New submission from Ivan Levkivskyi <levkivs...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue32018>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to