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

stubgen: do not include mypy generated symbols #18137

Merged
merged 2 commits into from
Nov 14, 2024
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
2 changes: 2 additions & 0 deletions mypy/stubutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ def is_not_in_all(self, name: str) -> bool:
return False

def is_private_name(self, name: str, fullname: str | None = None) -> bool:
if "__mypy-" in name:
return True # Never include mypy generated symbols
if self._include_private:
return False
if fullname in self.EXTRA_EXPORTED:
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/stubgen.test
Original file line number Diff line number Diff line change
Expand Up @@ -4508,3 +4508,21 @@ class C3[T3 = int]: ...
class C4[T4: int | float = int](list[T4]): ...

def f5[T5 = int]() -> None: ...

[case testIgnoreMypyGeneratedMethods_semanal]
# flags: --include-private --python-version=3.13
from typing_extensions import dataclass_transform

# TODO: preserve dataclass_transform decorator
@dataclass_transform()
class DCMeta(type): ...
class DC(metaclass=DCMeta):
x: str

[out]
class DCMeta(type): ...

class DC(metaclass=DCMeta):
x: str
def __init__(self, x) -> None: ...
def __replace__(self, *, x) -> None: ...
Loading