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

Be stricter about access to generic vars from class #18100

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Nov 3, 2024

This behaviour was intentionally chosen in #6418

I agree with Ivan's comment there that it's similar to how mypy allows instantiation of type[Abstract] -- but that's a thing that I want to explore disallowing.

Let's see primer!

This behaviour was intentionally chosen in python#6418

I agree with Ivan's comment there that it's similar to how mypy allows
instantiation of `type[Abstract]` -- but that's a thing that I want to
explore disallowing.

Let's see primer
Copy link
Contributor

github-actions bot commented Nov 3, 2024

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

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/_internal/concurrency/services.py:237: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/_internal/concurrency/services.py:270: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/_internal/concurrency/services.py:271: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/_internal/concurrency/services.py:273: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/server/task_queue.py:48: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/server/task_queue.py:52: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/server/task_queue.py:53: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/prefect/server/task_queue.py:58: error: Access to generic instance variables via class is ambiguous  [misc]

altair (https://github.com/vega/altair)
+ altair/utils/schemapi.py:918: error: Access to generic instance variables via class is ambiguous  [misc]
+ tools/schemapi/schemapi.py:916: error: Access to generic instance variables via class is ambiguous  [misc]

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/internal/mappings.py:246: error: Access to generic class variables is ambiguous  [misc]
+ src/arti/storage/__init__.py:90: error: Access to generic class variables is ambiguous  [misc]
+ src/arti/storage/__init__.py:105: error: Access to generic class variables is ambiguous  [misc]
+ src/arti/storage/__init__.py:115: error: Access to generic class variables is ambiguous  [misc]

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/capture.py:911: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/_pytest/capture.py:912: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/_pytest/capture.py:944: error: Access to generic instance variables via class is ambiguous  [misc]
+ src/_pytest/capture.py:945: error: Access to generic instance variables via class is ambiguous  [misc]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/api/dataframe/model.py:262: error: Access to generic instance variables via class is ambiguous  [misc]
- pandera/api/dataframe/model.py:264: error: Unused "type: ignore" comment  [unused-ignore]
- pandera/api/dataframe/model.py:265: error: Unused "type: ignore" comment  [unused-ignore]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/_gc/state.py:87: error: Access to generic instance variables via class is ambiguous  [misc]
+ steam/_gc/state.py:96: error: Access to generic instance variables via class is ambiguous  [misc]
+ steam/ext/commands/converters.py:239: error: Access to generic instance variables via class is ambiguous  [misc]

core (https://github.com/home-assistant/core)
+ homeassistant/components/yeelight/scanner.py:53: error: Access to generic instance variables via class is ambiguous  [misc]
+ homeassistant/components/yeelight/scanner.py:54: error: Access to generic instance variables via class is ambiguous  [misc]
+ homeassistant/components/yeelight/scanner.py:55: error: Access to generic instance variables via class is ambiguous  [misc]

@hauntsaninja
Copy link
Collaborator Author

prefect is self type, altair is self type (singleton), artigraph is runtime typing i'm fine with, pytest is abstract generic class with only concrete subclasses, pandera is also fine, steam is self type, homeassistant is self type

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