Skip to content

gh-152692: Fix annotationlib.type_repr() for bound built-in methods#152693

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-typerepr-builtin-module
Open

gh-152692: Fix annotationlib.type_repr() for bound built-in methods#152693
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-typerepr-builtin-module

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

type_repr() returned a string naming a nonexistent module None -- e.g.
type_repr([].append) == 'None.list.append' -- for bound built-in methods,
whose __module__ is None.

Return the qualified name when __module__ is None, as already done for the
"builtins" module. This also covers C-accelerator functions such as
random.random. annotations_to_string and
get_annotations(format=Format.STRING) are fixed transitively when an
annotation value is such a method.

…hods

type_repr() returned a string naming a nonexistent module None -- e.g.
type_repr([].append) == 'None.list.append' -- for bound built-in methods,
whose __module__ is None.

Return the qualified name when __module__ is None, as already done for the
"builtins" module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants