Skip to content
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

Fixed bug that led to an inconsistency between the use of type and … #6253

Merged
merged 2 commits into from
Nov 2, 2023

Conversation

erictraut
Copy link
Collaborator

Type when applying isinstance type narrowing in some cases. This addresses #6252.

…`Type` when applying `isinstance` type narrowing in some cases. This addresses #6252.
@github-actions

This comment has been minimized.

…ble as an argument in a call expression _after_ a keyword argument. This addresses #6247.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spack (https://github.com/spack/spack)
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/mirror.py:705:13 - error: No overloads for "print_exception" match the provided arguments
-     Argument types: (TextIO, *OptExcInfo | Unbound) (reportGeneralTypeIssues)
- 3830 errors, 48 warnings, 0 informations 
+ 3829 errors, 48 warnings, 0 informations 

Tanjun (https://github.com/FasterSpeeding/Tanjun)
-   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:2222:16 - warning: Return type, "Unknown | type[_T@__getitem__]", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:2222:16 - warning: Return type, "Type[Unknown] | type[_T@__getitem__]", is partially unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:2204:9 - error: Return type, "Unknown | type[_T@__getitem__]", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:2204:9 - error: Return type, "Type[Unknown] | type[_T@__getitem__]", is partially unknown (reportUnknownParameterType)

dd-trace-py (https://github.com/DataDog/dd-trace-py): typechecking got 1.28x faster (62.9s -> 49.0s)
(Performance measurements are based on a single noisy sample)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/debugging/_debugger.py:411:48 - error: Argument of type "type[CoroutineType[_YieldT_co@CoroutineType, _SendT_contra@CoroutineType, _ReturnT_co@CoroutineType]] | None" cannot be assigned to parameter "types" of type "Type[Unknown] | Tuple[Type[Unknown] | Tuple[Any, ...], ...]" in function "_isinstance" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/debugging/_function/discovery.py:246:39 - error: Argument of type "type[(self: ContainerIterator, container: FunctionContainerType, origin: Tuple[ContainerIterator, ContainerKey] | Tuple[FullyNamedFunction, str] | None = None) -> None] | None" cannot be assigned to parameter "types" of type "Type[Unknown] | Tuple[Type[Unknown] | Tuple[Any, ...], ...]" in function "_isinstance" (reportGeneralTypeIssues)
- 9533 errors, 464 warnings, 0 informations 
+ 9535 errors, 464 warnings, 0 informations 

pandera (https://github.com/pandera-dev/pandera)
+   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:57:27 - error: Cannot access member "CHECK_FUNCTION_REGISTRY" for type "Type[Unknown]"
+     Member "CHECK_FUNCTION_REGISTRY" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:193:21 - error: Cannot access member "_register_equivalents" for type "_EngineType[Unknown]"
+     Member "_register_equivalents" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:196:21 - error: Cannot access member "_register_from_parametrized_dtype" for type "_EngineType[Unknown]"
+     Member "_register_from_parametrized_dtype" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:198:17 - error: Cannot access member "_registered_dtypes" for type "_EngineType[Unknown]"
+     Member "_registered_dtypes" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:209:38 - error: Cannot access member "_base_pandera_dtypes" for type "_EngineType[Unknown]"
+     Member "_base_pandera_dtypes" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:215:43 - error: Cannot access member "_base_pandera_dtypes" for type "_EngineType[Unknown]"
+     Member "_base_pandera_dtypes" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:228:24 - error: Cannot access member "_registry" for type "_EngineType[Unknown]"
+     Member "_registry" is unknown (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/tests/core/test_schemas.py:1742:18 - error: Expression of type "Type[Unknown] | str" cannot be assigned to declared type "Type[Unknown]"
+     Type "Type[Unknown] | str" cannot be assigned to type "Type[Unknown]"
+       "str" is incompatible with "Type[Unknown]" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pandera/tests/core/test_schemas.py:1745:16 - error: Expression of type "Type[Unknown] | str" cannot be assigned to declared type "Type[Unknown]"
+     Type "Type[Unknown] | str" cannot be assigned to type "Type[Unknown]"
+       "str" is incompatible with "Type[Unknown]" (reportGeneralTypeIssues)
- 1116 errors, 10 warnings, 0 informations 
+ 1125 errors, 10 warnings, 0 informations 

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:929:21 - error: "assert_type" mismatch: expected "Index[float]" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:951:21 - error: "assert_type" mismatch: expected "Index[complex]" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1030:23 - error: Operator "/" not supported for types "Index[int]" and "timedelta" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1030:23 - error: "assert_type" mismatch: expected "Index[float]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1031:23 - error: Operator "/" not supported for types "Index[int]" and "list[timedelta]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1031:23 - error: "assert_type" mismatch: expected "Index[float]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1032:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1033:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1034:23 - error: Operator "//" not supported for types "Index[int]" and "timedelta" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1034:23 - error: "assert_type" mismatch: expected "Index[int]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1035:23 - error: Operator "//" not supported for types "Index[int]" and "list[timedelta]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1035:23 - error: "assert_type" mismatch: expected "Index[int]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1036:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1037:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1039:23 - error: Operator "/" not supported for types "timedelta" and "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1039:23 - error: "assert_type" mismatch: expected "Index[float]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1040:23 - error: Operator "/" not supported for types "list[timedelta]" and "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1040:23 - error: "assert_type" mismatch: expected "Index[float]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1041:23 - error: Operator "//" not supported for types "timedelta" and "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1041:23 - error: "assert_type" mismatch: expected "Index[int]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1042:23 - error: Operator "//" not supported for types "list[timedelta]" and "Index[int]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1042:23 - error: "assert_type" mismatch: expected "Index[int]" but received "Unknown" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1045:63 - error: Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues"
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1046:65 - error: Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues"
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1047:64 - error: Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues"
-   /tmp/mypy_primer/projects/pandas-stubs/tests/test_indexes.py:1048:66 - error: Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues"
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:91:9 - error: Overload 3 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:69:9 - error: Overload 1 for "__new__" overlaps overload 3 and returns an incompatible type (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:102:9 - error: Overload 4 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
+   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:102:9 - error: Overload 4 for "__new__" will never be used because its parameters overlap overload 3 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:80:9 - error: Overload 2 for "__new__" overlaps overload 4 and returns an incompatible type (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:113:9 - error: Overload 5 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:69:9 - error: Overload 1 for "__new__" overlaps overload 5 and returns an incompatible type (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:126:9 - error: Overload 6 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
+   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:126:9 - error: Overload 6 for "__new__" will never be used because its parameters overlap overload 5 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:80:9 - error: Overload 2 for "__new__" overlaps overload 6 and returns an incompatible type (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:138:9 - error: Overload 7 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:149:9 - error: Overload 8 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:160:9 - error: Overload 9 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:171:9 - error: Overload 10 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:182:9 - error: Overload 11 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:193:9 - error: Overload 12 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:204:9 - error: Overload 13 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
-   /tmp/mypy_primer/projects/pandas-stubs/pandas-stubs/core/indexes/base.pyi:215:9 - error: Overload 14 for "__new__" will never be used because its parameters overlap overload 1 (reportOverlappingOverload)
- 1366 errors, 0 warnings, 0 informations 
+ 1326 errors, 0 warnings, 0 informations 

@erictraut erictraut merged commit 5b6d786 into main Nov 2, 2023
12 checks passed
@erictraut erictraut deleted the issue6252 branch November 2, 2023 18:56
@erictraut erictraut restored the issue6252 branch November 7, 2023 01:14
@erictraut erictraut deleted the issue6252 branch November 7, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant