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

Confusing error message when constructing invalid inspect.Parameters #77378

Closed
anntzer mannequin opened this issue Apr 1, 2018 · 17 comments
Closed

Confusing error message when constructing invalid inspect.Parameters #77378

anntzer mannequin opened this issue Apr 1, 2018 · 17 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Apr 1, 2018

BPO 33197
Nosy @serhiy-storchaka, @1st1, @corona10, @nitishch
PRs
  • bpo-33197: Update error message of invalid inspect.Parameters #6636
  • [3.7] bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) #7204
  • [3.6] bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) #7205
  • bpo-33197: Add description property for _ParameterKind #7206
  • bpo-33197: Add versionadded tag to the documentation of ParameterKind #7536
  • 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 2018-06-08.16:08:08.034>
    created_at = <Date 2018-04-01.07:14:32.079>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'Confusing error message when constructing invalid inspect.Parameters'
    updated_at = <Date 2018-06-08.16:08:08.033>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2018-06-08.16:08:08.033>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-06-08.16:08:08.034>
    closer = 'yselivanov'
    components = ['Library (Lib)']
    creation = <Date 2018-04-01.07:14:32.079>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33197
    keywords = ['patch']
    message_count = 17.0
    messages = ['314764', '314798', '314799', '315900', '317289', '317995', '318041', '318046', '318052', '319006', '319014', '319015', '319060', '319069', '319081', '319083', '319084']
    nosy_count = 4.0
    nosy_names = ['serhiy.storchaka', 'yselivanov', 'corona10', 'nitishch']
    pr_nums = ['6636', '7204', '7205', '7206', '7536']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33197'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented Apr 1, 2018

    Python 3.6.4

    In [15]: inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD, default=42)
    \---------------------------------------------------------------------------
    
        ValueError                                Traceback (most recent call last)
        <ipython-input-15-7ed8c4fd15f3> in <module>()
        ----> 1 inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD, default=42)
    /usr/lib/python3.6/inspect.py in __init__(self, name, kind, default, annotation)
    2442             if kind in (_VAR_POSITIONAL, _VAR_KEYWORD):
    2443                 msg = '{} parameters cannot have default values'.format(kind)
    -> 2444                 raise ValueError(msg)
    2445         self._default = default
    2446         self._annotation = annotation
    
    ValueError: 4 parameters cannot have default values
    

    Note the "interesting" error message that starts with "4 parameters ..." (yes, I guess that inspect.Parameter == 4 internally...).

    Probably just a matter of making the error f'{kind.name} parameters ...'.

    @anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Apr 1, 2018
    @nitishch
    Copy link
    Mannequin

    nitishch mannequin commented Apr 2, 2018

    @antony Lee since you know the fix, do you want to submit a PR?

    @nitishch
    Copy link
    Mannequin

    nitishch mannequin commented Apr 2, 2018

    Also, _ParameterKind class has a __str__ method. So, I guess it's better to use "{!s}" in the format string instead of using kind.name.

    @corona10
    Copy link
    Member

    @nitish

    I will take a look this issue.
    I agree with to use "{!s}" in the format string

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error labels Apr 29, 2018
    @corona10
    Copy link
    Member

    Can I get a code review for PR 6636?

    @corona10
    Copy link
    Member

    PR 6636 is ready to be merged :)

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset a9cab43 by Yury Selivanov (Dong-hee Na) in branch 'master':
    bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636)
    a9cab43

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset cb055bc by Yury Selivanov (Miss Islington (bot)) in branch '3.7':
    bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) (GH-7204)
    cb055bc

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset 5e9e9db by Yury Selivanov (Miss Islington (bot)) in branch '3.6':
    bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) (bpo-7205)
    5e9e9db

    @corona10
    Copy link
    Member

    corona10 commented Jun 8, 2018

    @yselivanov

    Please take a look PR 7206 :)

    @1st1
    Copy link
    Member

    1st1 commented Jun 8, 2018

    New changeset 4aa3006 by Yury Selivanov (Dong-hee Na) in branch 'master':
    bpo-33197: Add description property for _ParameterKind. (GH-7206)
    4aa3006

    @1st1
    Copy link
    Member

    1st1 commented Jun 8, 2018

    Thanks!

    @1st1 1st1 closed this as completed Jun 8, 2018
    @1st1
    Copy link
    Member

    1st1 commented Jun 8, 2018

    We forgot to add "versionadded: 3.8" tag to the documentation of ParameterKind.description. Dong-hee Na, could you please make a PR to add it?

    @1st1 1st1 reopened this Jun 8, 2018
    @corona10
    Copy link
    Member

    corona10 commented Jun 8, 2018

    Sure, I will send a PR soon.

    @corona10
    Copy link
    Member

    corona10 commented Jun 8, 2018

    @yselivanov

    Please take a look PR 7536 :) Thanks!

    @1st1
    Copy link
    Member

    1st1 commented Jun 8, 2018

    @yselivanov
    Please take a look PR 7536 :) Thanks!

    Please stop posting comments like this frequently. They are highly distractive.

    @1st1
    Copy link
    Member

    1st1 commented Jun 8, 2018

    New changeset 4f54867 by Yury Selivanov (Dong-hee Na) in branch 'master':
    bpo-33197: Add versionadded tag to the documentation of ParameterKind (GH-7536)
    4f54867

    @1st1 1st1 closed this as completed Jun 8, 2018
    @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
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants