8000 gh-119180: Fix annotations lookup on classes with custom metaclasses by JelleZijlstra · Pull Request #120719 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119180: Fix annotations lookup on classes with custom metaclasses #120719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
JelleZijlstra committed Jun 21, 2024
commit b845c0e1fc150232c826090e7665636116e94efb
1 change: 1 addition & 0 deletions Lib/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
# Recurse to methods, properties, and nested classes.
if ((inspect.isroutine(val) or inspect.isclass(val) or
isinstance(val, property)) and
valname != '__annotations__' and
self._from_module(module, val)):
valname = '%s.%s' % (name, valname)
self._find(tests, val, valname, module, source_lines,
Expand Down
4 changes: 3 additions & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ def visiblename(name, all=None, obj=None):
'__date__', '__doc__', '__file__', '__spec__',
'__loader__', '__module__', '__name__', '__package__',
'__path__', '__qualname__', '__slots__', '__version__',
'__static_attributes__', '__firstlineno__'}:
'__static_attributes__', '__firstlineno__', '__annotations__'}:
return 0
if name == '__annotate__' and getattr(obj, name, None) is None:
return False
# Private names are hidden, but special names are displayed.
if name.startswith('__') and name.endswith('__'): return 1
# Namedtuples have public fields and methods with a single leading underscore
Expand Down
Loading
0