Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pydoc rendersfrom builtins.type note, even if it is incorrect #97959

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@sobolevn

Description

@sobolevn

While working on#97958 I've noticed that there's something strange withhelp() andclassmethods.

Take a look at this example:

importpydocclassMy:@classmethoddef__init_subclass__(cls,*args,**kwargs):pass@classmethoddefcustom(cls):passprint(pydoc.plain(pydoc.render_doc(My)))

It prints:

Python Library Documentation: class My in module __main__class My(builtins.object) |  Class methods defined here: | |  __init_subclass__(*args, **kwargs) from builtins.type |      This method is called when a class is subclassed. | |      The default implementation does nothing. It may be |      overridden to extend subclasses. | |  custom() from builtins.type | |  ---------------------------------------------------------------------- |  Data descriptors defined here: | |  __dict__ |      dictionary for instance variables (if defined) | |  __weakref__ |      list of weak references to the object (if defined)

Take a look at these two entries:

  1. __init_subclass__(*args, **kwargs) from builtins.type
  2. custom() from builtins.type

Whiletype has__init_subclass__, there's notype.custom. But,help says that there is!

>>>type.__init_subclass__<built-inmethod__init_subclass__oftypeobjectat0x10a50c360>>>>type.customTraceback (mostrecentcalllast):File"<stdin>",line1,in<module>AttributeError:typeobject'type'hasnoattribute'custom'

I think that it is incorrect and can lead to confusion.
Instead it should be:

 |  __init_subclass__(*args, **kwargs) from builtins.type |      This method is called when a class is subclassed. | |      The default implementation does nothing. It may be |      overridden to extend subclasses. | |  custom()

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp