File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Fixed
11+
12+ - Fixed type of default parameter for ` EntityComponents.get ` .
13+
1014## [ 5.2.0] - 2024-07-22
1115
1216### Changed
Original file line number Diff line number Diff line change @@ -529,12 +529,17 @@ def __ior__(
529529 self .update (value )
530530 return self
531531
532- def get (self , __key : ComponentKey [T ], __default : T | None = None ) -> T | None :
532+ @overload
533+ def get (self , __key : ComponentKey [T ]) -> T | None : ...
534+ @overload
535+ def get (self , __key : ComponentKey [T ], __default : _T1 ) -> T | _T1 : ...
536+
537+ def get (self , __key : ComponentKey [T ], __default : _T1 | None = None ) -> T | _T1 :
533538 """Return a component, returns None or a default value when the component is missing."""
534539 try :
535540 return self [__key ]
536541 except KeyError :
537- return __default
542+ return __default # type: ignore[return-value] # https://github.com/python/mypy/issues/3737
538543
539544 def setdefault (self , __key : ComponentKey [T ], __default : T ) -> T : # type: ignore[override]
540545 """Assign a default value if a component is missing, then returns the current value."""
You can’t perform that action at this time.
0 commit comments