help(list[int]) → TypeError

Paul Bryan pbryan at anode.ca
Fri Dec 4 15:09:21 EST 2020


Thanks, will bring it to the dev list.

On Fri, 2020-12-04 at 07:07 -0800, Julio Di Egidio wrote:
> On Thursday, 3 December 2020 at 19:28:19 UTC+1, Paul Bryan wrote:
> > Is this the correct behavior? 
> > 
> > Python 3.9.0 (default, Oct 7 2020, 23:09:01) 
> > [GCC 10.2.0] on linux 
> > Type "help", "copyright", "credits" or "license" for more
> > information. 
> > > > > help(list[int]) 
> > Traceback (most recent call last): 
> > File "<stdin>", line 1, in <module> 
> > File "/usr/lib/python3.9/_sitebuiltins.py", line 103, in __call__ 
> > return pydoc.help(*args, **kwds) 
> > File "/usr/lib/python3.9/pydoc.py", line 2001, in __call__ 
> > self.help(request) 
> > File "/usr/lib/python3.9/pydoc.py", line 2060, in help 
> > else: doc(request, 'Help on %s:', output=self._output) 
> > File "/usr/lib/python3.9/pydoc.py", line 1779, in doc 
> > pager(render_doc(thing, title, forceload)) 
> > File "/usr/lib/python3.9/pydoc.py", line 1772, in render_doc 
> > return title % desc + '\n\n' + renderer.document(object, name) 
> > File "/usr/lib/python3.9/pydoc.py", line 473, in document 
> > if inspect.isclass(object): return self.docclass(*args) 
> > File "/usr/lib/python3.9/pydoc.py", line 1343, in docclass 
> > (str(cls.__name__) for cls in type.__subclasses__(object) 
> > TypeError: descriptor '__subclasses__' for 'type' objects doesn't
> > apply to a 'types.GenericAlias' object 
> > > > > 
> > 
> > I would have expected the output to the identical to help(list).
> 
> As I get it from the docs (*), these new generics still only work in
> type hinting contexts,
> and I'd rather have expected a more useful error message: but,
> whether that is temporary
> (possibly a plain bug, as in a forgotten case) or, instead, just "how
> things are", I wouldn't
> know... might be a good question for Python developers.
> 
> (*) As in this one for a starter, but see also PEP 585:
> "*In type annotations* you can now use ...", my emphasis.
> <https://docs.python.org/3.9/whatsnew/3.9.html#type-hinting-generics-in-standard-collections
> >
> 
> Julio



More information about the Python-list mailing list