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
>>> List(2*x for x in range(3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tmk/.conda/envs/palbolts/lib/python3.9/typing.py", line 675, in __call__
raise TypeError(f"Type {self._name} cannot be instantiated; "
TypeError: Type List cannot be instantiated; use list() instead
But with PEP 585, there is no real reason to keep builtins.list distinct from typing.List, right? The CamelCase aliases in the typing module could just stay there indefinitely for people who want their classes to be in CamelCase.
You could maybe argue that this situation would be confusing to newcomers, but code from the era 3.6-3.8 is already littered with typing.List, typing.Dict, etc so it doesn't really make the situation worse.
There was discussion about this #367 where it was concluded that List[int]() should not be allowed, but that point is now kind of moot because since PEP 585, list[int]() is already allowed, so I don't see a good reason why List[int]() would be worse.
The text was updated successfully, but these errors were encountered:
I'd rather not do this. The point of typing.py isn't to help "people who want their classes to be in CamelCase", it's to provide helpers for type annotating your code. The camel case aliases are still there for compatibility but should eventually be removed.
The recent proposal in python-ideas to rename classes in the standard library to have CamelCase names, reminded me that
list
,dict
,tuple
,set
,frozenset
already have CamelCase aliases in thetyping
module. However, they can't be used to instantiate anything:But with PEP 585, there is no real reason to keep
builtins.list
distinct fromtyping.List
, right? The CamelCase aliases in thetyping
module could just stay there indefinitely for people who want their classes to be in CamelCase.You could maybe argue that this situation would be confusing to newcomers, but code from the era 3.6-3.8 is already littered with
typing.List
,typing.Dict
, etc so it doesn't really make the situation worse.There was discussion about this #367 where it was concluded that
List[int]()
should not be allowed, but that point is now kind of moot because since PEP 585,list[int]()
is already allowed, so I don't see a good reason whyList[int]()
would be worse.The text was updated successfully, but these errors were encountered: