8000 Set ruff `target-version` to the minimum supported version of Python by tleonhardt · Pull Request #1441 · python-cmd2/cmd2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Set ruff target-version to the minimum supported version of Python #1441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3597,8 +3597,8 @@ def _macro_create(self, args: argparse.Namespace) -> None:
max_arg_num = 0
arg_nums = set()

while True:
try:
try:
while True:
cur_match = normal_matches.__next__()

# Get the number string between the braces
Expand All @@ -3612,9 +3612,8 @@ def _macro_create(self, args: argparse.Namespace) -> None:
max_arg_num = max(max_arg_num, cur_num)

arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=False))

except StopIteration:
break
except StopIteration:
pass

# Make sure the argument numbers are continuous
if len(arg_nums) != max_arg_num:
Expand All @@ -3624,16 +3623,16 @@ def _macro_create(self, args: argparse.Namespace) -> None:
# Find all escaped arguments
escaped_matches = re.finditer(MacroArg.macro_escaped_arg_pattern, value)

while True:
try:
try:
while True:
cur_match = escaped_matches.__next__()

# Get the number string between the braces
cur_num_str = re.findall(MacroArg.digit_pattern, cur_match.group())[0]

arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=True))
except StopIteration:
break
except StopIteration:
pass

# Set the macro
result = "overwritten" if args.name in self.macros else "created"
Expand Down
52 changes: 15 additions & 37 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ exclude = [
# Same as Black.
line-length = 127
indent-width = 4

# Assume Python 3.13
target-version = "py313"
target-version = "py39" # Minimum supported version of Python
output-format = "full"

[tool.ruff.lint]
Expand Down Expand Up @@ -235,6 +233,7 @@ ignore = [
"E111", # Conflicts with ruff format
"E114", # Conflicts with ruff format
"E117", # Conflicts with ruff format
"FA100", # Adding from __future__ import annotations screws up cmd2 because of how use inspect to validate type annotations at runtime
"ISC002", # Conflicts with ruff format
"Q000", # Conflicts with ruff format
"Q001", # Conflicts with ruff format
Expand All @@ -258,56 +257,35 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

mccabe.max-complexity = 49

per-file-ignores."cmd2/__init__.py" = [
"E402", # Module level import not at top of file
"F401", # Unused import
]
[tool.ruff.lint.per-file-ignores]
# Module level import not at top of file and unused import
"cmd2/__init__.py" = ["E402", "F401"]

per-file-ignores."cmd2/argparse_custom.py" = [
"B010", # Do not call setattr with a constant attribute value
]
# Do not call setattr with constant attribute value
"cmd2/argparse_custom.py" = ["B010"]

per-file-ignores."examples/*.py" = [
# Ignore various varnings in examples/ directory
"examples/*.py" = [
"ANN", # Ignore all type annotation rules in examples folder
"D", # Ignore all pydocstyle rules in examples folder
"INP001", # Module is part of an implicit namespace
"PLW2901", # loop variable overwritten inside loop
"S", # Ignore all Security rules in examples folder
]
"examples/scripts/*.py" = ["F821"] # Undefined name `app`
"plugins/*.py" = ["INP001"] # Module is part of an implicit namespace

per-file-ignores."examples/scripts/*.py" = [
"F821", # Undefined name `app`
]

per-file-ignores."plugins/*.py" = [
"ANN", # Ignore all type annotation rules in test folders
"D", # Ignore all pydocstyle rules in test folders
"INP001", # Module is part of an implicit namespace
"S", # Ignore all Security rules in test folders
"SLF", # Ignore all warnings about private or protected member access in test folders
]

per-file-ignores."tests/*.py" = [
# Ingore various rulesets in test and plugins directories
"{plugins,tests,tests_isolated}/*.py" = [
"ANN", # Ignore all type annotation rules in test folders
"ARG", # Ignore all unused argument warnings in test folders
"D", # Ignore all pydocstyle rules in test folders
"E501", # Line too long
"S", # Ignore all Security rules in test folders
"SLF", # Ignore all warnings about private or protected member access in test folders
]

per-file-ignores."tests/pyscript/*.py" = [
"F821", # Undefined name `app`
"INP001", # Module is part of an implicit namespace
]

per-file-ignores."tests_isolated/*.py" = [
"ANN", # Ignore all type annotation rules in test folders
"ARG", # Ignore all unused argument warnings in test folders
"D", # Ignore all pydocstyle rules in test folders
"S", # Ignore all Security rules in test folders
"SLF", # Ignore all warnings about private or protected member access in test folders
]
# Undefined name `app` and module is part of an implicit namespace
"tests/pyscript/*.py" = ["F821", "INP001"]

[tool.ruff.format]
# Like Black, use double quotes for strings.
Expand Down
Loading
0