pycodestyle 2.12.1__tar.gz → 2.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/PKG-INFO +2 -2
  2. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/PKG-INFO +2 -2
  3. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.py +27 -21
  4. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/setup.cfg +1 -1
  5. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_E901.py +2 -2
  6. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/LICENSE +0 -0
  7. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/README.rst +0 -0
  8. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/SOURCES.txt +0 -0
  9. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/dependency_links.txt +0 -0
  10. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/entry_points.txt +0 -0
  11. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/not-zip-safe +0 -0
  12. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/pycodestyle.egg-info/top_level.txt +0 -0
  13. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/setup.py +0 -0
  14. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_E101.py +0 -0
  15. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_all.py +0 -0
  16. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_api.py +0 -0
  17. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_blank_lines.py +0 -0
  18. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_data.py +0 -0
  19. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_parser.py +0 -0
  20. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_pycodestyle.py +0 -0
  21. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_self_doctests.py +0 -0
  22. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_shell.py +0 -0
  23. {pycodestyle-2.12.1 → pycodestyle-2.13.0}/tests/test_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycodestyle
3
- Version: 2.12.1
3
+ Version: 2.13.0
4
4
  Summary: Python style guide checker
5
5
  Home-page: https://pycodestyle.pycqa.org/
6
6
  Author: Johann C. Rocholl
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Classifier: Programming Language :: Python :: Implementation :: CPython
22
22
  Classifier: Programming Language :: Python :: Implementation :: PyPy
23
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.8
24
+ Requires-Python: >=3.9
25
25
  Description-Content-Type: text/x-rst
26
26
  License-File: LICENSE
27
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycodestyle
3
- Version: 2.12.1
3
+ Version: 2.13.0
4
4
  Summary: Python style guide checker
5
5
  Home-page: https://pycodestyle.pycqa.org/
6
6
  Author: Johann C. Rocholl
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Classifier: Programming Language :: Python :: Implementation :: CPython
22
22
  Classifier: Programming Language :: Python :: Implementation :: PyPy
23
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.8
24
+ Requires-Python: >=3.9
25
25
  Description-Content-Type: text/x-rst
26
26
  License-File: LICENSE
27
27
 
@@ -68,7 +68,7 @@ if (
68
68
  ): # pragma: no cover (<py310)
69
69
  tokenize._compile = lru_cache(tokenize._compile) # type: ignore
70
70
 
71
- __version__ = '2.12.1'
71
+ __version__ = '2.13.0'
72
72
 
73
73
  DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
74
74
  DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503,W504'
@@ -135,6 +135,7 @@ OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)')
135
135
  LAMBDA_REGEX = re.compile(r'\blambda\b')
136
136
  HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
137
137
  STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)\b')
138
+ STARTSWITH_GENERIC_REGEX = re.compile(r'^(async\s+def|def|class|type)\s+\w+\[')
138
139
  STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def\s+|def\s+|class\s+|@)')
139
140
  STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
140
141
  r'^\s*({})\b'.format('|'.join(s.replace(' ', r'\s+') for s in (
@@ -233,9 +234,11 @@ def trailing_whitespace(physical_line):
233
234
  W291: spam(1) \n#
234
235
  W293: class Foo(object):\n \n bang = 12
235
236
  """
236
- physical_line = physical_line.rstrip('\n') # chr(10), newline
237
- physical_line = physical_line.rstrip('\r') # chr(13), carriage return
238
- physical_line = physical_line.rstrip('\x0c') # chr(12), form feed, ^L
237
+ # Strip these trailing characters:
238
+ # - chr(10), newline
239
+ # - chr(13), carriage return
240
+ # - chr(12), form feed, ^L
241
+ physical_line = physical_line.rstrip('\n\r\x0c')
239
242
  stripped = physical_line.rstrip(' \t\v')
240
243
  if physical_line != stripped:
241
244
  if stripped:
@@ -783,7 +786,6 @@ def whitespace_before_parameters(logical_line, tokens):
783
786
  # Allow "return (a.foo for a in range(5))"
784
787
  not keyword.iskeyword(prev_text) and
785
788
  (
786
- sys.version_info < (3, 9) or
787
789
  # 3.12+: type is a soft keyword but no braces after
788
790
  prev_text == 'type' or
789
791
  not keyword.issoftkeyword(prev_text)
@@ -958,10 +960,8 @@ def missing_whitespace(logical_line, tokens):
958
960
  # Allow argument unpacking: foo(*args, **kwargs).
959
961
  if prev_type == tokenize.OP and prev_text in '}])' or (
960
962
  prev_type != tokenize.OP and
961
- prev_text not in KEYWORDS and (
962
- sys.version_info < (3, 9) or
963
- not keyword.issoftkeyword(prev_text)
964
- )
963
+ prev_text not in KEYWORDS and
964
+ not keyword.issoftkeyword(prev_text)
965
965
  ):
966
966
  need_space = None
967
967
  elif text in WS_OPTIONAL_OPERATORS:
@@ -1020,12 +1020,13 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
1020
1020
  E251: return magic(r = real, i = imag)
1021
1021
  E252: def complex(real, image: float=0.0):
1022
1022
  """
1023
- parens = 0
1023
+ paren_stack = []
1024
1024
  no_space = False
1025
1025
  require_space = False
1026
1026
  prev_end = None
1027
1027
  annotated_func_arg = False
1028
1028
  in_def = bool(STARTSWITH_DEF_REGEX.match(logical_line))
1029
+ in_generic = bool(STARTSWITH_GENERIC_REGEX.match(logical_line))
1029
1030
 
1030
1031
  message = "E251 unexpected spaces around keyword / parameter equals"
1031
1032
  missing_message = "E252 missing whitespace around parameter equals"
@@ -1043,15 +1044,22 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
1043
1044
  yield (prev_end, missing_message)
1044
1045
  if token_type == tokenize.OP:
1045
1046
  if text in '([':
1046
- parens += 1
1047
- elif text in ')]':
1048
- parens -= 1
1049
- elif in_def and text == ':' and parens == 1:
1047
+ paren_stack.append(text)
1048
+ # PEP 696 defaults always use spaced-style `=`
1049
+ # type A[T = default] = ...
1050
+ # def f[T = default](): ...
1051
+ # class C[T = default](): ...
1052
+ if in_generic and paren_stack == ['[']:
1053
+ annotated_func_arg = True
1054
+ elif text in ')]' and paren_stack:
1055
+ paren_stack.pop()
1056
+ # def f(arg: tp = default): ...
1057
+ elif text == ':' and in_def and paren_stack == ['(']:
1050
1058
  annotated_func_arg = True
1051
- elif parens == 1 and text == ',':
1059
+ elif len(paren_stack) == 1 and text == ',':
1052
1060
  annotated_func_arg = False
1053
- elif parens and text == '=':
1054
- if annotated_func_arg and parens == 1:
1061
+ elif paren_stack and text == '=':
1062
+ if annotated_func_arg and len(paren_stack) == 1:
1055
1063
  require_space = True
1056
1064
  if start == prev_end:
1057
1065
  yield (prev_end, missing_message)
@@ -1059,7 +1067,7 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
1059
1067
  no_space = True
1060
1068
  if start != prev_end:
1061
1069
  yield (prev_end, message)
1062
- if not parens:
1070
+ if not paren_stack:
1063
1071
  annotated_func_arg = False
1064
1072
 
1065
1073
  prev_end = end
@@ -1910,9 +1918,7 @@ class Checker:
1910
1918
 
1911
1919
  def run_check(self, check, argument_names):
1912
1920
  """Run a check plugin."""
1913
- arguments = []
1914
- for name in argument_names:
1915
- arguments.append(getattr(self, name))
1921
+ arguments = [getattr(self, name) for name in argument_names]
1916
1922
  return check(*arguments)
1917
1923
 
1918
1924
  def init_checker_state(self, name, argument_names):
@@ -29,7 +29,7 @@ project_urls =
29
29
 
30
30
  [options]
31
31
  py_modules = pycodestyle
32
- python_requires = >=3.8
32
+ python_requires = >=3.9
33
33
  include_package_data = True
34
34
  zip_safe = False
35
35
 
@@ -23,7 +23,7 @@ def lasting(self, duration=300):
23
23
  '''
24
24
  errors = errors_from_src(src)
25
25
  if sys.version_info < (3, 12): # pragma: <3.12 cover
26
- expected = ['E122:4:1', 'E251:5:13', 'E251:5:15']
26
+ expected = ['E122:4:1']
27
27
  else: # pragma: >=3.12 cover
28
- expected = ['E122:4:1', 'E251:5:13', 'E251:5:15', 'E901:5:1'] # noqa: E501
28
+ expected = ['E122:4:1', 'E901:5:1'] # noqa: E501
29
29
  self.assertEqual(errors, expected)
File without changes
File without changes
File without changes