cpython icon indicating copy to clipboard operation
cpython copied to clipboard

inspect documentation describes module type inaccurately

Open ericsnowcurrently opened this issue 11 years ago • 6 comments

BPO 21760
Nosy @ncoghlan, @ericsnowcurrently, @miss-islington, @furkanonder
PRs
  • python/cpython#19097
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2014-06-14.19:58:13.196>
    labels = ['easy', '3.11', '3.9', '3.10', 'docs']
    title = 'inspect documentation describes module type inaccurately'
    updated_at = <Date 2021-06-21.15:17:15.619>
    user = 'https://github.com/ericsnowcurrently'
    

    bugs.python.org fields:

    activity = <Date 2021-06-21.15:17:15.619>
    actor = 'iritkatriel'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2014-06-14.19:58:13.196>
    creator = 'eric.snow'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 21760
    keywords = ['easy']
    message_count = 5.0
    messages = ['220576', '364831', '366210', '395472', '395475']
    nosy_count = 5.0
    nosy_names = ['ncoghlan', 'docs@python', 'eric.snow', 'miss-islington', 'furkanonder']
    pr_nums = ['19097']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue21760'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']
    

    ericsnowcurrently avatar Jun 14 '14 19:06 ericsnowcurrently

    In the documentation for the inspect module, the module type is described with just 2 of its potential 7 attributes. The language reference[2] and importlib docs[3] both provide an accurate list of module attributes.

    Furthermore, the description for __file__ should be fixed. It should be clear that __file__ reflects the location from which the module was loaded, that location is not necessarily a filename, and the attribute may not exist if the module was not loaded from a specific location (e.g. builtin and frozen modules). The same goes for __cached__

    [1] https://docs.python.org/dev/library/inspect.html#types-and-members [2] https://docs.python.org/3/reference/import.html#import-related-module-attributes [3] https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec

    ericsnowcurrently avatar Jun 14 '14 19:06 ericsnowcurrently

    I sent a PR to fix a __file__ description. https://github.com/python/cpython/pull/19097

    PR has been sent.

    New changeset 878d7e4ee464913438fd59582bbb795e7e0fa387 by Furkan Onder in branch 'main': bpo-21760: fix __file__ description (GH-19097) https://github.com/python/cpython/commit/878d7e4ee464913438fd59582bbb795e7e0fa387

    miss-islington avatar Jun 09 '21 21:06 miss-islington

    I've merged the changes for __file__. Thanks, furkanonder!

    The fixes in the types module remain to be done, though now I see 4 of the relevant attributes instead of 2. (missing: __path__, __file__, __cached__)

    ericsnowcurrently avatar Jun 09 '21 21:06 ericsnowcurrently

    @encukou I believe this ticket is no longer relevant.

    There was a change in https://github.com/python/cpython/pull/98116/files where the module members were removed from https://docs.python.org/dev/library/inspect.html#types-and-members, that this ticket suggested to update.

    There's no longer nothing to update, because we're simply referencing another docs location for the details. I assume that other location is correct and covers all the fields. That was also the assumption in the original report in this ticket:

    The language reference[2] and importlib docs[3] both provide an accurate list of module attributes.

    [2] https://docs.python.org/3/reference/import.html#import-related-module-attributes (it's now linked to this) [3] https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec

    tuukkamustonen avatar Jul 14 '24 09:07 tuukkamustonen

    I agree. Thank you for triaging!

    encukou avatar Jul 18 '24 12:07 encukou

    As https://github.com/python/cpython/issues/65959#issuecomment-1093657481 notes, there are also some missing attributes in the types module docs. However, those can be addressed by gh-64019.

    ericsnowcurrently avatar Jul 18 '24 17:07 ericsnowcurrently