
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-11-13 22:06 bylevkivskyi, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4408 | merged | corona10,2017-11-15 17:36 | |
| Messages (6) | |||
|---|---|---|---|
| msg306171 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2017-11-13 22:06 | |
The string representation of a function signature with annotations is currently like this:>>> def __init__(self, x: int = 1, y: int = 2) -> None: pass... >>> import inspect>>> str(inspect.signature(__init__))'(self, x:str=1, y:int=2) -> None'At the same timePEP 8 says:When combining an argument annotation with a default value, use spaces around the = sign (but only for those arguments that have both an annotation and a default).Yes:def munge(sep: AnyStr = None): ...def munge(input: AnyStr, sep: AnyStr = None, limit=1000): ...No:def munge(input: AnyStr=None): ...def munge(input: AnyStr, limit = 1000): ...I think there should be spaces in the signature repr. | |||
| msg306172 -(view) | Author: R. David Murray (r.david.murray)*![]() | Date: 2017-11-13 22:11 | |
FWIW, I find the version without the spaces to be more readable (but I don't find annotations to be readable in general, so my opinion may not be worth much :) | |||
| msg306174 -(view) | Author: Guido van Rossum (gvanrossum)*![]() | Date: 2017-11-13 22:49 | |
Those people who read and write annotations regularly are all using the convention that was added toPEP 8, so let's make inspect follow that lead rather than argue about it here. :-) | |||
| msg306175 -(view) | Author: R. David Murray (r.david.murray)*![]() | Date: 2017-11-13 22:53 | |
Agreed. | |||
| msg306295 -(view) | Author: Dong-hee Na (corona10)*![]() | Date: 2017-11-15 18:25 | |
I've submitted a patch. :) | |||
| msg306296 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2017-11-15 18:31 | |
New changeset762b9571c9c8c6b036f1bf90140a1d030b3f9a01 by Yury Selivanov (Dong-hee Na) in branch 'master':bpo-32018: Fix inspect.signature repr to followPEP 8 (#4408)https://github.com/python/cpython/commit/762b9571c9c8c6b036f1bf90140a1d030b3f9a01 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:54 | admin | set | github: 76199 |
| 2017-11-15 18:31:22 | yselivanov | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-11-15 18:31:06 | yselivanov | set | messages: +msg306296 |
| 2017-11-15 18:25:51 | corona10 | set | messages: +msg306295 |
| 2017-11-15 17:46:28 | corona10 | set | nosy: +corona10 |
| 2017-11-15 17:36:41 | corona10 | set | keywords: +patch stage: patch review pull_requests: +pull_request4357 |
| 2017-11-13 22:53:52 | r.david.murray | set | messages: +msg306175 |
| 2017-11-13 22:49:59 | gvanrossum | set | nosy: +gvanrossum messages: +msg306174 |
| 2017-11-13 22:36:06 | eric.smith | set | nosy: +eric.smith |
| 2017-11-13 22:11:27 | r.david.murray | set | nosy: +r.david.murray messages: +msg306172 |
| 2017-11-13 22:06:50 | levkivskyi | create | |