Skip to content

Commit 72ada9e

Browse files
committed
remove special enum attrs
1 parent ee0ebb8 commit 72ada9e

File tree

3 files changed

+14
-17
lines changed
  • mypy
  • test-data/pybind11_fixtures
    • expected_stubs_no_docs/pybind11_fixtures
    • expected_stubs_with_docs/pybind11_fixtures

3 files changed

+14
-17
lines changed

mypy/stubgenc.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os.path
1515
from collections.abc import Mapping
1616
from types import FunctionType, ModuleType
17-
from typing import Any, Callable
17+
from typing import Any, Callable, Final
1818

1919
from mypy.fastparse import parse_type_comment
2020
from mypy.moduleinspect import is_c_module
@@ -40,6 +40,17 @@
4040
)
4141
from mypy.util import quote_docstring
4242

43+
SPECIAL_ENUM_ATTRS: Final = {
44+
"_generate_next_value_",
45+
"_member_map_",
46+
"_member_names_",
47+
"_member_type_",
48+
"_unhashable_values_",
49+
"_use_args_",
50+
"_value2member_map_",
51+
"_value_repr_"
52+
}
53+
4354

4455
class ExternalSignatureGenerator(SignatureGenerator):
4556
def __init__(
@@ -862,6 +873,8 @@ def generate_class_stub(
862873
)
863874
elif inspect.isclass(value) and self.is_defined_in_module(value):
864875
self.generate_class_stub(attr, value, types, parent_class=class_info)
876+
elif attr in SPECIAL_ENUM_ATTRS:
877+
pass
865878
else:
866879
attrs.append((attr, value))
867880

test-data/pybind11_fixtures/expected_stubs_no_docs/pybind11_fixtures/demo.pyi

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ class Color(enum.Enum):
99
__new__: ClassVar[Callable] = ...
1010
GREEN = 1
1111
RED = 0
12-
_generate_next_value_: ClassVar[Callable] = ...
13-
_member_map_: ClassVar[dict] = ...
14-
_member_names_: ClassVar[list] = ...
15-
_member_type_: ClassVar[type[object]] = ...
16-
_unhashable_values_: ClassVar[list] = ...
17-
_use_args_: ClassVar[bool] = ...
18-
_value2member_map_: ClassVar[dict] = ...
19-
_value_repr_: ClassVar[None] = ...
2012

2113
class Point:
2214
class AngleUnit:

test-data/pybind11_fixtures/expected_stubs_with_docs/pybind11_fixtures/demo.pyi

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ class Color(enum.Enum):
99
__new__: ClassVar[Callable] = ...
1010
GREEN = 1
1111
RED = 0
12-
_generate_next_value_: ClassVar[Callable] = ...
13-
_member_map_: ClassVar[dict] = ...
14-
_member_names_: ClassVar[list] = ...
15-
_member_type_: ClassVar[type[object]] = ...
16-
_unhashable_values_: ClassVar[list] = ...
17-
_use_args_: ClassVar[bool] = ...
18-
_value2member_map_: ClassVar[dict] = ...
19-
_value_repr_: ClassVar[None] = ...
2012

2113
class Point:
2214
class AngleUnit:

0 commit comments

Comments
 (0)