[issue34963] String representation for types created with typing.NewType(…) are opaque and unappealing
Alexander Böhn
report at bugs.python.org
Fri Oct 12 16:10:53 EDT 2018
Alexander Böhn <fish2000 at gmail.com> added the comment:
The proposed solution in the PR replaces the identity-function return value of `NewType(…)` with a callable class instance that adds an explicit `__repr__` function – which that function cobbles together the string representations of the supplied type and the new types’ name into a sensible and stylistically consistent “repr” output.
In this capacity the `__name__` vs. `__qualname__` consideration would appear to be an implementation detail – in this case, calculating a `__qualname__` value, á la PEP-3155, doesn’t seem to be possible nor advantageous, in this specific case.
On the other hand, adding `__module__` seems like it’d be a win – although I am wary about introducing a dependency on a function that starts with an underscore. How reliable and/or portable is `sys._getframe()` ?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34963>
_______________________________________
More information about the Python-bugs-list
mailing list