Skip to content

Commit 0d5d115

Browse files
committed
Replace black, isort, and flake8 with ruff and remove former three
1 parent 45190d4 commit 0d5d115

File tree

8 files changed

+182
-208
lines changed

8 files changed

+182
-208
lines changed

.github/CONTRIBUTING.md

Lines changed: 139 additions & 101 deletions
Large diffs are not rendered by default.

.github/workflows/format.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
33
name: Format
44

5-
on: [push, pull_request]
5+
on: [ push, pull_request ]
66

77
permissions:
88
contents: read
@@ -11,8 +11,8 @@ jobs:
1111
lint:
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest]
15-
python-version: ["3.12"]
14+
os: [ ubuntu-latest ]
15+
python-version: [ "3.12" ]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:
@@ -26,8 +26,6 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install python prerequisites
29-
run: pip install -U --user pip setuptools setuptools-scm black isort
30-
- name: Black
31-
run: python -m black --check --diff .
32-
- name: isort
33-
run: python -m isort --check-only .
29+
run: pip install -U --user ruff
30+
- name: Ruff format
31+
run: ruff format --check

.github/workflows/lint.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
33
name: Lint
44

5-
on: [push, pull_request]
5+
on: [ push, pull_request ]
66

77
permissions:
88
contents: read
@@ -11,8 +11,8 @@ jobs:
1111
lint:
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest]
15-
python-version: ["3.12"]
14+
os: [ ubuntu-latest ]
15+
python-version: [ "3.12" ]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:
@@ -26,6 +26,6 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install python prerequisites
29-
run: pip install -U --user pip setuptools setuptools-scm nox
30-
- name: Lint
31-
run: python -m nox --non-interactive --session validate-${{ matrix.python-version }} -k flake8
29+
run: pip install -U --user ruff
30+
- name: Ruff lint
31+
run: ruff --check

Pipfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@ setuptools = ">=34.4"
99
wcwidth = ">=0.1.7"
1010

1111
[dev-packages]
12-
black = "*"
13-
cmd2 = {editable = true,path = "."}
14-
cmd2_ext_test = {editable = true,path = "plugins/ext_test"}
12+
cmd2 = { editable = true, path = "." }
13+
cmd2_ext_test = { editable = true, path = "plugins/ext_test" }
1514
codecov = "*"
1615
doc8 = "*"
17-
flake8 = "*"
18-
gnureadline = {version = "*",sys_platform = "== 'darwin'"}
16+
gnureadline = { version = "*", sys_platform = "== 'darwin'" }
1917
invoke = "*"
2018
ipython = "*"
21-
isort = "*"
2219
mypy = "*"
23-
pyreadline3 = {version = ">=3.4",sys_platform = "== 'win32'"}
20+
pyreadline3 = { version = ">=3.4", sys_platform = "== 'win32'" }
2421
pytest = "*"
2522
pytest-cov = "*"
2623
pytest-mock = "*"

setup.cfg

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,10 @@ addopts =
77
--cov-report=term
88
--cov-report=html
99

10-
[flake8]
11-
count = True
12-
ignore = E203,W503,E704
13-
max-complexity = 26
14-
max-line-length = 127
15-
show-source = True
16-
statistics = True
17-
exclude =
18-
.git
19-
__pycache__
20-
.tox
21-
.nox
22-
.eggs
23-
*.eggs,
24-
.venv,
25-
.idea,
26-
.pytest_cache,
27-
.vscode,
28-
build,
29-
dist,
30-
htmlcov
31-
32-
[isort]
33-
line_length = 1
34-
skip = cmd2/__init__.py,.git,__pycache,.tox,.nox,.venv,.eggs,.idea,.vscode,build,dist.htmlcov
35-
profile = black
36-
multi_line_output = 3
37-
include_trailing_comma = true
38-
force_grid_wrap = 0
39-
use_parentheses = true
40-
4110
[doc8]
42-
ignore-path=docs/_build,.git,.idea,.pytest_cache,.tox,.nox,.venv,.vscode,build,cmd2,examples,tests,cmd2.egg-info,dist,htmlcov,__pycache__,*.egg,plugins
43-
max-line-length=120
44-
verbose=0
11+
ignore-path = docs/_build,.git,.idea,.pytest_cache,.tox,.nox,.venv,.vscode,build,cmd2,examples,tests,cmd2.egg-info,dist,htmlcov,__pycache__,*.egg,plugins
12+
max-line-length = 120
13+
verbose = 0
4514

4615
[mypy]
4716
disallow_incomplete_defs = True

setup.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@
3434
Programming Language :: Python :: 3.10
3535
Programming Language :: Python :: 3.11
3636
Programming Language :: Python :: 3.12
37+
Programming Language :: Python :: 3.13
3738
Programming Language :: Python :: Implementation :: CPython
3839
Topic :: Software Development :: Libraries :: Python Modules
3940
""".splitlines(),
4041
),
4142
)
4243
) # noqa: E128
4344

44-
SETUP_REQUIRES = ['setuptools >= 34.4', 'setuptools_scm >= 3.0']
45+
SETUP_REQUIRES = ['setuptools', 'setuptools_scm']
4546

4647
INSTALL_REQUIRES = [
47-
'pyperclip >= 1.6',
48-
'wcwidth >= 0.1.7',
48+
'pyperclip',
49+
'wcwidth',
4950
]
5051

5152
EXTRAS_REQUIRE = {
@@ -56,17 +57,14 @@
5657
"gnureadline; sys_platform=='darwin'", # include gnureadline on macOS to ensure it is available in nox env
5758
'codecov',
5859
'coverage',
59-
'pytest>=4.6',
60+
'pytest',
6061
'pytest-cov',
6162
'pytest-mock',
6263
],
6364
# development only dependencies: install with 'pip install -e .[dev]'
6465
'dev': [
6566
'codecov',
6667
'doc8',
67-
'flake8',
68-
'black',
69-
'isort',
7068
'invoke',
7169
'mypy',
7270
'nox',
@@ -76,11 +74,12 @@
7674
'sphinx',
7775
'sphinx-rtd-theme',
7876
'sphinx-autobuild',
79-
'twine>=1.11',
77+
'ruff',
78+
'twine',
8079
],
8180
'validate': [
82-
'flake8',
8381
'mypy',
82+
'ruff',
8483
'types-setuptools',
8584
],
8685
}

tasks.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -347,34 +347,23 @@ def pypi_test(context):
347347
namespace.add_task(pypi_test)
348348

349349

350-
# Flake8 - linter and tool for style guide enforcement and linting
350+
# ruff fast linter
351351
@invoke.task(post=[plugin_tasks.flake8])
352-
def flake8(context):
353-
"""Run flake8 linter and tool for style guide enforcement"""
352+
def lint(context):
353+
"""Run ruff fast linter"""
354354
with context.cd(TASK_ROOT_STR):
355-
context.run("flake8")
355+
context.run("ruff check")
356356

357357

358-
namespace.add_task(flake8)
358+
namespace.add_task(lint)
359359

360360

361-
# Black and isort auto-formatting
361+
# ruff fast formatter
362362
@invoke.task()
363363
def format(context):
364-
"""Run black and isort auto-formatting for code style enforcement"""
364+
"""Run ruff format --checkt"""
365365
with context.cd(TASK_ROOT_STR):
366-
context.run("black . && isort .")
366+
context.run("ruff format --check")
367367

368368

369369
namespace.add_task(format)
370-
371-
372-
# ruff extremely fast Python linter and formatter written in Rust
373-
@invoke.task()
374-
def ruff(context):
375-
"""Run ruff linter and formatter"""
376-
with context.cd(TASK_ROOT_STR):
377-
context.run("ruff check && ruff format --check")
378-
379-
380-
namespace.add_task(ruff)

tests/test_cmd2.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,7 @@ def _expected_no_editor_error():
855855
"""
856856
EXCEPTION of type '{}' occurred with message: Please use 'set editor' to specify your text editing program of choice.
857857
To enable full traceback, run the following command: 'set debug true'
858-
""".format(
859-
expected_exception
860-
)
858+
""".format(expected_exception)
861859
)
862860

863861
return expected_text
@@ -1360,9 +1358,7 @@ def test_select_options(select_app, monkeypatch):
13601358
1. sweet
13611359
2. salty
13621360
{} with salty sauce, yum!
1363-
""".format(
1364-
food
1365-
)
1361+
""".format(food)
13661362
)
13671363

13681364
# Make sure our mock was called with the expected arguments
@@ -1388,9 +1384,7 @@ def test_select_invalid_option_too_big(select_app, monkeypatch):
13881384
2. salty
13891385
'3' isn't a valid choice. Pick a number between 1 and 2:
13901386
{} with sweet sauce, yum!
1391-
""".format(
1392-
food
1393-
)
1387+
""".format(food)
13941388
)
13951389

13961390
# Make sure our mock was called exactly twice with the expected arguments
@@ -1419,9 +1413,7 @@ def test_select_invalid_option_too_small(select_app, monkeypatch):
14191413
2. salty
14201414
'0' isn't a valid choice. Pick a number between 1 and 2:
14211415
{} with sweet sauce, yum!
1422-
""".format(
1423-
food
1424-
)
1416+
""".format(food)
14251417
)
14261418

14271419
# Make sure our mock was called exactly twice with the expected arguments
@@ -1445,9 +1437,7 @@ def test_select_list_of_strings(select_app, monkeypatch):
14451437
1. math
14461438
2. science
14471439
Good luck learning {}!
1448-
""".format(
1449-
'science'
1450-
)
1440+
""".format('science')
14511441
)
14521442

14531443
# Make sure our mock was called with the expected arguments
@@ -1468,9 +1458,7 @@ def test_select_list_of_tuples(select_app, monkeypatch):
14681458
1. Netflix
14691459
2. WebSurfing
14701460
Have fun procrasinating with {}!
1471-
""".format(
1472-
'YouTube'
1473-
)
1461+
""".format('YouTube')
14741462
)
14751463

14761464
# Make sure our mock was called with the expected arguments
@@ -1491,9 +1479,7 @@ def test_select_uneven_list_of_tuples(select_app, monkeypatch):
14911479
1. Electric Guitar
14921480
2. Drums
14931481
Charm us with the {}...
1494-
""".format(
1495-
'Drums'
1496-
)
1482+
""".format('Drums')
14971483
)
14981484

14991485
# Make sure our mock was called with the expected arguments
@@ -1523,9 +1509,7 @@ def test_select_return_type(select_app, monkeypatch, selection, type_str):
15231509
2. String
15241510
3. Method
15251511
The return type is {}
1526-
""".format(
1527-
type_str
1528-
)
1512+
""".format(type_str)
15291513
)
15301514

15311515
# Make sure our mock was called with the expected arguments

0 commit comments

Comments
 (0)