Skip to content

Commit 3830fe9

Browse files
committed
refactor: remove RET505 and add spaces
1 parent 9bc93bc commit 3830fe9

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ ignore = [
139139
flake8-unused-arguments.ignore-variadic-names = true
140140

141141
[tool.ruff.lint.per-file-ignores]
142-
"tests/test_*.py" = ["PYI024", "PLR", "SIM201"]
142+
"tests/test_*.py" = ["PYI024", "PLR", "SIM201", "RET505"]
143143
"tasks/check.py" = ["UP032"]
144144
"tests/test_requirements.py" = ["UP032"]

src/packaging/_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,17 @@ def _parse_marker_var(tokenizer: Tokenizer) -> MarkerVar: # noqa: RET503
316316
"""
317317
if tokenizer.check("VARIABLE"):
318318
return process_env_var(tokenizer.read().text.replace(".", "_"))
319+
319320
if tokenizer.check("QUOTED_STRING"):
320321
return process_python_str(tokenizer.read().text)
322+
321323
tokenizer.raise_syntax_error(message="Expected a marker variable or quoted string")
322324

323325

324326
def process_env_var(env_var: str) -> Variable:
325327
if env_var in ("platform_python_implementation", "python_implementation"):
326328
return Variable("platform_python_implementation")
329+
327330
return Variable(env_var)
328331

329332

@@ -339,13 +342,16 @@ def _parse_marker_op(tokenizer: Tokenizer) -> Op:
339342
if tokenizer.check("IN"):
340343
tokenizer.read()
341344
return Op("in")
345+
342346
if tokenizer.check("NOT"):
343347
tokenizer.read()
344348
tokenizer.expect("WS", expected="whitespace after 'not'")
345349
tokenizer.expect("IN", expected="'in' after 'not'")
346350
return Op("not in")
351+
347352
if tokenizer.check("OP"):
348353
return Op(tokenizer.read().text)
354+
349355
return tokenizer.raise_syntax_error(
350356
"Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in"
351357
)

src/packaging/markers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@ def _format_marker(
157157
inner = (_format_marker(m, first=False) for m in marker)
158158
if first:
159159
return " ".join(inner)
160+
160161
return "(" + " ".join(inner) + ")"
162+
161163
if isinstance(marker, tuple):
162164
return " ".join([m.serialize() for m in marker])
165+
163166
return marker
164167

165168

@@ -201,6 +204,7 @@ def _normalize(
201204
if key == "extra":
202205
assert isinstance(rhs, str), "extra value must be a string"
203206
return (canonicalize_name(lhs), canonicalize_name(rhs))
207+
204208
if key in MARKERS_ALLOWING_SET:
205209
return (
206210
canonicalize_name(lhs),

src/packaging/metadata.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,12 @@ def _process_dynamic(self, value: list[str]) -> list[str]:
657657
raise self._invalid_metadata(
658658
f"{dynamic_field!r} is not allowed as a dynamic field"
659659
)
660+
660661
if dynamic_field not in _EMAIL_TO_RAW_MAPPING:
661662
raise self._invalid_metadata(
662663
f"{dynamic_field!r} is not a valid dynamic field"
663664
)
665+
664666
return list(map(str.lower, value))
665667

666668
def _process_provides_extra(
@@ -745,16 +747,19 @@ def _process_import_names(self, value: list[str]) -> list[str]:
745747
f"{name!r} is invalid for {{field}}; "
746748
f"{identifier!r} is not a valid identifier"
747749
)
750+
748751
if keyword.iskeyword(identifier):
749752
raise self._invalid_metadata(
750753
f"{name!r} is invalid for {{field}}; "
751754
f"{identifier!r} is a keyword"
752755
)
756+
753757
if semicolon and private.lstrip() != "private":
754758
raise self._invalid_metadata(
755759
f"{import_name!r} is invalid for {{field}}; "
756760
"the only valid option is 'private'"
757761
)
762+
758763
return value
759764

760765
_process_import_namespaces = _process_import_names

src/packaging/tags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ def _generic_abi() -> list[str]:
263263
ext_suffix = _get_config_var("EXT_SUFFIX", warn=True)
264264
if not isinstance(ext_suffix, str) or ext_suffix[0] != ".":
265265
raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')")
266+
266267
parts = ext_suffix.split(".")
267268
if len(parts) < 3:
268269
# CPython3.7 and earlier uses ".pyd" on Windows.
269270
return _cpython_abis(sys.version_info[:2])
271+
270272
soabi = parts[1]
271273
if soabi.startswith("cpython"):
272274
# non-windows
@@ -283,6 +285,7 @@ def _generic_abi() -> list[str]:
283285
abi = soabi
284286
else:
285287
return []
288+
286289
return [_normalize_string(abi)]
287290

288291

@@ -572,6 +575,7 @@ def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
572575
# we should never be here, just yield the sysconfig one and return
573576
yield linux
574577
return
578+
575579
if is_32bit:
576580
if linux == "linux_x86_64":
577581
linux = "linux_i686"
@@ -595,12 +599,16 @@ def platform_tags() -> Iterator[str]:
595599
"""
596600
if platform.system() == "Darwin":
597601
return mac_platforms()
602+
598603
if platform.system() == "iOS":
599604
return ios_platforms()
605+
600606
if platform.system() == "Android":
601607
return android_platforms()
608+
602609
if platform.system() == "Linux":
603610
return _linux_platforms()
611+
604612
return _generic_platforms()
605613

606614

src/packaging/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def local(self) -> str | None:
333333
"""
334334
if self._version.local:
335335
return ".".join(str(x) for x in self._version.local)
336+
336337
return None
337338

338339
@property

0 commit comments

Comments
 (0)