Skip to content

Commit

Permalink
Merge pull request #1 from keriksson-rosenqvist/bugfix/package_versio…
Browse files Browse the repository at this point in the history
…n_check

Version dependent operator whitespace function.
  • Loading branch information
keriksson-rosenqvist authored Aug 4, 2023
2 parents 5b9110b + 028f68f commit 36941c7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class documentation for more information.
import warnings
import ast
from configparser import ConfigParser as SafeConfigParser, Error
from packaging.version import parse as parse_version

import pycodestyle
from pycodestyle import STARTSWITH_INDENT_STATEMENT_REGEX
Expand Down Expand Up @@ -757,8 +758,16 @@ def fix_e225(self, result):
return
if not check_syntax(fixed.lstrip()):
return
if (
parse_version(pycodestyle.__version__) >=
parse_version("2.11.0")
):
operator_whitespace = pycodestyle.missing_whitespace
else:
operator_whitespace = \
pycodestyle.missing_whitespace_around_operator
errors = list(
pycodestyle.missing_whitespace_around_operator(fixed, ts))
operator_whitespace(fixed, ts))
for e in reversed(errors):
if error_code != e[1].split()[0]:
continue
Expand Down

0 comments on commit 36941c7

Please sign in to comment.