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 AlexWaygood
Recipients AlexWaygood, JacobHayes, asvetlov
Date 2021-12-10.08:54:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639126442.18.0.994276022795.issue45359@roundup.psfhosted.org>
In-reply-to
Content
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"}})
```

By using a string as the annotation, we give mypy the specificity it needs, but the expression will never need to be resolved at runtime.
History
Date User Action Args
2021-12-10 08:54:02AlexWaygoodsetrecipients: + AlexWaygood, asvetlov, JacobHayes
2021-12-10 08:54:02AlexWaygoodsetmessageid: <1639126442.18.0.994276022795.issue45359@roundup.psfhosted.org>
2021-12-10 08:54:02AlexWaygoodlinkissue45359 messages
2021-12-10 08:54:02AlexWaygoodcreate