Skip to content

Commit ef5df93

Browse files
0.11: Update CI & ruff fixes
1 parent 6526245 commit ef5df93

24 files changed

+192
-71
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ jobs:
77
build-n-publish:
88
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
99
runs-on: ubuntu-latest
10+
environment: release
11+
permissions:
12+
# IMPORTANT: this permission is mandatory for trusted publishing
13+
id-token: write
1014

1115
steps:
1216
- uses: actions/checkout@v3
1317
with:
1418
ref: main
15-
- name: Set up Python 3.8
19+
- name: Set up Python 3.10
1620
uses: actions/setup-python@v4
1721
with:
1822
python-version: '3.10'
@@ -27,7 +31,4 @@ jobs:
2731
python setup.py sdist bdist_wheel
2832
2933
- name: Publish distribution to PyPI
30-
uses: pypa/gh-action-pypi-publish@master
31-
with:
32-
user: __token__
33-
password: ${{ secrets.pypi_api_key }}
34+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run_tox.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@ name: Tests
33
on: [push, pull_request]
44

55
jobs:
6+
pre-commit:
7+
name: pre-commit
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.10'
14+
- uses: pre-commit/action@v3.0.0
15+
616
test:
17+
needs: pre-commit
718
runs-on: ubuntu-latest
819
strategy:
920
max-parallel: 4
1021
matrix:
11-
python-version: ['3.8', '3.9', '3.10', '3.11']
22+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
1223

1324
steps:
1425
- uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: check-docstring-first
8+
- id: check-merge-conflict
9+
- id: check-toml
510
- id: check-yaml
11+
- id: debug-statements
612
- id: end-of-file-fixer
713
- id: trailing-whitespace
814

9-
- repo: https://github.com/pycqa/isort
10-
rev: 5.12.0
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.1.11 # check that this version matches the requirements.txt
1117
hooks:
12-
- id: isort
13-
name: isort (python)
14-
15-
16-
- repo: https://github.com/PyCQA/flake8
17-
rev: '6.0.0'
18-
hooks:
19-
- id: flake8
20-
additional_dependencies:
21-
- flake8-bugbear==23.1.20
22-
- flake8-comprehensions==3.10.1
23-
- flake8-pytest-style==1.6
24-
- flake8-noqa==1.3
25-
- pep8-naming==0.13.3
18+
- id: ruff
2619

2720
- repo: https://github.com/pre-commit/pygrep-hooks
2821
rev: v1.10.0
2922
hooks:
3023
- id: rst-backticks
3124

32-
3325
- repo: meta
3426
hooks:
3527
- id: check-hooks-apply

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ formats: all
1818

1919

2020
build:
21-
os: ubuntu-20.04
21+
os: ubuntu-22.04
2222
tools:
23-
python: "3.9"
23+
python: "3.10"
2424

2525
python:
2626
install:

.ruff.toml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
line-length = 120
3+
indent-width = 4
4+
5+
target-version = "py38"
6+
src = ["src", "test"]
7+
8+
# https://docs.astral.sh/ruff/settings/#ignore-init-module-imports
9+
ignore-init-module-imports = true
10+
11+
extend-exclude = ["__init__.py"]
12+
13+
select = [
14+
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
15+
"I", # https://docs.astral.sh/ruff/rules/#isort-i
16+
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
17+
18+
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
19+
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
20+
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
21+
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
22+
"FIX", # https://docs.astral.sh/ruff/rules/#flake8-fixme-fix
23+
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
24+
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
25+
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
26+
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
27+
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
28+
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
29+
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
30+
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
31+
"T10", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
32+
"TCH", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
33+
"TD", # https://docs.astral.sh/ruff/rules/#flake8-todos-td
34+
35+
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
36+
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
37+
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
38+
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
39+
40+
"PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
41+
]
42+
43+
ignore = [
44+
"RET501", # https://docs.astral.sh/ruff/rules/unnecessary-return-none/#unnecessary-return-none-ret501
45+
"TRY400", # https://docs.astral.sh/ruff/rules/error-instead-of-exception/
46+
47+
"A003", # https://docs.astral.sh/ruff/rules/builtin-attribute-shadowing/
48+
]
49+
50+
51+
[format]
52+
# Use single quotes for non-triple-quoted strings.
53+
quote-style = "single"
54+
55+
56+
57+
[lint.per-file-ignores]
58+
"doc/*" = [
59+
"A001", # A001 Variable `copyright` is shadowing a Python builtin
60+
"E402", # E402 Module level import not at top of file
61+
"INP001", # INP001 File `FILE_NAME` is part of an implicit namespace package. Add an `__init__.py`.
62+
"PTH100", # PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
63+
"PTH118", # PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
64+
]
65+
66+
"tests/*" = [
67+
"INP001", # INP001 File `FILE_NAME` is part of an implicit namespace package. Add an `__init__.py`.
68+
"ISC002", # ISC002 Implicitly concatenated string literals over multiple lines
69+
]
70+
71+
"setup.py" = ["PTH123"]
72+
73+
"src/sphinx_exec_code/code_exec_error.py" = [
74+
"PERF401", # PERF401 Use a list comprehension to create a transformed list
75+
"PLW2901", # PLW2901 `for` loop variable `tb_line` overwritten by assignment target
76+
]
77+
78+
79+
[lint.isort]
80+
# https://docs.astral.sh/ruff/settings/#isort-lines-after-imports
81+
lines-after-imports = 2
82+
83+
84+
[lint.pylint]
85+
max-args = 6

doc/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13-
import logging
13+
1414
import os
1515
import sys
1616

17-
# required for sphinx_exec_code
17+
18+
# required for sphinx_exec_code to be found
1819
sys.path.insert(0, os.path.join(os.path.abspath('..'), 'src'))
1920

21+
2022
import sphinx_exec_code
2123

24+
2225
# -- Project information -----------------------------------------------------
2326
project = 'sphinx-exec-code'
2427
copyright = '2021, spacemanspiff2007'

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ This code will be executed
3636
```
3737

3838
# Changelog
39+
#### 0.11 (2024-01-09)
40+
- Updated CI and ruff fixes
41+
3942
#### 0.10 (2023-02-13)
4043
- Fixed a bug when no code was shown/executed
4144

requirements.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
pytest >= 7.2, < 7.3
2-
pre-commit >= 3.0, < 3.1
1+
pytest == 7.4.4
2+
pre-commit == 3.5.0
33

4-
sphinx >= 6.1, < 6.2
5-
sphinx-rtd-theme >= 1.2, <1.3
4+
ruff == 0.1.11
5+
6+
sphinx == 7.1.2
7+
sphinx-rtd-theme == 2.0.0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def load_version() -> str:
4646
package_dir={'': 'src'},
4747
packages=find_packages('src', exclude=['tests*']),
4848
classifiers=[
49-
"Development Status :: 4 - Beta",
49+
"Development Status :: 5 - Production/Stable",
5050
'Intended Audience :: Developers',
5151
'Framework :: Sphinx :: Extension',
5252
"License :: OSI Approved :: Apache Software License",
@@ -56,6 +56,7 @@ def load_version() -> str:
5656
"Programming Language :: Python :: 3.9",
5757
"Programming Language :: Python :: 3.10",
5858
"Programming Language :: Python :: 3.11",
59+
"Programming Language :: Python :: 3.12",
5960
"Programming Language :: Python :: 3 :: Only",
6061
],
6162
)

src/sphinx_exec_code/__const__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from sphinx.util import logging
22

3+
34
log = logging.getLogger('sphinx-exec-code')

0 commit comments

Comments
 (0)