Skip to content

Commit

Permalink
fix: repeated autopep8 use in runpy by reloading pycodestyle with imp…
Browse files Browse the repository at this point in the history
…ortlib
  • Loading branch information
hhatto committed Mar 17, 2024
1 parent 0fa37c2 commit eddf8fa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions autopep8.py
Expand Up @@ -69,6 +69,7 @@ class documentation for more information.
import copy
import difflib
import fnmatch
import importlib
import inspect
import io
import itertools
Expand Down Expand Up @@ -221,9 +222,6 @@ def extended_blank_lines(logical_line,
yield (0, 'E301 expected 1 blank line, found 0')


pycodestyle.register_check(extended_blank_lines)


def continued_indentation(logical_line, tokens, indent_level, hang_closing,
indent_char, noqa):
"""Override pycodestyle's function to provide indentation information."""
Expand Down Expand Up @@ -415,7 +413,11 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
yield (pos, 'E125 {}'.format(desired_indent))


# NOTE: need reload with runpy and call twice
# see: https://github.com/hhatto/autopep8/issues/625
importlib.reload(pycodestyle)
del pycodestyle._checks['logical_line'][pycodestyle.continued_indentation]
pycodestyle.register_check(extended_blank_lines)
pycodestyle.register_check(continued_indentation)


Expand Down

0 comments on commit eddf8fa

Please sign in to comment.