-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
help(list[int]) fails #84476
Comments
>>> help(list[int])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/_sitebuiltins.py", line 103, in __call__
return pydoc.help(*args, **kwds)
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1905, in __call__
self.help(request)
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1964, in help
else: doc(request, 'Help on %s:', output=self._output)
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1684, in doc
pager(render_doc(thing, title, forceload))
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1677, in render_doc
return title % desc + '\n\n' + renderer.document(object, name)
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 381, in document
if inspect.isclass(object): return self.docclass(*args)
File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1251, 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 |
The problem is that isinstance(list[int], type) returns True, but list[int] is not actually an instance of type. >>> isinstance(list[int], type)
True
>>> issubclass(type(list[int]), type)
False
>>> type.__subclasses__(list[int])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: descriptor '__subclasses__' for 'type' objects doesn't apply to a 'types.GenericAlias' object |
Yeah, I think help() or pydoc needs to special-case this. (Didn't your other PR attempt to fix this?) Note that issubclass(list[int].__class__, type) returns True -- the __class__ attribute in this case is taken from __origin__, while type() returns the "true" class. I don't know what to do about __subclasses__ -- I expect we should just let it be this way. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: