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 results in a false negative if a | union operator cr… #9422

Closed
wants to merge 1 commit into from

Conversation

erictraut
Copy link
Collaborator

…eates a union of generic types. These types should be specialized with default type arguments. This addresses #9415.

…eates a union of generic types. These types should be specialized with default type arguments. This addresses #9415.
Copy link
Contributor

github-actions bot commented Nov 7, 2024

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

ibis (https://github.com/ibis-project/ibis)
+           "Value" is not assignable to "StringValue"
-             "Value" is not assignable to "StringValue"
+       Type "dict[str, Deferred]" is not assignable to type "(Value) -> Value"
-         Type parameter "_KT@Mapping" is invariant, but "str" is not the same as "str | None"
+         Type parameter "_KT@Mapping" is invariant, but "str" is not the same as "str | None" (reportArgumentType)
-       Type "dict[str, Deferred]" is not assignable to type "(Value) -> Value" (reportArgumentType)
+       Type "dict[str, Deferred]" is not assignable to type "(Value) -> Value"
-         Type parameter "_KT@Mapping" is invariant, but "str" is not the same as "str | None"
+         Type parameter "_KT@Mapping" is invariant, but "str" is not the same as "str | None" (reportArgumentType)
-       Type "dict[str, Deferred]" is not assignable to type "(Value) -> Value" (reportArgumentType)
+         Type "Value" is not assignable to type "(Value) -> Value"
-         "Value" is not assignable to "Mapping[str | None, Deferred | ((Value) -> Value)]"
+         "Value" is not assignable to "Mapping[str | None, Deferred | ((Value) -> Value)]" (reportArgumentType)
-         Type "Value" is not assignable to type "(Value) -> Value" (reportArgumentType)
+       Type "Value" is not assignable to type "(Value) -> Value"
-       "Value" is not assignable to "Mapping[str | None, Deferred | ((Value) -> Value)]"
+       "Value" is not assignable to "Mapping[str | None, Deferred | ((Value) -> Value)]" (reportArgumentType)
-       Type "Value" is not assignable to type "(Value) -> Value" (reportArgumentType)
-       Type "Value" is not assignable to type "(Value, Value) -> Value"
+       Type "Value" is not assignable to type "(Value) -> Value"
-       Type "Value" is not assignable to type "(Value) -> Value" (reportArgumentType)
+       Type "Value" is not assignable to type "(Value, Value) -> Value" (reportArgumentType)
-       Type "Value" is not assignable to type "(Value, IntegerValue) -> (bool | BooleanValue)"
+       Type "Value" is not assignable to type "(Value) -> (bool | BooleanValue)"
-       Type "Value" is not assignable to type "(Value) -> (bool | BooleanValue)" (reportArgumentType)
+       Type "Value" is not assignable to type "(Value, IntegerValue) -> (bool | BooleanValue)" (reportArgumentType)

bokeh (https://github.com/bokeh/bokeh)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/settings.py:216:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/container.py:294:30 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/model/util.py:207:39 - error: Second argument to "issubclass" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/models/sources.py:694:38 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_figure.py:473:32 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_figure.py:478:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_figure.py:484:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+ /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_stack.py
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_stack.py:44:62 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_stack.py:64:30 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_stack.py:78:62 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/_stack.py:101:30 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/graph.py:143:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/plotting/graph.py:144:34 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/sphinxext/bokeh_palette.py:134:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
- 3547 errors, 294 warnings, 0 informations 
+ 3561 errors, 294 warnings, 0 informations 

core (https://github.com/home-assistant/core)
+   /tmp/mypy_primer/projects/core/homeassistant/helpers/template.py:2324:30 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
- 22487 errors, 323 warnings, 0 informations 
+ 22488 errors, 323 warnings, 0 informations 

mitmproxy (https://github.com/mitmproxy/mitmproxy)
-         "None" is not assignable to "WebSocketMessage"
+         "None" is not assignable to "UDPMessage"
-         "None" is not assignable to "UDPMessage" (reportArgumentType)
+         "None" is not assignable to "WebSocketMessage" (reportArgumentType)
-         "None" is not assignable to "WebSocketMessage"
+         "None" is not assignable to "UDPMessage"
-         "None" is not assignable to "UDPMessage" (reportArgumentType)
+         "None" is not assignable to "WebSocketMessage" (reportArgumentType)
-         "None" is not assignable to "WebSocketMessage"
+         "None" is not assignable to "UDPMessage"
-         "None" is not assignable to "UDPMessage" (reportArgumentType)
+         "None" is not assignable to "WebSocketMessage" (reportArgumentType)

zulip (https://github.com/zulip/zulip)
+   /tmp/mypy_primer/projects/zulip/zerver/lib/data_types.py:188:32 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
- 4864 errors, 461 warnings, 0 informations 
+ 4865 errors, 461 warnings, 0 informations 

xarray (https://github.com/pydata/xarray)
+   /tmp/mypy_primer/projects/xarray/xarray/core/dataarray.py:1442:33 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/core/dataset.py:2771:35 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/core/dataset.py:8639:34 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/core/dataset.py:8768:34 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+ /tmp/mypy_primer/projects/xarray/xarray/core/datatree_render.py
+   /tmp/mypy_primer/projects/xarray/xarray/core/datatree_render.py:252:37 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/core/indexes.py:533:27 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/core/utils.py:258:30 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/namedarray/core.py:813:31 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/plot/utils.py:129:25 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/plot/utils.py:940:25 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
+   /tmp/mypy_primer/projects/xarray/xarray/tests/test_units.py:166:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
- 2431 errors, 90 warnings, 0 informations 
+ 2442 errors, 90 warnings, 0 informations 

artigraph (https://github.com/artigraph/artigraph)
+   /tmp/mypy_primer/projects/artigraph/src/arti/internal/type_hints.py:148:26 - error: Second argument to "isinstance" must be a class or tuple of classes
+     Generic type with type arguments not allowed for instance or class checks (reportArgumentType)
- 155 errors, 4 warnings, 0 informations 
+ 156 errors, 4 warnings, 0 informations 

@erictraut erictraut closed this Nov 7, 2024
@erictraut erictraut deleted the issue-9415 branch November 7, 2024 23:37
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