File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1278,7 +1278,10 @@ def fix_w504(self, result):
12781278 newline_count = 0
12791279 newline_index = []
12801280 for index , t in enumerate (ts ):
1281- if t [0 ] == tokenize .OP :
1281+ if t [0 ] == tokenize .OP and t [1 ] not in ".,(){}" :
1282+ if t [2 ][0 ] == 1 and t [3 ][0 ] == 1 :
1283+ operator_position = (t [2 ][1 ], t [3 ][1 ])
1284+ elif t [0 ] == tokenize .NAME and t [1 ] in ("and" , "or" ):
12821285 if t [2 ][0 ] == 1 and t [3 ][0 ] == 1 :
12831286 operator_position = (t [2 ][1 ], t [3 ][1 ])
12841287 elif t [0 ] in (tokenize .NEWLINE , tokenize .NL ):
Original file line number Diff line number Diff line change @@ -4364,6 +4364,25 @@ def test_w504(self):
43644364 with autopep8_context (line , options = ['--select=W504' , '--ignore=E' ]) as result :
43654365 self .assertEqual (fixed , result )
43664366
4367+ def test_w504_with_e265_ignore_option (self ):
4368+ line = '(width == 0 +\n height == 0)\n '
4369+ with autopep8_context (line , options = ['--ignore=E265' ]) as result :
4370+ self .assertEqual (line , result )
4371+
4372+ def test_w504_with_e265_ignore_option_regression (self ):
4373+ line = """\
4374+ if True:
4375+ if True:
4376+ if (
4377+ link.is_wheel and
4378+ isinstance(link.comes_from, HTMLPage) and
4379+ link.comes_from.url.startswith(index_url)
4380+ ):
4381+ _store_wheel_in_cache(file_path, index_url)
4382+ """
4383+ with autopep8_context (line , options = ['--ignore=E265' ]) as result :
4384+ self .assertEqual (line , result )
4385+
43674386 @unittest .skip ('TODO' )
43684387 def test_w504_with_line_comment (self ):
43694388 line = '(width == 0 +\n # this is comment\n height == 0)\n '
You can’t perform that action at this time.
0 commit comments