-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
inspect.signature does not respect PEP 8 #76199
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
Comments
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 time PEP-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. |
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 :) |
Those people who read and write annotations regularly are all using the convention that was added to PEP-8, so let's make inspect follow that lead rather than argue about it here. :-) |
Agreed. |
I've submitted a 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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: