PEP8 suggests no spaces around equal operators in function parameters.
For example:
Correct:
def func(a=0):
print('PEP8 compliant spacing')
Incorrect:
def func(a = 0):
print('Invalid PEP8 spacing')
PyCharm's auto-formatter fails to pick up incorrect spacing when typing is included.
For example, PyCharm does not correctly format the following function:
def func(a: int = 0):
print('Invalid PEP8 spacing')
To:
def func(a: int=0):
print('PEP8 compliant spacing')
Has anyone found a way to have PyCharm's auto-formatter pick up spacing violations where typing is present?
You are mistaken in your quoting of PEP8. The whitespace is supposed to be there in this case:
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): ...
No:
def munge(input: AnyStr=None): ...
def munge(input: AnyStr, limit = 1000): ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With