Skip to content
Snippets Groups Projects
Commit 17baca46 authored by Jimmy Jia's avatar Jimmy Jia Committed by Ian Stapleton Cordasco
Browse files

Fix detection of annotated argument defaults

This improves E252 to allow default arguments like `_default(f=1)`.

Closes gh-753
parent d8f10a90
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -937,17 +937,17 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
parens -= 1
elif in_def and text == ':' and parens == 1:
annotated_func_arg = True
elif parens and text == ',' and parens == 1:
elif parens == 1 and text == ',':
annotated_func_arg = False
elif parens and text == '=':
if not annotated_func_arg:
no_space = True
if start != prev_end:
yield (prev_end, message)
else:
if annotated_func_arg and parens == 1:
require_space = True
if start == prev_end:
yield (prev_end, missing_message)
else:
no_space = True
if start != prev_end:
yield (prev_end, message)
if not parens:
annotated_func_arg = False
 
Loading
Loading
Loading
Loading
@@ -45,3 +45,6 @@ async def add(a: int = 0, b: int = 0) -> int:
#: E252:1:15 E252:1:16 E252:1:27 E252:1:36
def add(a: int=0, b: int =0, c: int= 0) -> int:
return a + b + c
#: Okay
def add(a: int = _default(name='f')):
return a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment