Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Mypy micro-optimizations (batch 1/3)#19768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2104,14 +2104,12 @@ def __init__( | ||
| ) -> None: | ||
| super().__init__(line, column) | ||
| assert len(arg_types) == len(arg_kinds) == len(arg_names) | ||
| self.arg_types = list(arg_types) | ||
| for t in self.arg_types: | ||
| if isinstance(t, ParamSpecType): | ||
| assert not t.prefix.arg_types | ||
| # TODO: should we assert that only ARG_STAR contain ParamSpecType? | ||
| # See testParamSpecJoin, that relies on passing e.g `P.args` as plain argument. | ||
| self.arg_kinds = arg_kinds | ||
| self.arg_names = list(arg_names) | ||
| self.min_args = arg_kinds.count(ARG_POS) | ||
| @@ -2123,7 +2121,11 @@ def __init__( | ||
| # * If it is a non-decorated function, FuncDef is the definition | ||
| # * If it is a decorated function, enclosing Decorator is the definition | ||
| self.definition = definition | ||
| self.variables: tuple[TypeVarLikeType, ...] | ||
| if variables is None: | ||
| self.variables = () | ||
| else: | ||
| self.variables = tuple(variables) | ||
Comment on lines -2126 to +2128 Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Note, this does crash the File"/.../python3.13/site-packages/pydantic/v1/mypy.py",line868,inadd_methodsignature.variables= [tvar_def]^^^^^^^^^^^^^^^^^^^TypeError:tupleobjectexpected;gotlist https://github.com/pydantic/pydantic/blob/v2.11.7/pydantic/v1/mypy.py#L866-L868 It can fairly easily be fixed and I'll open a PR for it soon. However, that might not be the only plugin which depends on it being "just" a sequence. CollaboratorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If we have evidence that this impacts multiple plugins, we can consider reverting this change. | ||
| self.is_ellipsis_args = is_ellipsis_args | ||
| self.implicit = implicit | ||
| self.special_sig = special_sig | ||
Uh oh!
There was an error while loading.Please reload this page.