-
Notifications
You must be signed in to change notification settings - Fork 28
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
improved narrowing of generics #745
Conversation
This comment has been minimized.
This comment has been minimized.
13dd380
to
56f2fd5
Compare
This comment has been minimized.
This comment has been minimized.
6e30215
to
2239619
Compare
This comment has been minimized.
This comment has been minimized.
2239619
to
69fb6f1
Compare
This comment has been minimized.
This comment has been minimized.
253fe90
to
d5ef6a7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/pyright-internal/src/tests/samples/typeNarrowingIsinstance6.py
Outdated
Show resolved
Hide resolved
Thanks for working on this. I tried working on it for a while, but I got stuck on trying to understand the code. |
i ran into a difficult to solve edge case that led to me abandoning this change for now (see the failing test case) but i may give it another go in the future |
You should pull from main here before looking at the diff there. |
db24af5
to
9a3e3d1
Compare
This comment has been minimized.
This comment has been minimized.
the primer identified this issue with constrained typevars: from typing import Literal
class Foo[T: (int, str)]:
...
def asdf(value: object):
if isinstance(value, Foo):
reveal_type(value) # `Foo[object]`, should be `Foo[int] | Foo[str]` |
…ant, or `Never` if it's contravariant
…hether to use variance to specialize type vars when narrowing
9a3e3d1
to
1a71f1d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
64e465f
to
e0ef69d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
03ae370
to
74f3b38
Compare
…ew functionality
…en the value being narrowed is a union
cccd781
to
04e71ae
Compare
isinstance
if it's covariant, or Never
if it's contravariant
This comment has been minimized.
This comment has been minimized.
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.
I looked over all the code. Didn't see any problems.
Diff from mypy_primer, showing the effect of this PR on open source code: more-itertools (https://github.com/more-itertools/more-itertools)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:224:5 - warning: Return type is unknown (reportUnknownParameterType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:224:5 - warning: Return type, "object | Unknown", is partially unknown (reportUnknownParameterType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:238:20 - warning: Return type is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:253:5 - warning: Return type is unknown (reportUnknownParameterType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:253:5 - warning: Return type, "object | Unknown", is partially unknown (reportUnknownParameterType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:267:12 - warning: Return type is unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:267:12 - warning: Return type, "object | Unknown", is partially unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2217:34 - warning: Type of "step" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2217:56 - warning: Type of "step" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2219:37 - error: Operator "<=" not supported for types "object" and "int" (reportOperatorIssue)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2219:16 - warning: Type of "start" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2219:37 - warning: Type of "start" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2221:18 - warning: Type of "start" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2221:18 - error: Operator ">=" not supported for types "object" and "int" (reportOperatorIssue)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2224:17 - warning: Type of "start" is unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2224:17 - warning: Type of "start" is partially unknown
+ Type of "start" is "Unknown | Any" (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2226:36 - error: Operator ">=" not supported for types "object" and "int" (reportOperatorIssue)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2224:44 - warning: Type of "start" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2224:44 - warning: Argument type is unknown
- Argument corresponds to parameter "i" in function "_get_by_index" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2226:16 - warning: Type of "stop" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2226:36 - warning: Type of "stop" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2228:18 - warning: Type of "stop" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2228:18 - error: Operator "<=" not supported for types "object" and "int" (reportOperatorIssue)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2231:17 - warning: Type of "stop" is unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2231:17 - warning: Type of "stop" is partially unknown
+ Type of "stop" is "Unknown | Any" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2231:43 - warning: Type of "stop" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2231:43 - warning: Argument type is unknown
- Argument corresponds to parameter "i" in function "_get_by_index" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2773:9 - warning: Type of "_target" is partially unknown
- Type of "_target" is "Sequence[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2775:9 - warning: Return type is unknown (reportUnknownParameterType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2775:9 - error: Method "__getitem__" overrides class "Sequence" in an incompatible manner
+ Return type mismatch: base method returns type "Sequence[Unknown]", override returns type "object"
+ "object" is not assignable to "Sequence[Unknown]" (reportIncompatibleMethodOverride)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2776:16 - warning: Type of "_target" is partially unknown
- Type of "_target" is "Sequence[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2776:16 - warning: Return type is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2779:20 - warning: Type of "_target" is partially unknown
- Type of "_target" is "Sequence[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2779:20 - warning: Argument type is partially unknown
- Argument corresponds to parameter "obj" in function "len"
- Argument type is "Sequence[Unknown]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2782:62 - warning: Type of "_target" is partially unknown
- Type of "_target" is "Sequence[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:2782:62 - warning: Argument type is partially unknown
- Argument corresponds to parameter "obj" in function "repr"
- Argument type is "Sequence[Unknown]" (reportUnknownArgumentType)
+ /tmp/mypy_primer/projects/more-itertools/more_itertools/more.py:4251:12 - error: "object" is not iterable
+ "__iter__" method not defined (reportGeneralTypeIssues)
- 24 errors, 2742 warnings, 0 notes
+ 30 errors, 2721 warnings, 0 notes
starlette (https://github.com/encode/starlette)
- Type of "exceptions" is "tuple[Unknown | BaseExceptionGroup[Unknown], ...]" (reportUnknownMemberType)
+ Type of "exceptions" is "tuple[Unknown | BaseExceptionGroup[Unknown], ...] | tuple[BaseException | BaseExceptionGroup[BaseException], ...]" (reportUnknownMemberType)
- Argument type is "tuple[Unknown | BaseExceptionGroup[Unknown], ...]" (reportUnknownArgumentType)
+ Argument type is "tuple[Unknown | BaseExceptionGroup[Unknown], ...] | tuple[BaseException | BaseExceptionGroup[BaseException], ...]" (reportUnknownArgumentType)
- Type of "exc" is "Unknown | BaseExceptionGroup[Unknown]" (reportUnknownVariableType)
+ Type of "exc" is "Unknown | BaseExceptionGroup[Unknown] | BaseException | BaseExceptionGroup[BaseException]" (reportUnknownVariableType)
- Type of "exceptions" is "tuple[Unknown | BaseExceptionGroup[Unknown]]" (reportUnknownMemberType)
+ Type of "exceptions" is "tuple[Unknown | BaseExceptionGroup[Unknown]] | tuple[BaseException | BaseExceptionGroup[BaseException]]" (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/starlette/starlette/testclient.py:336:39 - error: Argument of type "None" cannot be assigned to parameter "arg" of type "Never" in function "send"
+ Type "None" is not assignable to type "Never" (reportArgumentType)
- /tmp/mypy_primer/projects/starlette/starlette/testclient.py:336:21 - warning: Type of "chunk" is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/starlette/starlette/testclient.py:336:29 - warning: Type of "send" is partially unknown
- Type of "send" is "(arg: Unknown, /) -> Unknown" (reportUnknownMemberType)
- 206 errors, 4252 warnings, 0 notes
+ 207 errors, 4250 warnings, 0 notes
pytest (https://github.com/pytest-dev/pytest)
- /tmp/mypy_primer/projects/pytest/src/_pytest/python.py:978:34 - warning: Type of "pattern" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/python.py:978:34 - warning: Argument type is unknown
- Argument corresponds to parameter "val" in function "ascii_escaped" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:205:50 - warning: Argument type is partially unknown
- Argument corresponds to parameter "obj" in function "len"
- Argument type is "Sequence[Unknown]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:206:13 - warning: Type of "word" is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:206:19 - warning: Type of "markup" is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:208:24 - warning: Return type, "tuple[str, Mapping[Unknown, Unknown]]", is partially unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:208:24 - warning: Return type, "tuple[str, Mapping[Unknown, object]]", is partially unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/pytest/src/_pytest/reports.py:208:30 - error: Type "tuple[str, Mapping[Unknown, object]]" is not assignable to return type "tuple[str, Mapping[str, bool]]"
+ "Mapping[Unknown, object]" is not assignable to "Mapping[str, bool]"
+ Type parameter "_VT_co@Mapping" is covariant, but "object" is not a subtype of "bool"
+ "object" is not assignable to "bool" (reportReturnType)
- Argument type is "Mapping[Unknown, Unknown]" (reportUnknownArgumentType)
+ Argument type is "Mapping[Unknown, object]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/_code/code.py:789:37 - warning: Type of "value" is partially unknown
- Type of "value" is "BaseExceptionGroup[Unknown]*" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/_code/code.py:789:37 - warning: Argument type is partially unknown
- Argument corresponds to parameter "exc_group" in function "_group_contains"
- Argument type is "BaseExceptionGroup[Unknown]*" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1673:40 - warning: Argument type is partially unknown
- Argument corresponds to parameter "args" in function "__init__"
- Argument type is "PathLike[Unknown]" (reportUnknownArgumentType)
+ /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1673:40 - error: Argument of type "PathLike[str] | PathLike[bytes]" cannot be assigned to parameter "args" of type "StrPath" in function "__new__"
+ Type "PathLike[str] | PathLike[bytes]" is not assignable to type "StrPath"
+ Type "PathLike[bytes]" is not assignable to type "StrPath"
+ "PathLike[bytes]" is not assignable to "str"
+ "PathLike[bytes]" is not assignable to "PathLike[str]"
+ Type parameter "AnyStr_co@PathLike" is covariant, but "bytes" is not a subtype of "str"
+ "bytes" is not assignable to "str" (reportArgumentType)
+ /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1673:40 - error: Argument of type "PathLike[str] | PathLike[bytes]" cannot be assigned to parameter "args" of type "StrPath" in function "__init__"
+ Type "PathLike[str] | PathLike[bytes]" is not assignable to type "StrPath"
+ Type "PathLike[bytes]" is not assignable to type "StrPath"
+ "PathLike[bytes]" is not assignable to "str"
+ "PathLike[bytes]" is not assignable to "PathLike[str]"
+ Type parameter "AnyStr_co@PathLike" is covariant, but "bytes" is not a subtype of "str"
+ "bytes" is not assignable to "str" (reportArgumentType)
- 1162 errors, 17372 warnings, 0 notes
+ 1165 errors, 17364 warnings, 0 notes
mkosi (https://github.com/systemd/mkosi)
- /tmp/mypy_primer/projects/mkosi/mkosi/config.py:4924:20 - warning: Return type is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/mkosi/mkosi/config.py:4924:30 - warning: Argument type is partially unknown
- Argument corresponds to parameter "path" in function "fspath"
- Argument type is "PathLike[Unknown]" (reportUnknownArgumentType)
- 25 errors, 1559 warnings, 0 notes
+ 25 errors, 1557 warnings, 0 notes
openlibrary (https://github.com/internetarchive/openlibrary)
- /tmp/mypy_primer/projects/openlibrary/openlibrary/catalog/marc/tests/test_parse.py:119:28 - error: Argument of type "Iterable[Unknown]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+ /tmp/mypy_primer/projects/openlibrary/openlibrary/catalog/marc/tests/test_parse.py:119:28 - error: Argument of type "Iterable[object]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
- "Iterable[Unknown]" is incompatible with protocol "Sized"
+ "Iterable[object]" is incompatible with protocol "Sized"
- /tmp/mypy_primer/projects/openlibrary/openlibrary/catalog/marc/tests/test_parse.py:148:28 - error: Argument of type "Iterable[Unknown]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+ /tmp/mypy_primer/projects/openlibrary/openlibrary/catalog/marc/tests/test_parse.py:148:28 - error: Argument of type "Iterable[object]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
- "Iterable[Unknown]" is incompatible with protocol "Sized"
+ "Iterable[object]" is incompatible with protocol "Sized"
- Argument type is "set[Unknown]" (reportUnknownArgumentType)
+ Argument type is "set[Unknown] | set[object]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/openlibrary/openlibrary/solr/updater/abstract.py:53:68 - warning: Argument type is partially unknown
- Argument corresponds to parameter "o" in function "__init__"
- Argument type is "Any | Iterable[Unknown]" (reportUnknownArgumentType)
- 1920 errors, 33718 warnings, 0 notes
+ 1920 errors, 33717 warnings, 0 notes
yarl (https://github.com/aio-libs/yarl)
- /tmp/mypy_primer/projects/yarl/yarl/_url.py:1232:14 - warning: Unnecessary isinstance call; "Never" is always an instance of "Sequence[Unknown]" (reportUnnecessaryIsInstance)
+ /tmp/mypy_primer/projects/yarl/yarl/_url.py:1232:14 - warning: Unnecessary isinstance call; "Never" is always an instance of "Sequence[object]" (reportUnnecessaryIsInstance)
ibis (https://github.com/ibis-project/ibis)
- /tmp/mypy_primer/projects/ibis/ibis/util.py:650:13 - warning: Type of "hashable_obj" is partially unknown
- Type of "hashable_obj" is "tuple[Unknown, ...]*" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/ibis/ibis/util.py:650:34 - warning: Argument type is partially unknown
- Argument corresponds to parameter "iterable" in function "__new__"
- Argument type is "Sequence[Unknown]*" (reportUnknownArgumentType)
- Type of "hashable_obj" is "tuple[tuple[Unknown, Unknown], ...]" (reportUnknownVariableType)
+ Type of "hashable_obj" is "tuple[tuple[Unknown, object], ...]" (reportUnknownVariableType)
- Argument type is "ItemsView[Unknown, Unknown]" (reportUnknownArgumentType)
+ Argument type is "ItemsView[Unknown, object]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/ibis/ibis/util.py:654:13 - warning: Type of "hashable_obj" is partially unknown
- Type of "hashable_obj" is "frozenset[Unknown]*" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/ibis/ibis/util.py:654:38 - warning: Argument type is partially unknown
- Argument corresponds to parameter "iterable" in function "__new__"
- Argument type is "AbstractSet[Unknown]*" (reportUnknownArgumentType)
- Argument type is "tuple[type[Sequence[Unknown]]* | type[Mapping[Unknown, Unknown]]* | type[AbstractSet[Unknown]]* | type[object]*, tuple[Unknown, ...]* | tuple[tuple[Unknown, Unknown], ...] | frozenset[Unknown]* | int*]" (reportUnknownArgumentType)
+ Argument type is "tuple[type[Sequence[object]]* | type[Mapping[Unknown, object]]* | type[AbstractSet[object]]* | type[object]*, tuple[object, ...]* | tuple[tuple[Unknown, object], ...] | frozenset[object]* | int*]" (reportUnknownArgumentType)
- Argument type is "Sequence[Unknown]* | Mapping[Unknown, Unknown]* | AbstractSet[Unknown]* | object*" (reportUnknownArgumentType)
+ Argument type is "Sequence[object]* | Mapping[Unknown, object]* | AbstractSet[object]* | object*" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/__init__.py:443:9 - warning: Return type, "tuple[type[Value[Unknown, Unknown]], ...]", is partially unknown (reportUnknownParameterType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/__init__.py:444:16 - warning: Return type, "tuple[type[Value[Unknown, Unknown]], ...]", is partially unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/__init__.py:444:22 - warning: Argument type is partially unknown
- Argument corresponds to parameter "iterable" in function "__new__"
- Argument type is "Generator[type[Value[Unknown, Unknown]], None, None]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/__init__.py:455:9 - warning: Type of "op_classes" is partially unknown
- Type of "op_classes" is "tuple[type[Value[Unknown, Unknown]], ...]" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/__init__.py:455:22 - warning: Type of "_get_operations" is partially unknown
- Type of "_get_operations" is "_lru_cache_wrapper[tuple[type[Value[Unknown, Unknown]], ...]]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:379:13 - warning: Type of "repl" is partially unknown
- Type of "repl" is "Unknown | None" (reportUnknownVariableType)
- Type of "get" is "Overload[(key: Unknown, /) -> (Unknown | None), (key: Unknown, /, default: Unknown | _T@get) -> (Unknown | _T@get)]" (reportUnknownMemberType)
+ Type of "get" is "Overload[(key: Unknown, /) -> (object | None), (key: Unknown, /, default: object | _T@get) -> (object | _T@get)]" (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:381:29 - error: Cannot access attribute "value" for class "object"
+ Attribute "value" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:891:8 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:891:17 - error: Cannot access attribute "unit" for class "DataType"
+ Attribute "unit" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:894:18 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:894:27 - error: Cannot access attribute "unit" for class "DataType"
+ Attribute "unit" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:1391:12 - warning: Type of "step" is partially unknown
- Type of "step" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:1410:12 - warning: Type of "step" is partially unknown
- Type of "step" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:1411:12 - warning: Type of "step" is partially unknown
- Type of "step" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:1411:12 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/ibis/ibis/backends/polars/compiler.py:1411:26 - error: Cannot access attribute "unit" for class "DataType"
+ Attribute "unit" is unknown (reportAttributeAccessIssue)
- Type of "mapping" is "Mapping[Unknown, Unknown]" (reportUnknownVariableType)
+ Type of "mapping" is "Mapping[Unknown, object]" (reportUnknownVariableType)
- Type of "replacements" is "Mapping[Unknown, Unknown]" (reportUnknownMemberType)
+ Type of "replacements" is "Mapping[Unknown, object]" (reportUnknownMemberType)
- Type of "value" is "Unknown | None" (reportUnknownVariableType)
+ Type of "value" is "Unknown | object | None" (reportUnknownVariableType)
- Type of "get" is "Overload[(key: Unknown, /) -> (Unknown | None), (key: Unknown, /, default: Unknown | _T@get) -> (Unknown | _T@get)] | Overload[(key: Unknown, /) -> (Unknown | None), (key: Unknown, default: Unknown, /) -> Unknown, (key: Unknown, default: _T@get, /) -> (Unknown | _T@get)]" (reportUnknownMemberType)
+ Type of "get" is "Overload[(key: Unknown, /) -> (object | None), (key: Unknown, /, default: object | _T@get) -> (object | _T@get)] | Overload[(key: Unknown, /) -> (Unknown | None), (key: Unknown, default: Unknown, /) -> Unknown, (key: Unknown, default: _T@get, /) -> (Unknown | _T@get)]" (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/ibis/ibis/backends/sql/rewrites.py:168:38 - error: Argument of type "tuple[Field, Unknown | object]" cannot be assigned to parameter "arg" of type "VarTuple[Value[Unknown, Any]]" in function "__init__"
+ Type "Unknown | object" is not assignable to type "Value[Unknown, Any]"
+ "object" is not assignable to "Value[Unknown, Any]" (reportArgumentType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/rewrites.py:481:27 - warning: Type of "nth" is partially unknown
- Type of "nth" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/rewrites.py:481:50 - warning: Type of "nth" is partially unknown
- Type of "nth" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/rewrites.py:481:50 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/rewrites.py:481:50 - warning: Argument type is unknown
- Argument corresponds to parameter "dtype" in function "__init__" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/base.py:1000:61 - warning: Type of "length" is partially unknown
- Type of "length" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/clickhouse.py:707:22 - warning: Type of "step" is partially unknown
- Type of "step" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/duckdb.py:188:21 - warning: Type of "start" is partially unknown
- Type of "start" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/duckdb.py:196:24 - warning: Type of "stop" is partially unknown
- Type of "stop" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:342:9 - warning: Type of "idx" is partially unknown
- Type of "idx" is "Literal[Unknown]" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:342:15 - warning: Type of "index" is partially unknown
- Type of "index" is "Literal[Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:344:12 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:344:12 - warning: Type of "is_integer" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:347:20 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:347:20 - warning: Type of "is_string" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/flink.py:347:43 - warning: Type of "dtype" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/ibis/ibis/backends/sql/compilers/impala.py:240:13 - warning: Type of "format_str" is partially unknown
- Type of "format_str" is "Literal[Unknown]" (reportUnknownMemberType)
... (truncated 133 lines) ...
sympy (https://github.com/sympy/sympy)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:1662:20 - error: Argument of type "Iterable[Unknown]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+ /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:1662:20 - error: Argument of type "Iterable[object]" cannot be assigned to parameter "obj" of type "Sized" in function "len"
- "Iterable[Unknown]" is incompatible with protocol "Sized"
+ "Iterable[object]" is incompatible with protocol "Sized"
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:1664:60 - warning: Argument type is partially unknown
- Argument corresponds to parameter "args" in function "format"
- Argument type is "Iterable[Unknown]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:1665:21 - error: "__getitem__" method not defined on type "Iterable[Unknown]" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:1665:21 - error: "__getitem__" method not defined on type "Iterable[object]" (reportIndexIssue)
- /tmp/mypy_primer/projects/sympy/sympy/core/basic.py:412:18 - warning: Unnecessary isinstance call; "Never" is always an instance of "frozenset[Unknown]" (reportUnnecessaryIsInstance)
+ /tmp/mypy_primer/projects/sympy/sympy/core/basic.py:412:18 - warning: Unnecessary isinstance call; "Never" is always an instance of "frozenset[object]" (reportUnnecessaryIsInstance)
- /tmp/mypy_primer/projects/sympy/sympy/core/basic.py:413:34 - warning: Unnecessary isinstance call; "Never" is always an instance of "frozenset[Unknown]" (reportUnnecessaryIsInstance)
+ /tmp/mypy_primer/projects/sympy/sympy/core/basic.py:413:34 - warning: Unnecessary isinstance call; "Never" is always an instance of "frozenset[object]" (reportUnnecessaryIsInstance)
- /tmp/mypy_primer/projects/sympy/sympy/core/basic.py:414:28 - warning: Argument type is unknown
- Argument corresponds to parameter "args" in function "__new__" (reportUnknownArgumentType)
- Type of "sequence" is "ItemsView[Unknown, Unknown] | dict_items[Basic, Basic]" (reportUnknownVariableType)
+ Type of "sequence" is "ItemsView[Unknown, object] | dict_items[Basic, Basic]" (reportUnknownVariableType)
- Type of "s2" is "Unknown | Basic" (reportUnknownVariableType)
+ Type of "s2" is "Unknown | object | Basic" (reportUnknownVariableType)
- Type of "sequence" is "ItemsView[Unknown, Unknown] | dict_items[Basic, Basic]" (reportUnknownVariableType)
+ Type of "sequence" is "ItemsView[Unknown, object] | dict_items[Basic, Basic]" (reportUnknownVariableType)
- Type of "new" is "Unknown | Basic" (reportUnknownVariableType)
+ Type of "new" is "object | Basic | Unknown" (reportUnknownVariableType)
- Argument type is "ItemsView[Unknown, Unknown] | dict_items[Basic, Basic] | Unknown | list[tuple[Unknown, Unknown]]" (reportUnknownArgumentType)
+ Argument type is "ItemsView[Unknown, object] | dict_items[Basic, Basic] | Unknown | list[tuple[Unknown, Unknown]]" (reportUnknownArgumentType)
- Type of "__str__" is "((self: list[Unknown]) -> str) | ((self: tuple[Unknown, ...]) -> str) | ((self: set[Unknown]) -> str) | ((self: frozenset[Unknown]) -> str)" (reportUnknownMemberType)
+ Type of "__str__" is "((self: list[Unknown]) -> str) | ((self: tuple[Unknown, ...]) -> str) | ((self: set[Unknown]) -> str) | ((self: frozenset[object]) -> str)" (reportUnknownMemberType)
- Argument type is "list[Unknown] | tuple[Unknown, ...] | set[Unknown] | frozenset[Unknown]" (reportUnknownArgumentType)
+ Argument type is "list[Unknown] | tuple[Unknown, ...] | set[Unknown] | frozenset[object]" (reportUnknownArgumentType)
- Type of "__repr__" is "((self: list[Unknown]) -> str) | ((self: tuple[Unknown, ...]) -> str) | ((self: set[Unknown]) -> str) | ((self: frozenset[Unknown]) -> str)" (reportUnknownMemberType)
+ Type of "__repr__" is "((self: list[Unknown]) -> str) | ((self: tuple[Unknown, ...]) -> str) | ((self: set[Unknown]) -> str) | ((self: frozenset[object]) -> str)" (reportUnknownMemberType)
- Argument type is "list[Unknown] | tuple[Unknown, ...] | set[Unknown] | frozenset[Unknown]" (reportUnknownArgumentType)
+ Argument type is "list[Unknown] | tuple[Unknown, ...] | set[Unknown] | frozenset[object]" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/interactive/printing.py:149:39 - warning: Argument type is unknown
+ /tmp/mypy_primer/projects/sympy/sympy/interactive/printing.py:149:46 - warning: Type of "i" is partially unknown
+ Type of "i" is "Unknown | object" (reportUnknownVariableType)
- Argument corresponds to parameter "o" in function "_can_print" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/interactive/printing.py:149:46 - warning: Type of "i" is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/sympy/sympy/matrices/common.py:2293:62 - warning: Argument type is partially unknown
- Argument corresponds to parameter "iterable" in function "__init__"
- Argument type is "Permutation | Iterable[Unknown]" (reportUnknownArgumentType)
... (truncated 1707 lines) ...``` |
this is fantastic |
isinstance
if it's covariant,Never
if it's contravariantfixes #674