[New-bugs-announce] [issue32018] inspect.signature does not respect PEP 8

Ivan Levkivskyi report at bugs.python.org
Mon Nov 13 17:06:50 EST 2017


New submission from Ivan Levkivskyi <levkivskyi at gmail.com>:

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.

----------
messages: 306171
nosy: levkivskyi, yselivanov
priority: normal
severity: normal
status: open
title: inspect.signature does not respect PEP 8
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32018>
_______________________________________


More information about the New-bugs-announce mailing list