This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JacobHayes
Recipients AlexWaygood, JacobHayes, asvetlov
Date 2021-12-10.14:59:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639148397.7.0.317122018787.issue45359@roundup.psfhosted.org>
In-reply-to
Content
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
    TopologicalSorter.__class_getitem__ = classmethod(GenericAlias)  # type: ignore
```

Certainly a bit hacky, but aside from no-op on >=3.11 and satisfying mypy, it supports runtime type inspection via `get_type_hints` before 3.11 (which otherwise still errors for stringized versions). The stringized versions are probably a bit simpler/safer for most folks though :)
History
Date User Action Args
2021-12-10 14:59:57JacobHayessetrecipients: + JacobHayes, asvetlov, AlexWaygood
2021-12-10 14:59:57JacobHayessetmessageid: <1639148397.7.0.317122018787.issue45359@roundup.psfhosted.org>
2021-12-10 14:59:57JacobHayeslinkissue45359 messages
2021-12-10 14:59:57JacobHayescreate