[issue44524] __name__ attribute in typing module

Bas van Beek report at bugs.python.org
Thu Aug 5 06:30:29 EDT 2021


Bas van Beek <bas.vanbeek at hotmail.com> added the comment:

I do agree that it's nice to have a `__name__` for special forms, as they do very much behave like types even though they're strictly speaking not distinct classes.

Whether we should have this feature is a distinct "problem" from its `__name__` being `None` (as can happen in its the current implementation), 
the latter of which is actively breaking tests over in https://github.com/numpy/numpy/pull/19612.
I don't recall ever seeing a non-string name before, so I'd argue that this is a bug.

It seems to be easy to fix though (see below for a `Union` example), so if there are objections I'd like to submit a PR.

```
-    return _UnionGenericAlias(self, parameters)
+    return _UnionGenericAlias(self, parameters, name="Union")
```

----------

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


More information about the Python-bugs-list mailing list