Skip to content

inspect module docs omits many functions #62172

Description

@s7v7nislandsgmailcom
BPO 17972
Nosy @terryjreedy, @bitdancer, @ericsnowcurrently, @kernc, @ChillarAnand, @Carreau, @csabella, @lysnikolaou, @PaulRudin, @tirkarthi
PRs
  • bpo-17972: Document findsource in inspect.rst #6992
  • 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 2013-05-14.03:11:08.831>
    labels = ['easy', 'type-bug', '3.7', 'docs']
    title = 'inspect module docs omits many functions'
    updated_at = <Date 2019-02-01.23:37:17.171>
    user = 'https://bugs.python.org/s7v7nislandsgmailcom'

    bugs.python.org fields:

    activity = <Date 2019-02-01.23:37:17.171>
    actor = 'kernc'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2013-05-14.03:11:08.831>
    creator = 's7v7nislands@gmail.com'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 17972
    keywords = ['patch', 'easy']
    message_count = 12.0
    messages = ['189193', '189308', '189337', '309455', '309466', '309496', '309507', '309915', '317141', '329837', '329838', '332167']
    nosy_count = 12.0
    nosy_names = ['terry.reedy', 'r.david.murray', 'docs@python', 'eric.snow', 's7v7nislands@gmail.com', 'kernc', 'chillaranand', 'mbussonn', 'cheryl.sabella', 'lys.nikolaou', 'PaulRudin', 'xtreak']
    pr_nums = ['6992']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue17972'
    versions = ['Python 3.7']

    Linked PRs

    Activity

    1. s7v7nislandsgmailcom commented on May 14, 2013

      s7v7nislandsgmailcommannequin
      MannequinAuthor

      the inspect module leak docs.
      all these functions have no doc.
      getlineno
      getabsfile
      getblock
      formatannotation
      walktree
      findsource
      indentsize
      getargs
      formatannotationrelativeto
      classify_class_attrs

    2. added
      type-feature
      on May 14, 2013
    3. added
      docs
      on May 14, 2013
    4. terryjreedy commented on May 15, 2013

      @terryjreedy
      Member

      I do not know what you mean by 'leak docs' so I changed the title to something that makes more sense. It is possible that these functions are considered private to the module, but then their names should be preceded by '_', or else there should be an '__all__' list that omits them. So the omission may be a mistake. I do not know.

    5. changed the title [-]inspect module leak docs[/-] [+]inspect module docs omits many functions[/+] on May 15, 2013
    6. s7v7nislandsgmailcom commented on May 16, 2013

      s7v7nislandsgmailcommannequin
      MannequinAuthor

      when I read the memory_profiler source code, I find it using inspect.getblock(). so I check the doc, but can't find the function's doc.

      these functions are found not in doc. I want to known which function should in doc or not? in inspect module has no __all__ variable.

      sorry for poor english!

    7. added
      3.7 (EOL)
      type-bug
      and removed
      type-feature
      on Dec 16, 2017
    8. PaulRudin commented on Jan 4, 2018

      PaulRudinmannequin
      Mannequin

      If some are to be considered private then the questions are: which ones and how to fix. Presumably renaming to start with "_" might break existing code, so maybe adding an __all__, and just including the public objects is better? That could break code existing relying on * imports I suppose. Deprecation is another possibility, although feels a little odd for things never documented.

      formatannotation and formatannotationrelativeto look like a helper functions for formatargspec and are probably not intended as part of the public interface.

      Similarly walktree looks like a helper for getclasstree (and its docstring describes it as such).

    9. bitdancer commented on Jan 4, 2018

      @bitdancer
      Member

      I think adding an __all__ in 3.7 would be reasonable. You are right that we can't simply rename them for backward compatibility reasons. We could rename them, and leave a stub function (that calls the renamed function) but issues a deprecation warning. We've done that for other old internal APIs that we wanted to mark as private elsewhere in the stdlib. The question is, is it worth the trouble to do it?

    10. PaulRudin commented on Jan 5, 2018

      PaulRudinmannequin
      Mannequin

      Documenting and generating a deprecation warning also makes them part of the documented public api. Or are you suggesting just the warning without including in the documentation?

      Incidentally, there are also the classes BlockFinder and EndOfBlock, which are helpers for getblock and presumably not intended for public consumption.

    11. bitdancer commented on Jan 5, 2018

      @bitdancer
      Member

      Just warnings, no docs. We've done this before for other helper functions, but it is always a judgement call whether it is worth the churn. I defer to those people who have actually done work on the module for the answer to that question.

    12. PaulRudin commented on Jan 14, 2018

      PaulRudinmannequin
      Mannequin

      Although formatannotation is undocumented, its actually documented as a default value for one of the parameters of formatargspec, so it does form part of the module's public interface. However formatargspec is deprecated, so it's still OK to deprecate formatannotation.

      formatannotation is also used as a helper within Parameter, which isn't deprecated, but the public interface or docs of Parameter don't mention formatannotation, so using _formatannotation instead is fine.

      Since I've looked through this and, as far as I can tell, nobody is working on it, I'll make the changes and make a PR.

    13. Carreau commented on May 19, 2018

      Carreaumannequin
      Mannequin

      Just came across the same issue.

      It think that the exact behavior may depend on functions. IT is also unclear when to use what sometime.

      For example, getsource seem to be preferable to findsource, getsource cannot be use to get the source of wrapping function as it follows __wrapped__.

    14. lysnikolaou commented on Nov 13, 2018

      @lysnikolaou
      Member

      I think this issue should be discussed once more. I am not sure it's worth defining __all__, but then we would have to include them in the docs. If you think __all__ should be defined instead, then I could go through the trouble of doing so. Could a core developer maybe offer their opinion here?

    15. lysnikolaou commented on Nov 13, 2018

      @lysnikolaou
      Member

      ...but then we would have to include them in the docs... should be *but then we would have to include all the public functions in the docs*.

    16. csabella commented on Dec 19, 2018

      @csabella
      Contributor

      bpo-12317 discusses inspect.getabsfile()

    17. transferred this issue fromon Apr 10, 2022
    18. added a commit that references this issue on Jul 12, 2026
    19. added 3 commits that reference this issue on Jul 24, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      docseasytype-bug

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions