Skip to content

Commit cd01660

Browse files
committed
Add GitHub action for linting. Resolves #13
1 parent 62e8b96 commit cd01660

15 files changed

+159
-146
lines changed

.coveragerc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.flake8

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: nox-lint_multi-arch
2+
on: push
3+
jobs:
4+
tests:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: ["3.10", "3.11", "3.12", "3.13"]
9+
name: Python ${{ matrix.python-version }} xfce-repocapp
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python ${{ matrix.python-version }}
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: ${{ matrix.python-version }}
16+
allow-prereleases: true
17+
architecture: x64
18+
- run: pip install nox==2024.10.09
19+
- run: pip install poetry==1.8.5
20+
- run: |
21+
nox -s lint-${{ matrix.python-version }}

noxfile.py

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import nox
66

7-
nox.options.sessions = "lint", "safety", "tests"
7+
PYTHON_VERSIONS = ["3.10", "3.11", "3.12", "3.13"]
8+
nox.options.sessions = "lint", "tests"
89
locations = (
910
"src",
1011
"./noxfile.py",
@@ -41,64 +42,28 @@ def install_with_constraints(session, *args, **kwargs):
4142
session.install(f"--requirement={requirements.name}", *args, **kwargs)
4243

4344

44-
@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
45-
def black(session):
46-
"""Run black code formatter."""
47-
args = session.posargs or locations
48-
install_with_constraints(session, "black")
49-
session.run("black", *args)
50-
51-
52-
@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
45+
@nox.session(python=PYTHON_VERSIONS)
5346
def docs(session):
5447
"""Build the documentation."""
5548
install_with_constraints(session, "sphinx")
5649
session.run("sphinx-build", "docs", "docs/_build")
5750

5851

59-
@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
52+
@nox.session(python=PYTHON_VERSIONS)
6053
def lint(session):
61-
"""Lint using flake8."""
54+
"""Lint using ruff."""
6255
args = session.posargs or locations
6356
install_with_constraints(
6457
session,
65-
"flake8",
66-
"flake8-bandit",
67-
"flake8-black",
68-
"flake8-bugbear",
69-
# "flake8-docstrings",
70-
"flake8-import-order",
58+
"ruff",
7159
)
72-
session.run("flake8", *args)
73-
74-
75-
@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
76-
def safety(session):
77-
"""Scan dependencies for insecure packages."""
78-
with tempfile.NamedTemporaryFile() as requirements:
79-
session.run(
80-
"poetry",
81-
"export",
82-
"--with",
83-
"dev",
84-
"--format=requirements.txt",
85-
"--without-hashes",
86-
f"--output={requirements.name}",
87-
external=True,
88-
)
89-
install_with_constraints(session, "safety")
90-
session.run(
91-
"safety",
92-
"check",
93-
f"--file={requirements.name}",
94-
"--full-report",
95-
)
60+
session.run("ruff", "check", ".", *args)
9661

9762

98-
@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
63+
@nox.session(python=PYTHON_VERSIONS)
9964
def tests(session):
10065
"""Run the test suite."""
101-
args = session.posargs or ["--cov"]
66+
args = session.posargs
10267
with tempfile.NamedTemporaryFile() as requirements:
10368
session.run(
10469
"poetry",

poetry.lock

Lines changed: 35 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,14 @@ ruff = ">=0.8, <1.0"
2020
nox = "2024.10.09"
2121
pytest = ">=8.0, <8.4"
2222
pytest-cov = ">=6.0.0, <7.0"
23+
pytest-sugar = "1.0.0"
2324
coverage = { version = ">=7.0.0, <8.0.0", extras = ["toml"] }
2425
pylint = "^3.0"
2526
sphinx = ">= 8.0, <9.0"
2627

27-
[tool.black]
28-
line-length = 79
29-
# include =
30-
exclude = '''
31-
/(
32-
\.git
33-
| __pycache__
34-
| .pytest_cache
35-
| .idea
36-
| logs
37-
| .venv
38-
| build
39-
| dist
40-
)/
41-
'''
42-
43-
[tool.coverage.paths]
44-
source = ["src"]
45-
4628
[tool.coverage.run]
4729
branch = true
30+
dynamic_context = "test_function"
4831
source = ["src"]
4932
omit = [
5033
"*/__init__.py",
@@ -61,13 +44,6 @@ precision = 2
6144
show_contexts = true
6245
title = "xfce-repocapp coverage report"
6346

64-
[tool.isort]
65-
profile = "black"
66-
multi_line_output = 3
67-
skip = ["*.gitignore"]
68-
extend_skip = ["*.md", "*.json"]
69-
line_length = 79
70-
7147
[tool.pytest.ini_options]
7248
addopts = [
7349
"--import-mode=importlib",
@@ -82,10 +58,10 @@ respect-gitignore = true
8258
unsafe-fixes = false
8359

8460
# Same as Black.
85-
line-length = 79
61+
line-length = 88
8662

87-
# Assume Python 3.10.
88-
target-version = "py312"
63+
# Assume Python 3.13.x
64+
target-version = "py313"
8965

9066
# Exclude a variety of commonly ignored directories.
9167
exclude = [
@@ -97,12 +73,29 @@ exclude = [
9773
"_build",
9874
"build",
9975
"dist",
76+
"htmlcov",
10077
]
10178

10279
[tool.ruff.lint]
10380
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
104-
select = ["E", "F"]
105-
ignore = []
81+
select = [
82+
"B", # flake8-bugbear
83+
"C90", # mccabe
84+
"E", # pycodestyle errors
85+
"F", # pyflakes
86+
"I", # isort
87+
"S", # flake8-bandit
88+
"W", # pycodestyle warnings
89+
"RUF", # ruff checks
90+
]
91+
ignore = [
92+
"E501", # line too long ({width} > {limit} characters)
93+
# "E203", # slice notation whitespace (not currently supported)
94+
"E402", # module level import not at top of file
95+
"E722", # do not use bare except
96+
# "W503", # (not currently supported)
97+
"ERA", # do not autoremove commented out code
98+
]
10699

107100
# Allow autofix for all enabled rules (when `--fix`) is provided.
108101
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]

requirements-dev.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ exceptiongroup==1.2.2 ; python_full_version >= "3.10.0" and python_version < "3.
193193
filelock==3.16.1 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
194194
--hash=sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0 \
195195
--hash=sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435
196-
identify==2.6.3 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
197-
--hash=sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02 \
198-
--hash=sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd
196+
identify==2.6.4 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
197+
--hash=sha256:285a7d27e397652e8cafe537a6cc97dd470a970f48fb2e9d979aa38eae5513ac \
198+
--hash=sha256:993b0f01b97e0568c179bb9196391ff391bfb88a99099dbf5ce392b68f42d0af
199199
idna==3.10 ; python_version >= "3.10" and python_full_version < "3.14.0" \
200200
--hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \
201201
--hash=sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3
@@ -306,6 +306,9 @@ pytest==8.3.4 ; python_full_version >= "3.10.0" and python_full_version < "3.14.
306306
pytest-cov==6.0.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
307307
--hash=sha256:eee6f1b9e61008bd34975a4d5bab25801eb31898b032dd55addc93e96fcaaa35 \
308308
--hash=sha256:fde0b595ca248bb8e2d76f020b465f3b107c9632e6a1d1705f17834c89dcadc0
309+
pytest-sugar==1.0.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
310+
--hash=sha256:6422e83258f5b0c04ce7c632176c7732cab5fdb909cb39cca5c9139f81276c0a \
311+
--hash=sha256:70ebcd8fc5795dc457ff8b69d266a4e2e8a74ae0c3edc749381c64b5246c8dfd
309312
pyyaml==6.0.2 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
310313
--hash=sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff \
311314
--hash=sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48 \
@@ -406,6 +409,9 @@ sphinxcontrib-qthelp==2.0.0 ; python_version >= "3.10" and python_full_version <
406409
sphinxcontrib-serializinghtml==2.0.0 ; python_version >= "3.10" and python_full_version < "3.14.0" \
407410
--hash=sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331 \
408411
--hash=sha256:e9d912827f872c029017a53f0ef2180b327c3f7fd23c87229f7a8e8b70031d4d
412+
termcolor==2.5.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
413+
--hash=sha256:37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8 \
414+
--hash=sha256:998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f
409415
tomli==2.2.1 ; python_version >= "3.10" and python_full_version <= "3.11.0a6" \
410416
--hash=sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6 \
411417
--hash=sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd \

0 commit comments

Comments
 (0)