Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require pycodestyle 2.10.0 and higher version #659

Merged
merged 6 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ autopep8 fixes the following issues_ reported by pycodestyle_::
W391 - Remove trailing blank lines.
W503 - Fix line break before binary operator.
W504 - Fix line break after binary operator.
W601 - Use "in" rather than "has_key()".
W602 - Fix deprecated form of raising exception.
W603 - Use "!=" instead of "<>"
W604 - Use "repr()" instead of backticks.
W605 - Fix invalid escape sequence 'x'.
W690 - Fix various deprecated code (via lib2to3).

Expand Down Expand Up @@ -347,9 +343,6 @@ function:
Or with options:

>>> import autopep8
>>> autopep8.fix_code('x.has_key(y)\n',
... options={'aggressive': 1})
'y in x\n'
>>> autopep8.fix_code('print( 123 )\n',
... options={'ignore': ['E']})
'print( 123 )\n'
Expand Down
30 changes: 1 addition & 29 deletions autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,10 @@ class documentation for more information.
# to be enabled, disable both of them
CONFLICTING_CODES = ('W503', 'W504')

SELECTED_GLOBAL_FIXED_METHOD_CODES = ['W602', ]

# W602 is handled separately due to the need to avoid "with_traceback".
CODE_TO_2TO3 = {
'E231': ['ws_comma'],
'E721': ['idioms'],
'W601': ['has_key'],
'W603': ['ne'],
'W604': ['repr'],
'W690': ['apply',
'except',
'exitfunc',
Expand Down Expand Up @@ -1779,14 +1774,6 @@ def fix_2to3(source,
filename=filename)


def fix_w602(source, aggressive=True):
"""Fix deprecated form of raising exception."""
if not aggressive:
return source

return refactor(source, ['raise'], ignore='with_traceback')


def find_newline(source):
"""Return type of newline used in source.

Expand Down Expand Up @@ -3547,22 +3534,10 @@ def fix_lines(source_lines, options, filename=''):
# Disable "apply_local_fixes()" for now due to issue #175.
fixed_source = tmp_source
else:
pep8_options = {
'ignore': options.ignore,
'select': options.select,
'max_line_length': options.max_line_length,
'hang_closing': options.hang_closing,
}
sio = io.StringIO(tmp_source)
contents = sio.readlines()
results = _execute_pep8(pep8_options, contents)
codes = {result['id'] for result in results
if result['id'] in SELECTED_GLOBAL_FIXED_METHOD_CODES}
# Apply global fixes only once (for efficiency).
fixed_source = apply_global_fixes(tmp_source,
options,
filename=filename,
codes=codes)
filename=filename)

passes = 0
long_line_ignore_cache = set()
Expand Down Expand Up @@ -3684,9 +3659,6 @@ def apply_global_fixes(source, options, where='global', filename='',
)

for (code, function) in global_fixes():
if code.upper() in SELECTED_GLOBAL_FIXED_METHOD_CODES \
and code.upper() not in codes:
continue
if code_match(code, select=options.select, ignore=options.ignore):
if options.verbose:
print('---> Applying {} fix for {}'.format(where,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


INSTALL_REQUIRES = (
['pycodestyle >= 2.9.1', 'tomli']
['pycodestyle >= 2.10.0', 'tomli']
)


Expand Down
12 changes: 0 additions & 12 deletions test/suite/W60.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
#: W601
if a.has_key("b"):
print a
#: W602
raise DummyError, "Message"
#: W602
raise ValueError, "hello %s %s" % (1, 2)
#: Okay
raise type_, val, tb
raise Exception, Exception("f"), t
#: W603
if x <> 0:
x = 0
#: W604
val = `1 + 2`
12 changes: 0 additions & 12 deletions test/suite/out/W60.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
#: W601
if "b" in a:
print a
#: W602
raise DummyError, "Message"
#: W602
raise ValueError, "hello %s %s" % (1, 2)
#: Okay
raise type_, val, tb
raise Exception, Exception("f"), t
#: W603
if x != 0:
x = 0
#: W604
val = repr(1 + 2)
Loading