Skip to content

Commit

Permalink
stubgen: do not include mypy generated symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed Nov 10, 2024
1 parent 3b00002 commit a7a464f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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 name.startswith("__mypy-"):
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: ...

0 comments on commit a7a464f

Please sign in to comment.