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

Jacob Hayes report at bugs.python.org
Sun Oct 3 18:18:50 EDT 2021


New submission from Jacob Hayes <jacob.r.hayes at gmail.com>:

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 "/tmp/toposort.py", line 3, in <module>
    TopologicalSorter[str]({"a": {}, "b": {"a"}})
TypeError: 'type' object is not subscriptable
```

I opened the issue here (rather than typeshed) because we'd presumably like to support this at runtime too.

Typeshed link: https://github.com/python/mypy/blob/0a830481980bfc554ded61a3eaaaecde384a21e4/mypy/typeshed/stdlib/graphlib.pyi#L6

----------
components: Library (Lib)
messages: 403115
nosy: JacobHayes
priority: normal
severity: normal
status: open
title: TopologicalSorter is not Generic at runtime (but is in typeshed)
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45359>
_______________________________________


More information about the Python-bugs-list mailing list