Skip to content

Commit 76abb5d

Browse files
committed
Moved to existing check
1 parent d13134e commit 76abb5d

File tree

2 files changed

+11
-33
lines changed

2 files changed

+11
-33
lines changed

pycodestyle.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,17 @@ def whitespace_around_keywords(logical_line):
494494
elif len(after) > 1:
495495
yield match.start(2), "E271 multiple spaces after keyword"
496496

497+
if sys.version_info >= (3, 10):
498+
match = MATCH_CASE_REGEX.match(logical_line)
499+
if match:
500+
whitespace = match.groups()[0]
501+
if whitespace == ' ':
502+
return
503+
if whitespace == '':
504+
yield match.start(1), "E275 missing whitespace after keyword"
505+
else:
506+
yield match.start(1), "E271 multiple spaces after keyword"
507+
497508

498509
@register_check
499510
def missing_whitespace_after_import_keyword(logical_line):
@@ -513,32 +524,6 @@ def missing_whitespace_after_import_keyword(logical_line):
513524
yield pos, "E275 missing whitespace after keyword"
514525

515526

516-
@register_check
517-
def missing_whitespace_after_match_case(logical_line):
518-
r"""Check whitespace after 'match' and 'case'.
519-
520-
Python 3.10
521-
Okay: match status:
522-
E271: match status:
523-
E271: case\tstatus:
524-
E271: case _:
525-
E275: matchstatus:
526-
E275: casestatus:
527-
E275: case_:
528-
"""
529-
if sys.version_info < (3, 10):
530-
return
531-
match = MATCH_CASE_REGEX.match(logical_line)
532-
if match:
533-
whitespace = match.groups()[0]
534-
if whitespace == ' ':
535-
return
536-
if whitespace == '':
537-
yield match.start(1), "E275 missing whitespace after keyword"
538-
else:
539-
yield match.start(1), "E271 multiple spaces after keyword"
540-
541-
542527
@register_check
543528
def missing_whitespace(logical_line):
544529
r"""Each comma, semicolon or colon should be followed by whitespace.

testsuite/support.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pycodestyle import Checker, BaseReport, StandardReport, readlines
77

88
SELFTEST_REGEX = re.compile(r'\b(Okay|[EW]\d{3}):\s(.*)')
9-
SELFTEST_PY_REGEX = re.compile(r'\bPython (\d).(\d+)')
109
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
1110

1211

@@ -113,14 +112,8 @@ def selftest(options):
113112
counters = report.counters
114113
checks = options.physical_checks + options.logical_checks
115114
for name, check, argument_names in checks:
116-
python_version = None
117115
for line in check.__doc__.splitlines():
118116
line = line.lstrip()
119-
match = SELFTEST_PY_REGEX.match(line)
120-
if match:
121-
python_version = tuple(map(int, match.groups()))
122-
if python_version and sys.version_info < python_version:
123-
continue
124117
match = SELFTEST_REGEX.match(line)
125118
if match is None:
126119
continue

0 commit comments

Comments
 (0)