-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow PEP 673 instead of PEP 484 when dealing with implicit self
#14712
Follow PEP 673 instead of PEP 484 when dealing with implicit self
#14712
Conversation
This comment has been minimized.
This comment has been minimized.
Looking through the results of
which can be fixed by changing https://github.com/Gobot1234/steam.py/blob/81d133cc27beba265ee960901e1c05a82c904c6c/steam/app.py#L712 to app: PartialApp = self EDIT: As an interesting thing to note, |
c06ee74
to
5d8724b
Compare
This comment has been minimized.
This comment has been minimized.
mypy/semanal.py
Outdated
leading_type: Type = self.type.self_type | ||
else: | ||
leading_type = fill_typevars(info) | ||
leading_type: Type = info.self_type if info.self_type else fill_typevars(info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH this is quite arbitrary. This will result in Self
inferred if it is used explicitly somewhere else in the current class. Something like this will continue to error (unless I am missing something):
from typing import Self
class C:
x: Self
class D(C):
def foo(self) -> None:
self.x = self
But also as I mentioned in the issue, finding a heuristic that will work well without also causing big perf penalty is hard. Another option to consider is adding a flag for this (like --force-implicit-self
) and then create and use self types always.
In general, I would not hurry with this, we need to carefully consider all options, since it may be hard to undo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this will continue to error (unless I am missing something):
I did not account for that, tweaked some code and using:
self.setup_self_type()
leading_type: Type = info.self_type
to determine leading_type fixes it (setup_self_type
wont replace the type if its already set)
I am going to push this to the branch just to be able to run mypy-primer
on it and see the results, its not final
EDIT: Also important to note that this causes a lot of test failures due to reveal_type
using Self
instead of the class name. I will go around fixing them if this is the way it is decided to go, but wont spend time on it atm
But something I noticed is that mypy seems to completely ignore inheritance when dealing with Self
, something that pyright
smartly deals with. Maybe the implementation of Self
should be revisited and all these weird edge cases will disappear. I also dont personally like implementing a --force-implicit-self
type, as this should be the default as stated in PEP 673. It should be sensible of mypy to properly deal and treat with these issues without having to enable extra flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But something I noticed is that mypy seems to completely ignore inheritance when dealing with Self
What does this mean? Also you are talking so much about pyright, just go work with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean? Also you are talking so much about pyright, just go work with it.
I didnt mean to sound mean with the comment. Just wanted to point out that it might be better to deal with Self
in a different way than mypy
that might help to deal with all these edge cases that are being found as people start to use Self
with mypy
. I do not have any intent to turn mypy into pyright, was just pointing out a different implementation that might be better to deal with these cases.
I sincerely apologize if my comment came out as "pyright is better than mypy and mypy should follow its lead", it wasnt my intention. I am sorry
Diff from mypy_primer, showing the effect of this PR on open source code: pylox (https://github.com/sco1/pylox)
- pylox/ast_printer.py:10: error: Argument 1 to "accept" of "Expr" has incompatible type "AstPrinter"; expected "VisitorProtocol" [arg-type]
+ pylox/ast_printer.py:10: error: Argument 1 to "accept" of "Expr" has incompatible type "Self"; expected "VisitorProtocol" [arg-type]
- pylox/ast_printer.py:17: error: Argument 1 to "accept" of "Expr" has incompatible type "AstPrinter"; expected "VisitorProtocol" [arg-type]
+ pylox/ast_printer.py:17: error: Argument 1 to "accept" of "Expr" has incompatible type "Self"; expected "VisitorProtocol" [arg-type]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/dtypes/dtypes.py:871: error: Argument 1 to "__new__" of "PeriodDtypeBase" has incompatible type "Type[PeriodDtype]"; expected "Type[Self]" [arg-type]
+ pandas/core/dtypes/dtypes.py:882: error: Argument 1 to "__new__" of "PeriodDtypeBase" has incompatible type "Type[PeriodDtype]"; expected "Type[Self]" [arg-type]
+ pandas/core/arrays/base.py:434: error: Unused "type: ignore" comment
+ pandas/core/arrays/base.py:434: error: "bool" has no attribute "any" [attr-defined]
+ pandas/core/arrays/base.py:434: note: Error code "attr-defined" not covered by "type: ignore" comment
+ pandas/core/arrays/arrow/array.py:721: error: Incompatible types in assignment (expression has type "ArrowExtensionArray", variable has type "Self") [assignment]
+ pandas/core/arrays/interval.py:1076: error: Incompatible types in assignment (expression has type "IntervalArray", variable has type "Self") [assignment]
+ pandas/core/arrays/interval.py:1077: error: List item 0 has incompatible type "IntervalArray"; expected "Self" [list-item]
+ pandas/core/arrays/datetimelike.py:445: error: Incompatible types in assignment (expression has type "DatetimeArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:451: error: "Self" has no attribute "tz" [attr-defined]
+ pandas/core/arrays/datetimelike.py:453: error: "Self" has no attribute "_creso" [attr-defined]
+ pandas/core/arrays/datetimelike.py:808: error: Incompatible types in assignment (expression has type "Union[DatetimeArray, TimedeltaArray]", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:809: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1036: error: Incompatible types in assignment (expression has type "TimedeltaArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1046: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1051: error: "Self" has no attribute "_ensure_matching_resos" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1052: error: Incompatible types in assignment (expression has type "TimedeltaArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1058: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1060: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1061: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1080: error: Incompatible types in assignment (expression has type "DatetimeArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1100: error: Incompatible types in assignment (expression has type "DatetimeArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1102: error: "Self" has no attribute "_ensure_matching_resos" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1107: error: Incompatible types in assignment (expression has type "DatetimeArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1112: error: "Self" has no attribute "_assert_tzawareness_compat" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1121: error: "Self" has no attribute "unit" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1174: error: Incompatible types in assignment (expression has type "Union[DatetimeArray, TimedeltaArray]", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1176: error: "Self" has no attribute "_ensure_matching_resos" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1181: error: Incompatible types in assignment (expression has type "Union[DatetimeArray, TimedeltaArray]", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1191: error: Unexpected keyword argument "freq" for "_simple_new" of "NDArrayBacked" [call-arg]
+ pandas/_libs/arrays.pyi:15: note: "_simple_new" of "NDArrayBacked" defined here
+ pandas/core/arrays/datetimelike.py:1080: error: Incompatible types in assignment (expression has type "DatetimeArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1089: error: "Self" has no attribute "_ensure_matching_resos" [attr-defined]
+ pandas/core/arrays/datetimelike.py:1240: error: Incompatible types in assignment (expression has type "PeriodArray", variable has type "Self") [assignment]
+ pandas/core/arrays/datetimelike.py:1241: error: Argument 1 to "_check_compatible_with" of "DatetimeLikeArrayMixin" has incompatible type "Union[Period, PeriodArray]"; expected "Union[Union[Period, Timestamp, Timedelta], NaTType]" [arg-type]
+ pandas/core/arrays/datetimelike.py:1247: error: Item "None" of "Optional[BaseOffset]" has no attribute "base" [union-attr]
+ pandas/core/apply.py:941: error: Argument 1 to "__setattr__" of "object" has incompatible type "Series"; expected "Self" [arg-type]
+ pandas/core/indexes/frozen.py:71: error: Unused "type: ignore" comment
+ pandas/core/indexes/frozen.py:114: error: Unused "type: ignore" comment
+ pandas/core/indexes/base.py:1244: error: Incompatible types in assignment (expression has type "CategoricalIndex", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:1245: error: "Self" has no attribute "categories" [attr-defined]
+ pandas/core/indexes/base.py:2033: error: Incompatible types in assignment (expression has type "MultiIndex", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:2035: error: "Self" has no attribute "levels" [attr-defined]
+ pandas/core/indexes/base.py:2036: error: "Self" has no attribute "codes" [attr-defined]
+ pandas/core/indexes/base.py:3210: error: Argument 1 to "_outer_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:3298: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:3359: error: Argument 1 to "_inner_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4440: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4446: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4457: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4512: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4604: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4688: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4797: error: Incompatible return value type (got "Tuple[object, None, None]", expected "Tuple[Index, Optional[ndarray[Any, dtype[signedinteger[Any]]]], Optional[ndarray[Any, dtype[signedinteger[Any]]]]]") [return-value]
+ pandas/core/indexes/base.py:4807: error: Argument 1 to "_left_indexer_unique" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4809: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:4813: error: Argument 1 to "_inner_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4814: error: Argument 2 to "_wrap_joined_index" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4816: error: Argument 1 to "_outer_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4817: error: Argument 2 to "_wrap_joined_index" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4820: error: Argument 1 to "_left_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4824: error: Argument 1 to "_inner_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4826: error: Argument 1 to "_outer_indexer" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:4831: error: Argument 2 to "_wrap_joined_index" of "Index" has incompatible type "Index"; expected "Self" [arg-type]
+ pandas/core/indexes/base.py:5226: error: Argument 1 to "_concat" of "Index" has incompatible type "List[Self]"; expected "List[Index]" [arg-type]
+ pandas/core/indexes/base.py:5226: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ pandas/core/indexes/base.py:5226: note: Consider using "Sequence" instead, which is covariant
+ pandas/core/indexes/base.py:6017: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/base.py:6021: error: Incompatible types in assignment (expression has type "Index", variable has type "Self") [assignment]
+ pandas/core/indexes/datetimelike.py:537: error: Argument 1 to "_can_fast_intersect" of "DatetimeTimedeltaMixin" has incompatible type "DatetimeTimedeltaMixin"; expected "Self" [arg-type]
+ pandas/core/indexes/datetimes.py:632: error: Argument 1 to "slice_indexer" of "Index" has incompatible type "DatetimeIndex"; expected "Self" [arg-type]
+ pandas/core/internals/base.py:130: error: Argument 1 to "_equal_values" of "DataManager" has incompatible type "DataManager"; expected "Self" [arg-type]
... (truncated 64 lines) ...
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/debug/repr.py:266: error: Argument 1 to "__repr__" of "object" has incompatible type "object"; expected "Self" [arg-type]
+ src/werkzeug/formparser.py:327: error: Dict entry 0 has incompatible type "str": "Callable[[Self, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]"; expected "str": "Callable[[FormDataParser, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]" [dict-item]
+ src/werkzeug/formparser.py:328: error: Dict entry 1 has incompatible type "str": "Callable[[Self, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]"; expected "str": "Callable[[FormDataParser, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]" [dict-item]
+ src/werkzeug/formparser.py:329: error: Dict entry 2 has incompatible type "str": "Callable[[Self, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]"; expected "str": "Callable[[FormDataParser, IO[bytes], str, Optional[int], Dict[str, str]], Tuple[IO[bytes], MultiDict[Any, Any], MultiDict[Any, Any]]]" [dict-item]
+ src/werkzeug/routing/map.py:905: error: Need type annotation for "k" [var-annotated]
+ src/werkzeug/routing/map.py:905: error: Need type annotation for "v" [var-annotated]
+ src/werkzeug/routing/map.py:907: error: Argument 1 to "items" of "dict" has incompatible type "MultiDict[Any, Any]"; expected "Self" [arg-type]
poetry (https://github.com/python-poetry/poetry)
- Warning: unused section(s) in pyproject.toml: module = ['xattr.*']
+ /tmp/mypy_primer/projects/_poetry_venv/lib/python3.10/site-packages/pip/_vendor/rich/color_triplet.py:17: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.1.0+dev.fa63adc20c42d2f66d5c3f13b941e32bdea8f36f
- src/poetry/layouts/layout.py:93: error: Unused "type: ignore" comment
- src/poetry/layouts/layout.py:96: error: Unused "type: ignore" comment
- src/poetry/console/exceptions.py:6: error: Class cannot subclass "CleoError" (has type "Any") [misc]
- src/poetry/console/command_loader.py:15: error: Class cannot subclass "FactoryCommandLoader" (has type "Any") [misc]
- src/poetry/console/io/inputs/run_argv_input.py:12: error: Class cannot subclass "ArgvInput" (has type "Any") [misc]
- src/poetry/locations.py:55: error: Returning Any from function declared to return "Path" [no-any-return]
- src/poetry/mixology/term.py:155: error: Returning Any from function declared to return "bool" [no-any-return]
- src/poetry/poetry.py:23: error: Class cannot subclass "BasePoetry" (has type "Any") [misc]
- src/poetry/utils/password_manager.py:69: error: Returning Any from function declared to return "Optional[str]" [no-any-return]
- src/poetry/mixology/version_solver.py:424: error: Returning Any from function declared to return "Optional[str]" [no-any-return]
- src/poetry/mixology/version_solver.py:453: error: Returning Any from function declared to return "Optional[str]" [no-any-return]
- src/poetry/mixology/solutions/solutions/python_requirement_solution.py:13: error: Class cannot subclass "Solution" (has type "Any") [misc]
- src/poetry/installation/wheel_installer.py:28: error: Class cannot subclass "SchemeDictionaryDestination" (has type "Any") [misc]
- src/poetry/mixology/solutions/providers/python_requirement_solution_provider.py:16: error: Class cannot subclass "HasSolutionsForException" (has type "Any") [misc]
- src/poetry/packages/locker.py:322: error: Returning Any from function declared to return "Dict[str, Any]" [no-any-return]
- src/poetry/packages/locker.py:349: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]
- src/poetry/factory.py:39: error: Class cannot subclass "BaseFactory" (has type "Any") [misc]
- src/poetry/factory.py:293: error: "Dict[str, Any]" has no attribute "add" [attr-defined]
- src/poetry/factory.py:297: error: "Dict[str, Any]" has no attribute "as_string" [attr-defined]
- src/poetry/factory.py:310: error: Returning Any from function declared to return "Dict[str, List[str]]" [no-any-return]
- src/poetry/vcs/git/backend.py:40: error: Returning Any from function declared to return "bytes" [no-any-return]
- src/poetry/vcs/git/backend.py:170: error: Returning Any from function declared to return "str" [no-any-return]
- src/poetry/puzzle/provider.py:77: error: Class cannot subclass "ProgressIndicator" (has type "Any") [misc]
- src/poetry/puzzle/provider.py:169: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]
- src/poetry/masonry/builders/editable.py:45: error: Class cannot subclass "Builder" (has type "Any") [misc]
- src/poetry/installation/chef.py:44: error: Class cannot subclass "BaseIsolatedEnv" (has type "Any") [misc]
- src/poetry/installation/executor.py:807: error: Returning Any from function declared to return "Path" [no-any-return]
- src/poetry/console/commands/command.py:15: error: Class cannot subclass "BaseCommand" (has type "Any") [misc]
- src/poetry/console/application.py:96: error: Class cannot subclass "BaseApplication" (has type "Any") [misc]
- src/poetry/console/commands/self/self_command.py:78: error: Unused "type: ignore" comment
- src/poetry/console/commands/show.py:414: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]
- src/poetry/console/commands/show.py:463: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]
+ Traceback (most recent call last):
+ File "", line 8, in <module>
+ sys.exit(console_entry())
+ File "/__main__.py", line 15, in console_entry
+ main()
+ File "/main.py", line 95, in main
+ res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+ File "/main.py", line 174, in run_build
+ res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+ File "/build.py", line 194, in build
+ result = _build(
+ File "/build.py", line 277, in _build
+ graph = dispatch(sources, manager, stdout)
+ File "/build.py", line 2923, in dispatch
+ process_graph(graph, manager)
+ File "/build.py", line 3320, in process_graph
+ process_stale_scc(graph, scc, manager)
+ File "/build.py", line 3421, in process_stale_scc
+ graph[id].type_check_first_pass()
+ File "/build.py", line 2317, in type_check_first_pass
+ self.type_checker().check_first_pass()
+ File "/checker.py", line 474, in check_first_pass
+ self.accept(d)
+ File "/checker.py", line 582, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1123, in accept
+ return visitor.visit_class_def(self)
+ File "/checker.py", line 2163, in visit_class_def
+ self.accept(defn.defs)
+ File "/checker.py", line 582, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1204, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 2607, in visit_block
+ self.accept(s)
+ File "/checker.py", line 582, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 884, in accept
+ return visitor.visit_decorator(self)
+ File "/checker.py", line 4611, in visit_decorator
+ self.check_func_item(e.func, name=e.func.name)
+ File "/checker.py", line 1035, in check_func_item
+ self.check_func_def(defn, typ, name, allow_empty)
+ File "/checker.py", line 1215, in check_func_def
+ self.accept(item.body)
+ File "/checker.py", line 582, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1204, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 2607, in visit_block
+ self.accept(s)
+ File "/checker.py", line 582, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1291, in accept
+ return visitor.visit_assignment_stmt(self)
+ File "/checker.py", line 2655, in visit_assignment_stmt
+ self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
+ File "/checker.py", line 2710, in check_assignment
+ self.check_assignment_to_multiple_lvalues(
+ File "/checker.py", line 3364, in check_assignment_to_multiple_lvalues
+ self.check_multi_assignment(lvalues, rvalue, context, infer_lvalue_type)
+ File "/checker.py", line 3411, in check_multi_assignment
+ self.check_multi_assignment_from_tuple(
+ File "/checker.py", line 3547, in check_multi_assignment_from_tuple
+ assert isinstance(reinferred_rvalue_type, TupleType)
+ AssertionError:
pyjwt (https://github.com/jpadilla/pyjwt)
- jwt/algorithms.py:590: error: Argument "salt_length" to "PSS" has incompatible type "Callable[[HashAlgorithm], int]"; expected "Union[int, _MaxLength, _Auto, _DigestLength]" [arg-type]
+ jwt/algorithms.py:590: error: Argument "salt_length" to "PSS" has incompatible type "Callable[[Self], int]"; expected "Union[int, _MaxLength, _Auto, _DigestLength]" [arg-type]
- jwt/algorithms.py:602: error: Argument "salt_length" to "PSS" has incompatible type "Callable[[HashAlgorithm], int]"; expected "Union[int, _MaxLength, _Auto, _DigestLength]" [arg-type]
+ jwt/algorithms.py:602: error: Argument "salt_length" to "PSS" has incompatible type "Callable[[Self], int]"; expected "Union[int, _MaxLength, _Auto, _DigestLength]" [arg-type]
pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/commands/cyclic.py:19: error: Argument "type" to "add_argument" of "_ActionsContainer" has incompatible type "Callable[[Self, str, str], bytes]"; expected "Union[Callable[[str], <nothing>], FileType]" [arg-type]
Auto-Split (https://github.com/Avasam/Auto-Split)
- src/region_selection.py:89: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/region_selection.py:89: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
- src/region_selection.py:130: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/region_selection.py:130: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
- src/capture_method/__init__.py:100: error: Incompatible types in assignment (expression has type "None", base class "dict" defined the type as "Callable[[Dict[CaptureMethodEnum, CaptureMethodInfo], CaptureMethodEnum], CaptureMethodInfo]") [assignment]
+ src/capture_method/__init__.py:100: error: Incompatible types in assignment (expression has type "None", base class "dict" defined the type as "Callable[[Self, CaptureMethodEnum], CaptureMethodInfo]") [assignment]
- src/AutoSplit.py:346: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/AutoSplit.py:346: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
- src/AutoSplit.py:681: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/AutoSplit.py:681: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
- src/AutoSplit.py:690: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/AutoSplit.py:690: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
- src/AutoSplit.py:723: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "QTest" [arg-type]
+ src/AutoSplit.py:723: error: Argument 1 to "qWait" of "QTest" has incompatible type "int"; expected "Self" [arg-type]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/path.py:102: error: Incompatible return value type (got "object", expected "LocalPath") [return-value]
+ boostedblob/path.py:170: error: Incompatible return value type (got "object", expected "AzurePath") [return-value]
+ boostedblob/path.py:227: error: Incompatible return value type (got "object", expected "GooglePath") [return-value]
artigraph (https://github.com/artigraph/artigraph)
+ src/arti/internal/models.py:176: error: Argument 1 to "__setattr__" of "object" has incompatible type "_Model"; expected "Self" [arg-type]
+ src/arti/internal/models.py:183: error: Argument 1 to "__setattr__" of "object" has incompatible type "_Model"; expected "Self" [arg-type]
+ src/arti/partitions/__init__.py:37: error: Cannot infer type argument 2 of "register" [misc]
+ src/arti/views/__init__.py:38: error: Argument 1 to "register" has incompatible type "Dict[type, Type[View]]"; expected "Dict[type, Type[object]]" [arg-type]
+ src/arti/views/__init__.py:38: note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ src/arti/views/__init__.py:38: note: Consider using "Mapping" instead, which is covariant in the value type
+ src/arti/views/__init__.py:38: error: "object" has no attribute "priority" [attr-defined]
+ src/arti/views/__init__.py:38: error: Returning Any from function declared to return "int" [no-any-return]
+ src/arti/views/__init__.py:38: error: "Type[object]" has no attribute "priority" [attr-defined]
+ src/arti/views/__init__.py:94: error: Incompatible types in assignment (expression has type "Optional[Type[View]]", variable has type "Optional[Type[Self]]") [assignment]
+ src/arti/views/__init__.py:98: error: Incompatible types in assignment (expression has type "Optional[Type[View]]", variable has type "Optional[Type[Self]]") [assignment]
+ tests/arti/graphs/test_graph.py:139: error: Argument 1 to "combine" of "Fingerprint" has incompatible type "*List[Fingerprint]"; expected "Self" [arg-type]
+ tests/arti/graphs/test_graph.py:141: error: Argument 1 to "combine" of "Fingerprint" has incompatible type "*reversed[Fingerprint]"; expected "Self" [arg-type]
apprise (https://github.com/caronc/apprise)
- apprise/plugins/NotifyEmail.py:834: error: "NotifyEmail" has no attribute "throttle" [attr-defined]
+ apprise/plugins/NotifyEmail.py:834: error: "Self" has no attribute "throttle" [attr-defined]
- apprise/plugins/NotifyEmail.py:837: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:837: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:840: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:840: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:852: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:852: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:855: error: "NotifyEmail" has no attribute "password" [attr-defined]
+ apprise/plugins/NotifyEmail.py:855: error: "Self" has no attribute "password" [attr-defined]
- apprise/plugins/NotifyEmail.py:857: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:857: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:858: error: "NotifyEmail" has no attribute "password" [attr-defined]
+ apprise/plugins/NotifyEmail.py:858: error: "Self" has no attribute "password" [attr-defined]
- apprise/plugins/NotifyEmail.py:868: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:868: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:871: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:871: error: "Self" has no attribute "logger" [attr-defined]
- apprise/plugins/NotifyEmail.py:879: error: "NotifyEmail" has no attribute "logger" [attr-defined]
+ apprise/plugins/NotifyEmail.py:879: error: "Self" has no attribute "logger" [attr-defined]
sympy (https://github.com/sympy/sympy)
+ sympy/core/containers.py:329: error: Incompatible types in assignment (expression has type "Callable[[Self], int]", variable has type "Callable[[Basic], Any]") [assignment]
+ sympy/sets/sets.py:2131: error: Incompatible types in assignment (expression has type "Callable[[Self], int]", variable has type "Callable[[Basic], Any]") [assignment]
porcupine (https://github.com/Akuli/porcupine)
- porcupine/utils.py:408: error: No overload variant of "asdict" matches argument type "EventDataclass" [call-overload]
+ porcupine/utils.py:408: error: No overload variant of "asdict" matches argument type "Self" [call-overload]
+ porcupine/plugins/filetypes.py:295: error: Argument "key" to "sorted" has incompatible type "Callable[[Self], str]"; expected "Callable[[str], Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]]" [arg-type]
pip (https://github.com/pypa/pip)
- src/pip/_internal/metadata/_json.py:67: error: Item "None" of "Optional[List[Any]]" has no attribute "__iter__" (not iterable) [union-attr]
- src/pip/_internal/metadata/_json.py:70: error: Argument 1 to "sanitise_header" has incompatible type "Optional[Any]"; expected "Union[Header, str]" [arg-type]
- src/pip/_internal/metadata/pkg_resources.py:228: error: Argument 1 to "Environment" has incompatible type "None"; expected "WorkingSet" [arg-type]
- src/pip/_internal/network/auth.py:427: error: "Response" has no attribute "connection" [attr-defined]
- src/pip/_internal/network/session.py:246: error: Cannot assign to a method [method-assign]
- src/pip/_internal/network/session.py:389: error: Incompatible types in assignment (expression has type "HTTPAdapter", variable has type "CacheControlAdapter") [assignment]
- src/pip/_internal/network/session.py:390: error: Incompatible types in assignment (expression has type "InsecureHTTPAdapter", variable has type "InsecureCacheControlAdapter") [assignment]
- src/pip/_internal/network/xmlrpc.py:36: error: Argument 3 of "request" is incompatible with supertype "Transport"; supertype defines the argument type as "Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]]" [override]
- src/pip/_internal/network/xmlrpc.py:36: note: This violates the Liskov substitution principle
- src/pip/_internal/network/xmlrpc.py:36: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ src/pip/_vendor/rich/color_triplet.py:17: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.1.0+dev.fa63adc20c42d2f66d5c3f13b941e32bdea8f36f
+ src/pip/_vendor/rich/color_triplet.py:17: : note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+ File "", line 8, in <module>
+ sys.exit(console_entry())
+ File "/__main__.py", line 15, in console_entry
+ main()
+ File "/main.py", line 95, in main
+ res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+ File "/main.py", line 174, in run_build
... (truncated 816 lines) ...``` |
I am opening this PR as a possible fix for #14075, where there seems to be a clash of PEP's, prioritizing the newer and more complete one, as it describes the feature that is being implemented and supported here.
I was not able to find any discussions on this subject apart from in the before mentioned issue and the pr that adds
typing.Self
support mentioning the opening of the followup issue (#14041 (comment))For more info on the reason behind this change, see: #14075 (comment) and #14708 (comment)
Fixes #14075