__qualname__ and nested class naming fixes #1171
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few fixes related to how we set
__qualname__
and how we show the type name in function signatures (fixes #1166).__qualname__
isn't supposed to have the module name at the beginning, but we've been putting it there. This removes it, while keeping theNested.Class
name chaining.print
__module__.__qualname__
rather thantype->tp_name
; the latter doesn't work properly for nested classes, so we would getmodule.B
rather thanmodule.A.B
for a classB
with parentA
. This also unifies the Python 3 and PyPy code. Fixes Incorrect type names in docstrings for nested types #1166.This now sets a
__qualname__
attribute on the type (as would happen internally to Python 3.3+) for Python <3.3 and PyPy. While not particularly important to have in earlier Python versions, it's useful for us to be able to extracted the nested name for function signatures (which is why__qualname__
was invented in the first place).Added tests for the above.