Alex Waygood <alex.wayg...@gmail.com> 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"}})
```

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.

----------
nosy: +AlexWaygood
type: behavior -> enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45359>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to