Message408211
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 :) |
|
Date |
User |
Action |
Args |
2021-12-10 14:59:57 | JacobHayes | set | recipients:
+ JacobHayes, asvetlov, AlexWaygood |
2021-12-10 14:59:57 | JacobHayes | set | messageid: <1639148397.7.0.317122018787.issue45359@roundup.psfhosted.org> |
2021-12-10 14:59:57 | JacobHayes | link | issue45359 messages |
2021-12-10 14:59:57 | JacobHayes | create | |
|