@@ -873,10 +873,6 @@ def __getattr__(self, name):
873
873
# -----------------------------------------------------------------------------
874
874
875
875
876
- def module_field (* , kw_only : bool = False , default : Optional [Any ] = ...) -> Any :
877
- ...
878
-
879
-
880
876
# The ModuleBase class is created only to make static analyzers happy
881
877
# mainly pytype and pyright. Some notes:
882
878
# * pyright (correctly) complains that Module itself is not a dataclass, even
@@ -891,12 +887,14 @@ def module_field(*, kw_only: bool = False, default: Optional[Any] = ...) -> Any:
891
887
# * Other attributes are annotated for completeness. Because we are using
892
888
# the `if typing.TYPE_CHECKING` pattern, these annotations are not present
893
889
# at runtime so they don't affect the dataclass behavior.
894
- @dataclass_transform (field_specifiers = ( module_field ,)) # type: ignore[literal-required]
890
+ @dataclass_transform ()
895
891
class ModuleBase :
896
892
if typing .TYPE_CHECKING :
893
+ name : Optional [str ] = None
897
894
scope : Optional [Scope ]
898
895
_state : _ModuleInternalState
899
896
_parent_ref : Union ['Module' , weakref .ReferenceType ['Module' ], None ]
897
+ parent : Union ['Module' , _Sentinel , None ]
900
898
__dataclass_fields__ : Dict [str , dataclasses .Field ]
901
899
902
900
@@ -936,10 +934,6 @@ def __call__(self, x):
936
934
"""
937
935
938
936
if typing .TYPE_CHECKING :
939
- name : Optional [str ] = module_field (kw_only = True , default = None )
940
- parent : Union ['Module' , _Sentinel , None ] = module_field (
941
- kw_only = True , default = None
942
- )
943
937
944
938
def __init__ (self , * args , ** kwargs ):
945
939
# this stub makes sure pytype accepts constructor arguments.
0 commit comments