Skip to content
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

Fix some name-mangling edge cases #52

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion stubdefaulter.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ def gather_funcs(
return
for child_name, child_node in node.child_nodes.items():
if child_name.startswith("__") and not child_name.endswith("__"):
maybe_mangled_child_name = f"_{name}{child_name}"
unmangled_parent_name = fullname.split(".")[-1]
maybe_mangled_child_name = (
f"_{unmangled_parent_name.lstrip('_')}{child_name}"
)
else:
maybe_mangled_child_name = child_name
yield from gather_funcs(
Expand Down
10 changes: 10 additions & 0 deletions test_stubdefaulter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def method(self, a=False):
pass
async def async_method(self, b=3.14):
pass
class __Mangled1:
class __Mangled2:
def __mangled(self, x=True):
pass

def overloaded(x=False):
return 1 if x else "1"
Expand Down Expand Up @@ -84,6 +88,9 @@ class NestedKlass1:
class NestedKlass2:
def method(self, a: bool = ...) -> None: ...
async def async_method(self, b: float = ...) -> None: ...
class __Mangled1:
class __Mangled2:
def __mangled(self, x: bool = ...) -> None: ...

@overload
def overloaded(x: Literal[False] = ...) -> str: ...
Expand Down Expand Up @@ -124,6 +131,9 @@ class NestedKlass1:
class NestedKlass2:
def method(self, a: bool = False) -> None: ...
async def async_method(self, b: float = 3.14) -> None: ...
class __Mangled1:
class __Mangled2:
def __mangled(self, x: bool = True) -> None: ...

@overload
def overloaded(x: Literal[False] = False) -> str: ...
Expand Down