Skip to content
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

Add example for inspect module doc #60447

Closed
abalkin opened this issue Oct 15, 2012 · 6 comments
Closed

Add example for inspect module doc #60447

abalkin opened this issue Oct 15, 2012 · 6 comments
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@abalkin
Copy link
Member

abalkin commented Oct 15, 2012

BPO 16243
Nosy @abalkin, @vstinner, @asvetlov, @berkerpeksag
Files
  • inspect-formatargspec-example.patch
  • 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 = <Date 2012-10-26.21:31:00.081>
    created_at = <Date 2012-10-15.23:19:45.444>
    labels = ['type-feature', 'docs']
    title = 'Add example for inspect module doc'
    updated_at = <Date 2012-10-26.21:31:00.063>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2012-10-26.21:31:00.063>
    actor = 'asvetlov'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2012-10-26.21:31:00.081>
    closer = 'asvetlov'
    components = ['Documentation']
    creation = <Date 2012-10-15.23:19:45.444>
    creator = 'belopolsky'
    dependencies = []
    files = ['27718']
    hgrepos = []
    issue_num = 16243
    keywords = ['patch']
    message_count = 6.0
    messages = ['173003', '173004', '173010', '173802', '173892', '173893']
    nosy_count = 6.0
    nosy_names = ['belopolsky', 'vstinner', 'asvetlov', 'docs@python', 'python-dev', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue16243'
    versions = ['Python 3.4']

    @abalkin
    Copy link
    Member Author

    abalkin commented Oct 15, 2012

    In Python 3.3.0 and 3.2.3:

    >>> from inspect import *
    >>> def f(a,b):pass
    ...
    >>> formatargspec(getargspec(f))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/inspect.py", line 905, in formatargspec
        spec = formatargandannotation(arg)
      File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/inspect.py", line 898, in formatargandannotation
        if arg in annotations:
    TypeError: unhashable type: 'list'

    No such error in 2.7.1:

    >>> formatargspec(getargspec(f))
    '((a, b), None, None, None)'

    @abalkin abalkin added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Oct 15, 2012
    @vstinner
    Copy link
    Member

    It looks like a typo in your code. You should use instead:
    formatargspec(*getargspec(f))

    Or better:
    formatargspec(*getfullargspec(f))

    Try with:
    def f(a: int, b: float): pass

    @abalkin
    Copy link
    Member Author

    abalkin commented Oct 16, 2012

    My bad, but I think documentation can be improved by adding an example.

    @abalkin abalkin added docs Documentation in the Doc dir and removed stdlib Python modules in the Lib dir labels Oct 16, 2012
    @abalkin abalkin added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Oct 16, 2012
    @terryjreedy terryjreedy changed the title Regression in inspect module Add example for inspect module doc Oct 19, 2012
    @berkerpeksag
    Copy link
    Member

    Here's a patch that adds an example of using inspect.formatargspec.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 26, 2012

    New changeset 9d3b616fc702 by Andrew Svetlov in branch '3.3':
    Issue bpo-16243: add example for inspect.formatargspec
    http://hg.python.org/cpython/rev/9d3b616fc702

    New changeset a0337031a6b7 by Andrew Svetlov in branch 'default':
    Merge issue bpo-16243: add example for inspect.formatargspec
    http://hg.python.org/cpython/rev/a0337031a6b7

    @asvetlov
    Copy link
    Contributor

    Thanks, Berker.
    I feel the patch is good enough to close the issue.
    If anybody want to add some value please reopen.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants