You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type hints for __new__ no longer work when subclassing Dict #15135
from __future__ importannotationsfromtypingimport*classModFrozenSet(FrozenSet[int]):
some_str: strdef__new__(cls, init: Iterable[int], some_str: str) ->ModFrozenSet:
_=some_str# used by '__init__()'returnfrozenset.__new__(cls, init)
def__init__(self, init: Iterable[int], some_str: str):
_=init# used by '__new__()'self.some_str=some_str# Empirical test to show that this works in practice:deftest_motivation_empirically() ->None:
created=ModFrozenSet([1, 2, 3], "hello")
asserttype(created) isModFrozenSetassertisinstance(created, frozenset)
assertsorted(created) == [1, 2, 3]
assertcreated.some_str=="hello"
Activity
finite-state-machine commentedon Aug 5, 2023
This applies to (at least)
FrozenSetas well.mypy-play.net: minimal reproduction case
As motivation, consider [mypy-play.net]:
finite-state-machine commentedon Oct 30, 2023
This appears to be fixed on the master branch, but not in 1.6.1 (per the first gist in my reply above).