Skip to content

Commit

Permalink
Fix matches_qualname() not to stop at first matching name
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr committed Oct 29, 2024
1 parent ef8f161 commit c18ce26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beniget/beniget.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def matches_qualname(*, heads, locals, imports, modnames, expr, qnames):
return True
else:
# localy defined name, but module name doesn't match
break
continue

elif isinstance(expr, ast.Attribute):
for n in qnames:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,25 @@ def test_stubs_typealias_typing_pyi(self):
filename='typing.pyi',
)

def test_stubs_conditionnal_typealias(self):
code = '''
import sys
if sys.version_info < (3,10):
TypeAlias = object
else:
from typing import TypeAlias
LiteralValue: TypeAlias = list[LiteralValue]|object
'''
self.checkChains(
code,
['sys -> (sys -> (.version_info -> (<Compare> -> ())))',
'TypeAlias -> (TypeAlias -> ())',
'TypeAlias -> (TypeAlias -> ())',
'LiteralValue -> (LiteralValue -> (<Subscript> -> (<BinOp> -> ())))',
],
filename='test.pyi',
)

def test_stubs_class_decorators(self):
code = '''
@dataclass_transform
Expand Down

0 comments on commit c18ce26

Please sign in to comment.