Skip to content

Commit 916802d

Browse files
committed
Enable ruff UP ruleset for pyupgrade
1 parent e15c209 commit 916802d

File tree

9 files changed

+12
-19
lines changed

9 files changed

+12
-19
lines changed

cmd2/argparse_custom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class CompletionItem(str): # noqa: SLOT000
283283
"""
284284

285285
def __new__(cls, value: object, *args: Any, **kwargs: Any) -> 'CompletionItem':
286-
return super(CompletionItem, cls).__new__(cls, value)
286+
return super().__new__(cls, value)
287287

288288
def __init__(self, value: object, description: str = '', *args: Any) -> None:
289289
"""
@@ -1252,7 +1252,7 @@ def __init__(
12521252
"""
12531253
if sys.version_info >= (3, 14):
12541254
# Python >= 3.14 so pass new arguments to parent argparse.ArgumentParser class
1255-
super(Cmd2ArgumentParser, self).__init__(
1255+
super().__init__(
12561256
prog=prog,
12571257
usage=usage,
12581258
description=description,
@@ -1271,7 +1271,7 @@ def __init__(
12711271
)
12721272
else:
12731273
# Python < 3.14, so don't pass new arguments to parent argparse.ArgumentParser class
1274-
super(Cmd2ArgumentParser, self).__init__(
1274+
super().__init__(
12751275
prog=prog,
12761276
usage=usage,
12771277
description=description,

cmd2/cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4089,7 +4089,7 @@ def select(self, opts: Union[str, list[str], list[tuple[Any, Optional[str]]]], p
40894089
except IndexError:
40904090
fulloptions.append((opt[0], opt[0]))
40914091
for idx, (_, text) in enumerate(fulloptions):
4092-
self.poutput(' %2d. %s' % (idx + 1, text))
4092+
self.poutput(' %2d. %s' % (idx + 1, text)) # noqa: UP031
40934093

40944094
while True:
40954095
try:

plugins/ext_test/cmd2_ext_test/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#
2-
# coding=utf-8
31
"""cmd2 External Python Testing Mixin
42
53
Allows developers to exercise their cmd2 application using the PyScript interface

plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#
2-
# coding=utf-8
31
"""External test interface plugin"""
42

53
from typing import (

plugins/ext_test/examples/example.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# coding=utf-8
3-
# import cmd2
41
import cmd2_ext_test
52

63
import cmd2

plugins/ext_test/setup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# coding=utf-8
3-
41
import os
52

63
import setuptools

plugins/ext_test/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def rmrf(items, verbose=True):
2424

2525
for item in items:
2626
if verbose:
27-
print("Removing {}".format(item))
27+
print(f"Removing {item}")
2828
shutil.rmtree(item, ignore_errors=True)
2929
# rmtree doesn't remove bare files
3030
try:

plugins/ext_test/tests/test_ext_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# coding=utf-8
3-
41
import cmd2_ext_test
52
import pytest
63

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ select = [
216216
"TD", # flake8-todos (force all TODOs to include an author and issue link)
217217
"TID", # flake8-tidy-imports (extra import rules to check)
218218
# "TRY", # tryceratops (warnings related to exceptions and try/except)
219-
# "UP", # pyupgrade (A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language)
219+
"UP", # pyupgrade (A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language)
220220
"W", # pycodestyle warnings (warn about minor stylistic issues)
221221
"YTT", # flake8-2020 (checks for misuse of sys.version or sys.version_info)
222222
]
@@ -237,6 +237,8 @@ ignore = [
237237
"TC006", # Add quotes to type expression in typing.cast() (not needed except for forward references)
238238
"UP007", # Use X | Y for type annotations (requires Python 3.10+)
239239
"UP017", # Use datetime.UTC alias (requires Python 3.11+)
240+
"UP036", # Version block is outdated for minimum Python version (requires ruff target_version set to minimum supported)
241+
"UP038", # Use X | Y in {} call instead of (X, Y) - deprecated due to poor performance (requires Python 3.10+)
240242
"W191", # Conflicts with ruff format
241243
]
242244

@@ -254,6 +256,10 @@ per-file-ignores."cmd2/__init__.py" = [
254256
"F401", # Unused import
255257
]
256258

259+
per-file-ignores."cmd2/argparse_custom.py" = [
260+
"UP031", # Use format specifiers instead of percent format (auto fix is unsafe)
261+
]
262+
257263
per-file-ignores."examples/*.py" = [
258264
"INP001", # Module is part of an implicit namespace
259265
"PLW2901", # loop variable overwritten inside loop

0 commit comments

Comments
 (0)