Issue 33197: Confusing error message when constructing invalid inspect.Parameters (original) (raw)

Issue33197

Created on 2018-04-01 07:14 by Antony.Lee, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6636 merged corona10,2018-04-29 15:00
PR 7204 merged miss-islington,2018-05-29 15:04
PR 7205 merged miss-islington,2018-05-29 15:05
PR 7206 merged corona10,2018-05-29 15:21
PR 7536 merged corona10,2018-06-08 14:39
Messages (17)
msg314764 - (view) Author: Antony Lee (Antony.Lee) * Date: 2018-04-01 07:14
Python 3.6.4 In [15]: inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD, default=42) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in () ----> 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 ...'.
msg314798 - (view) Author: Nitish (nitishch) * Date: 2018-04-02 05:15
@Antony Lee since you know the fix, do you want to submit a PR?
msg314799 - (view) Author: Nitish (nitishch) * Date: 2018-04-02 05:20
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.
msg315900 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-04-29 14:37
@Nitish I will take a look this issue. I agree with to use "{!s}" in the format string
msg317289 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-05-22 13:59
Can I get a code review for PR 6636?
msg317995 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-05-29 09:20
PR 6636 is ready to be merged :)
msg318041 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-05-29 15:04
New changeset a9cab433bbf02f3a1de59d14dc8f583181ffe2d5 by Yury Selivanov (Dong-hee Na) in branch 'master': bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) https://github.com/python/cpython/commit/a9cab433bbf02f3a1de59d14dc8f583181ffe2d5
msg318046 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-05-29 15:43
New changeset cb055bcc2bbfa5dcc6b0332305918a2118d9ebbc by Yury Selivanov (Miss Islington (bot)) in branch '3.7': bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) (GH-7204) https://github.com/python/cpython/commit/cb055bcc2bbfa5dcc6b0332305918a2118d9ebbc
msg318052 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-05-29 15:59
New changeset 5e9e9db9d9b648d2326e2853dc07377e12498e3f by Yury Selivanov (Miss Islington (bot)) in branch '3.6': bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) (#7205) https://github.com/python/cpython/commit/5e9e9db9d9b648d2326e2853dc07377e12498e3f
msg319006 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-06-08 02:13
@yselivanov Please take a look PR 7206 :)
msg319014 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 03:46
New changeset 4aa3006619392438b0775a2f488bbe9e7a22c468 by Yury Selivanov (Dong-hee Na) in branch 'master': bpo-33197: Add description property for _ParameterKind. (GH-7206) https://github.com/python/cpython/commit/4aa3006619392438b0775a2f488bbe9e7a22c468
msg319015 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 03:46
Thanks!
msg319060 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 13:24
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?
msg319069 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-06-08 14:29
Sure, I will send a PR soon.
msg319081 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-06-08 16:04
@yselivanov Please take a look PR 7536 :) Thanks!
msg319083 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 16:07
> @yselivanov > Please take a look PR 7536 :) Thanks! Please stop posting comments like this frequently. They are highly distractive.
msg319084 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 16:07
New changeset 4f54867e29af93779922ff23df542f2d5df4c4ee by Yury Selivanov (Dong-hee Na) in branch 'master': bpo-33197: Add versionadded tag to the documentation of ParameterKind (GH-7536) https://github.com/python/cpython/commit/4f54867e29af93779922ff23df542f2d5df4c4ee
History
Date User Action Args
2022-04-11 14:58:59 admin set github: 77378
2018-06-08 16:08:08 yselivanov set status: open -> closedstage: patch review -> resolved
2018-06-08 16:07:54 yselivanov set messages: +
2018-06-08 16:07:29 yselivanov set messages: +
2018-06-08 16:04:55 corona10 set messages: +
2018-06-08 14:39:06 corona10 set stage: resolved -> patch reviewpull_requests: + <pull%5Frequest7173>
2018-06-08 14:29:26 corona10 set messages: +
2018-06-08 13:24:01 yselivanov set status: closed -> openmessages: +
2018-06-08 03:46:53 yselivanov set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2018-06-08 03:46:34 yselivanov set messages: +
2018-06-08 02:13:46 corona10 set messages: +
2018-05-29 15:59:29 yselivanov set messages: +
2018-05-29 15:43:57 yselivanov set messages: +
2018-05-29 15:21:45 corona10 set pull_requests: + <pull%5Frequest6841>
2018-05-29 15:05:19 miss-islington set pull_requests: + <pull%5Frequest6840>
2018-05-29 15:04:31 miss-islington set pull_requests: + <pull%5Frequest6839>
2018-05-29 15:04:18 yselivanov set messages: +
2018-05-29 09:20:49 corona10 set nosy: + serhiy.storchakamessages: +
2018-05-22 13:59:08 corona10 set messages: +
2018-04-29 20:52:34 Antony.Lee set nosy: - Antony.Lee
2018-04-29 15:41:08 serhiy.storchaka set nosy: + yselivanovtype: behaviorversions: + Python 3.7, Python 3.8
2018-04-29 15:00:57 corona10 set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest6332>
2018-04-29 14:37:18 corona10 set nosy: + corona10messages: +
2018-04-02 05:20:03 nitishch set messages: +
2018-04-02 05:15:49 nitishch set nosy: + nitishchmessages: +
2018-04-01 07:14:32 Antony.Lee create