[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-10 Thread Jacob Hayes
Jacob Hayes added the comment: Thanks for the tips! I've been using this patch in my own code in a early imported `__init__.py`: ``` from graphlib import TopologicalSorter from types import GenericAlias if not hasattr(TopologicalSorter, "__class_getitem__"): # pragma: no cover

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-10 Thread Alex Waygood
Alex Waygood added the comment: Another option for code using Python <3.11, that will work without the `from __future__ import annotations` import, is to do something like this: ``` from graphlib import TopologicalSorter x: 'TopologicalSorter[str]' = TopologicalSorter({"a": {}, "b": {"a"}})

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-09 Thread Andrew Svetlov
Andrew Svetlov added the comment: `if TYPE_CHECKING:` is a good choice, it works fine just now. `from __future__ import annotations` is another alternative. I don't see a reason for REMOVING already existing and correct annotations from typeshed. --

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-09 Thread Jacob Hayes
Jacob Hayes added the comment: Thanks for merging! Should typeshed be updated for <3.11 in the meantime or do you suggest `if TYPE_CHECKING` blocks on user side? Perhaps it's a non-issue if no one else has noticed this. :) -- ___ Python tracker

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-09 Thread Andrew Svetlov
Andrew Svetlov added the comment: The new feature is applied to Python 3.11 only -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: -Python 3.10, Python 3.9 ___ Python tracker

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-12-08 Thread Andrew Svetlov
Andrew Svetlov added the comment: New changeset 3cb9731b7e59b0df9a7a9ab6b7746a669958b693 by Jacob Hayes in branch 'main': bpo-45359: Support TopologicalSorter type subscript (GH-28714) https://github.com/python/cpython/commit/3cb9731b7e59b0df9a7a9ab6b7746a669958b693 -- nosy:

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-11-01 Thread Alex Waygood
Change by Alex Waygood : -- versions: +Python 3.10, Python 3.11 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-10-03 Thread Jacob Hayes
Change by Jacob Hayes : -- keywords: +patch pull_requests: +27064 stage: -> patch review pull_request: https://github.com/python/cpython/pull/28714 ___ Python tracker ___

[issue45359] TopologicalSorter is not Generic at runtime (but is in typeshed)

2021-10-03 Thread Jacob Hayes
New submission from Jacob Hayes : Reproduction: ``` from graphlib import TopologicalSorter TopologicalSorter[str]({"a": {}, "b": {"a"}}) ``` ``` $ mypy /tmp/toposort.py Success: no issues found in 1 source file $ python3 /tmp/toposort.py Traceback (most recent call last): File