Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
Callingtyping.List[''] produces an unexpectedIndexError.
>>>importtyping>>>typing.List['']Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.11/typing.py",line362,ininnerreturncached(*args,**kwds)^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1575,in__getitem__params=tuple(_type_check(p,msg)forpinparams)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1575,in<genexpr>params=tuple(_type_check(p,msg)forpinparams)^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line186,in_type_checkarg=_type_convert(arg,module=module,allow_special_forms=allow_special_forms)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line164,in_type_convertreturnForwardRef(arg,module=module,is_class=allow_special_forms)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line859,in__init__ifarg[0]=='*':~~~^^^IndexError:stringindexoutofrange
The construct is invalid, but I'd expect a more friendly error, something similar to
>>>typing.Dict[1]Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.11/typing.py",line365,ininnerreturnfunc(*args,**kwds)^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1576,in__getitem___check_generic(self,params,self._nparams)File"/usr/lib/python3.11/typing.py",line293,in_check_genericraiseTypeError(f"Too{'many'ifalen>elenelse'few'} arguments for{cls};"TypeError:Toofewargumentsfortyping.Dict;actual1,expected2
CPython versions tested on:
3.11
Operating systems tested on:
Linux