Skip to content

Commit 4f9751c

Browse files
authored
Merge pull request #96 from aboutcode-org/add-code-style-checks
Add code style checks
2 parents dc123f1 + 6450529 commit 4f9751c

30 files changed

+350
-406
lines changed

.github/workflows/docs-ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222

2323
- name: Install Dependencies
24-
run: pip install -e .[docs]
24+
run: ./configure --dev
2525

26-
- name: Check Sphinx Documentation build minimally
27-
working-directory: ./docs
28-
run: sphinx-build -E -W source build
26+
- name: Check documentation and HTML for errors and dead links
27+
run: make docs-check
2928

30-
- name: Check for documentation style errors
31-
working-directory: ./docs
32-
run: ./scripts/doc8_style_check.sh
29+
- name: Check documentation for style errors
30+
run: make doc8
3331

3432

.github/workflows/pypi-release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ jobs:
3030
with:
3131
python-version: 3.12
3232

33-
- name: Install pypa/build
34-
run: python -m pip install build --user
33+
- name: Install pypa/build and twine
34+
run: python -m pip install --user build twine
3535

3636
- name: Build a binary wheel and a source tarball
3737
run: python -m build --sdist --wheel --outdir dist/
3838

39+
- name: Validate wheel and sdis for Pypi
40+
run: python -m twine check dist/*
41+
3942
- name: Upload built archives
4043
uses: actions/upload-artifact@v4
4144
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ tcl
7272

7373
# Ignore Jupyter Notebook related temp files
7474
.ipynb_checkpoints/
75+
/.ruff_cache/
76+
.env

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ python:
2626
- method: pip
2727
path: .
2828
extra_requirements:
29-
- docs
29+
- dev

AUTHORS.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
The following organizations or individuals have contributed to this repo:
22

3-
-
3+
-

MANIFEST.in

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
graft src
2+
graft docs
3+
graft etc
24

35
include *.LICENSE
46
include NOTICE
57
include *.ABOUT
68
include *.toml
79
include *.yml
810
include *.rst
11+
include *.png
912
include setup.*
1013
include configure*
1114
include requirements*
12-
include .git*
15+
include .dockerignore
16+
include .gitignore
17+
include .readthedocs.yml
18+
include manage.py
19+
include Dockerfile*
20+
include Makefile
21+
include MANIFEST.in
1322

14-
global-exclude *.py[co] __pycache__ *.*~
23+
include .VERSION
1524

25+
global-exclude *.py[co] __pycache__ *.*~

Makefile

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,33 @@ PYTHON_EXE?=python3
1313
VENV=venv
1414
ACTIVATE?=. ${VENV}/bin/activate;
1515

16-
dev:
17-
@echo "-> Configure the development envt."
18-
./configure --dev
1916

20-
isort:
21-
@echo "-> Apply isort changes to ensure proper imports ordering"
22-
${VENV}/bin/isort --sl -l 100 src tests setup.py
17+
conf:
18+
@echo "-> Install dependencies"
19+
./configure
2320

24-
black:
25-
@echo "-> Apply black code formatter"
26-
${VENV}/bin/black -l 100 src tests setup.py
21+
dev:
22+
@echo "-> Configure and install development dependencies"
23+
./configure --dev
2724

2825
doc8:
2926
@echo "-> Run doc8 validation"
30-
@${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
27+
@${ACTIVATE} doc8 --quiet docs/ *.rst
3128

32-
valid: isort black
29+
valid:
30+
@echo "-> Run Ruff format"
31+
@${ACTIVATE} ruff format
32+
@echo "-> Run Ruff linter"
33+
@${ACTIVATE} ruff check --fix
3334

3435
check:
35-
@echo "-> Run pycodestyle (PEP8) validation"
36-
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,migrations,settings.py,.cache .
37-
@echo "-> Run isort imports ordering validation"
38-
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
39-
@echo "-> Run black validation"
40-
@${ACTIVATE} black --check --check -l 100 src tests setup.py
36+
@echo "-> Run Ruff linter validation (pycodestyle, bandit, isort, and more)"
37+
@${ACTIVATE} ruff check
38+
@echo "-> Run Ruff format validation"
39+
@${ACTIVATE} ruff format --check
40+
@$(MAKE) doc8
41+
@echo "-> Run ABOUT files validation"
42+
@${ACTIVATE} about check etc/
4143

4244
clean:
4345
@echo "-> Clean the Python env"
@@ -49,6 +51,10 @@ test:
4951

5052
docs:
5153
rm -rf docs/_build/
52-
@${ACTIVATE} sphinx-build docs/ docs/_build/
54+
@${ACTIVATE} sphinx-build docs/source docs/_build/
55+
56+
docs-check:
57+
@${ACTIVATE} sphinx-build -E -W -b html docs/source docs/_build/
58+
@${ACTIVATE} sphinx-build -E -W -b linkcheck docs/source docs/_build/
5359

54-
.PHONY: conf dev check valid black isort clean test docs
60+
.PHONY: conf dev check valid clean test docs docs-check

README.rst

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
A Simple Python Project Skeleton
22
================================
33

4-
This repo attempts to standardize the structure of the Python-based project's repositories using
5-
modern Python packaging and configuration techniques that can then be applied to many repos.
6-
7-
Using this `blog post`_ as inspiration, this repository serves as the base for all new Python
8-
projects and is mergeable in existing repositories as well.
4+
This repo attempts to standardize the structure of the Python-based project's
5+
repositories using modern Python packaging and configuration techniques.
6+
Using this `blog post`_ as inspiration, this repository serves as the base for
7+
all new Python projects and is mergeable in existing repositories as well.
98

109
.. _blog post: https://blog.jaraco.com/a-project-skeleton-for-python-projects/
1110

@@ -45,6 +44,10 @@ More usage instructions can be found in ``docs/skeleton-usage.rst``.
4544
Release Notes
4645
=============
4746

47+
- 2025-03-31:
48+
49+
- Use ruff as the main code formatting tool, add ruff rules to pyproject.toml
50+
4851
- 2025-03-29:
4952

5053
- Add support for beta macOS-15
@@ -69,7 +72,7 @@ Release Notes
6972

7073
- Drop support for Python 3.8
7174
- Drop support for macOS-11, add support for macOS-14
72-
75+
7376
- 2024-02-19:
7477

7578
- Replace support in CI of default ubuntu-20.04 by ubuntu-22.04
@@ -86,19 +89,19 @@ Release Notes
8689

8790
- Synchronize configure and configure.bat scripts for sanity
8891
- Update CI operating system support with latest Azure OS images
89-
- Streamline utility scripts in etc/scripts/ to create, fetch and manage third-party dependencies
90-
There are now fewer scripts. See etc/scripts/README.rst for details
92+
- Streamline utility scripts in etc/scripts/ to create, fetch and manage third-party
93+
dependencies. There are now fewer scripts. See etc/scripts/README.rst for details
9194

9295
- 2021-09-03:
93-
94-
- ``configure`` now requires pinned dependencies via the use of ``requirements.txt`` and ``requirements-dev.txt``
95-
96+
- ``configure`` now requires pinned dependencies via the use of ``requirements.txt``
97+
and ``requirements-dev.txt``
9698
- ``configure`` can now accept multiple options at once
9799
- Add utility scripts from scancode-toolkit/etc/release/ for use in generating project files
98100
- Rename virtual environment directory from ``tmp`` to ``venv``
99-
- Update README.rst with instructions for generating ``requirements.txt`` and ``requirements-dev.txt``,
100-
as well as collecting dependencies as wheels and generating ABOUT files for them.
101+
- Update README.rst with instructions for generating ``requirements.txt``
102+
and ``requirements-dev.txt``, as well as collecting dependencies as wheels and generating
103+
ABOUT files for them.
101104

102105
- 2021-05-11:
103-
104-
- Adopt new configure scripts from ScanCode TK that allows correct configuration of which Python version is used.
106+
- Adopt new configure scripts from ScanCode TK that allows correct configuration of which
107+
Python version is used.

azure-pipelines.yml

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,90 +7,74 @@
77

88
jobs:
99

10+
- template: etc/ci/azure-posix.yml
11+
parameters:
12+
job_name: run_code_checks
13+
image_name: ubuntu-24.04
14+
python_versions: ['3.12']
15+
test_suites:
16+
all: make check
17+
1018
- template: etc/ci/azure-posix.yml
1119
parameters:
1220
job_name: ubuntu22_cpython
1321
image_name: ubuntu-22.04
14-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
22+
python_versions: ['3.9', '3.10', '3.11', '3.12']
1523
test_suites:
1624
all: venv/bin/pytest -n 2 -vvs
1725

1826
- template: etc/ci/azure-posix.yml
1927
parameters:
2028
job_name: ubuntu24_cpython
2129
image_name: ubuntu-24.04
22-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
30+
python_versions: ['3.9', '3.10', '3.11', '3.12']
2331
test_suites:
2432
all: venv/bin/pytest -n 2 -vvs
2533

2634
- template: etc/ci/azure-posix.yml
2735
parameters:
2836
job_name: macos13_cpython
29-
image_name: macOS-13-xlarge
30-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
31-
test_suites:
32-
all: venv/bin/pytest -n 2 -vvs
33-
34-
- template: etc/ci/azure-posix.yml
35-
parameters:
36-
job_name: macos13_cpython_arm64
3737
image_name: macOS-13
38-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
38+
python_versions: ['3.9', '3.10', '3.11', '3.12']
3939
test_suites:
4040
all: venv/bin/pytest -n 2 -vvs
4141

4242
- template: etc/ci/azure-posix.yml
4343
parameters:
4444
job_name: macos14_cpython
45-
image_name: macOS-14-large
46-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
47-
test_suites:
48-
all: venv/bin/pytest -n 2 -vvs
49-
50-
- template: etc/ci/azure-posix.yml
51-
parameters:
52-
job_name: macos14_cpython_arm64
5345
image_name: macOS-14
54-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
46+
python_versions: ['3.9', '3.10', '3.11', '3.12']
5547
test_suites:
5648
all: venv/bin/pytest -n 2 -vvs
5749

5850
- template: etc/ci/azure-posix.yml
5951
parameters:
6052
job_name: macos15_cpython
6153
image_name: macOS-15
62-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
63-
test_suites:
64-
all: venv/bin/pytest -n 2 -vvs
65-
66-
- template: etc/ci/azure-posix.yml
67-
parameters:
68-
job_name: macos15_cpython_arm64
69-
image_name: macOS-15-large
70-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
54+
python_versions: ['3.9', '3.10', '3.11', '3.12']
7155
test_suites:
7256
all: venv/bin/pytest -n 2 -vvs
7357

7458
- template: etc/ci/azure-win.yml
7559
parameters:
7660
job_name: win2019_cpython
7761
image_name: windows-2019
78-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
62+
python_versions: ['3.9', '3.10', '3.11', '3.12']
7963
test_suites:
8064
all: venv\Scripts\pytest -n 2 -vvs
8165

8266
- template: etc/ci/azure-win.yml
8367
parameters:
8468
job_name: win2022_cpython
8569
image_name: windows-2022
86-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
70+
python_versions: ['3.9', '3.10', '3.11', '3.12']
8771
test_suites:
8872
all: venv\Scripts\pytest -n 2 -vvs
8973

9074
- template: etc/ci/azure-win.yml
9175
parameters:
9276
job_name: win2025_cpython
9377
image_name: windows-2025
94-
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
78+
python_versions: ['3.9', '3.10', '3.11', '3.12']
9579
test_suites:
9680
all: venv\Scripts\pytest -n 2 -vvs

configure

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ CLI_ARGS=$1
2929

3030
# Requirement arguments passed to pip and used by default or with --dev.
3131
REQUIREMENTS="--editable . --constraint requirements.txt"
32-
DEV_REQUIREMENTS="--editable .[testing] --constraint requirements.txt --constraint requirements-dev.txt"
33-
DOCS_REQUIREMENTS="--editable .[docs] --constraint requirements.txt"
32+
DEV_REQUIREMENTS="--editable .[dev] --constraint requirements.txt --constraint requirements-dev.txt"
3433

3534
# where we create a virtualenv
3635
VIRTUALENV_DIR=venv
3736

3837
# Cleanable files and directories to delete with the --clean option
39-
CLEANABLE="build dist venv .cache .eggs"
38+
CLEANABLE="build dist venv .cache .eggs *.egg-info docs/_build/ pip-selfcheck.json"
4039

4140
# extra arguments passed to pip
4241
PIP_EXTRA_ARGS=" "
@@ -168,6 +167,7 @@ clean() {
168167
for cln in $CLEANABLE;
169168
do rm -rf "${CFG_ROOT_DIR:?}/${cln:?}";
170169
done
170+
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
171171
set +e
172172
exit
173173
}
@@ -185,7 +185,6 @@ while getopts :-: optchar; do
185185
help ) cli_help;;
186186
clean ) find_python && clean;;
187187
dev ) CFG_REQUIREMENTS="$DEV_REQUIREMENTS";;
188-
docs ) CFG_REQUIREMENTS="$DOCS_REQUIREMENTS";;
189188
esac;;
190189
esac
191190
done

0 commit comments

Comments
 (0)