Skip to content

Commit b93d4b6

Browse files
committed
Update __new__ method to use Self type for improved type hinting
1 parent 3c1676d commit b93d4b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

traitlets/traitlets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ def class_init(self, cls: type[HasTraits], name: str | None) -> None:
12901290
class HasDescriptors(metaclass=MetaHasDescriptors):
12911291
"""The base class for all classes that have descriptors."""
12921292

1293-
def __new__(*args: t.Any, **kwargs: t.Any) -> t.Any:
1293+
def __new__(*args: t.Any, **kwargs: t.Any) -> Self: # type:ignore[misc, type-var]
12941294
# Pass cls as args[0] to allow "cls" as keyword argument
12951295
cls = args[0]
12961296
args = args[1:]
@@ -1303,7 +1303,7 @@ def __new__(*args: t.Any, **kwargs: t.Any) -> t.Any:
13031303
else:
13041304
inst = new_meth(cls, *args, **kwargs)
13051305
inst.setup_instance(*args, **kwargs)
1306-
return inst
1306+
return inst # type:ignore[no-any-return]
13071307

13081308
def setup_instance(*args: t.Any, **kwargs: t.Any) -> None:
13091309
"""

0 commit comments

Comments
 (0)