Skip to content

Commit 1c46b7c

Browse files
Update to Python 3.13 (#13)
1 parent 50b335e commit 1c46b7c

20 files changed

+203
-134
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v5
1313
with:
14-
python-version: '3.10'
15-
- uses: pre-commit/action@v3.0.0
14+
python-version: '3.12'
15+
- uses: pre-commit/action@v3.0.1

.github/workflows/publish-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
- uses: actions/checkout@v4
1717
with:
1818
ref: main
19-
- name: Set up Python 3.10
19+
- name: Set up Python 3.12
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.10'
22+
python-version: '3.12'
2323

2424
- name: Install setuptools
2525
run: |

.github/workflows/run_tox.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- uses: actions/setup-python@v5
1212
with:
13-
python-version: '3.10'
14-
- uses: pre-commit/action@v3.0.0
13+
python-version: '3.12'
14+
- uses: pre-commit/action@v3.0.1
1515

1616
test:
1717
needs: pre-commit
1818
runs-on: ubuntu-latest
1919
strategy:
2020
max-parallel: 4
2121
matrix:
22-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
22+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
2323

2424
steps:
2525
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-ast
66
- id: check-builtin-literals
@@ -13,9 +13,28 @@ repos:
1313
- id: trailing-whitespace
1414

1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.1.11 # check that this version matches the requirements.txt
16+
rev: v0.6.9
1717
hooks:
1818
- id: ruff
19+
name: ruff unused imports
20+
# F401 [*] {name} imported but unused
21+
args: [ "--select", "F401", "--extend-exclude", "__init__.py", "--fix"]
22+
23+
- id: ruff
24+
# I001 [*] Import block is un-sorted or un-formatted
25+
# UP035 [*] Import from {target} instead: {names}
26+
# Q000 [*] Double quote found but single quotes preferred
27+
# Q001 [*] Double quote multiline found but single quotes preferred
28+
args: [ "--select", "I001,UP035,Q000,Q001", "--fix"]
29+
30+
31+
- repo: https://github.com/JelleZijlstra/autotyping
32+
rev: 24.9.0
33+
hooks:
34+
- id: autotyping
35+
types: [python]
36+
args: [--safe]
37+
1938

2039
- repo: https://github.com/pre-commit/pygrep-hooks
2140
rev: v1.10.0

.ruff.toml

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,96 @@
1-
2-
line-length = 120
31
indent-width = 4
2+
line-length = 120
43

54
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
5+
6+
src = [
7+
"src",
8+
"tests"
419
]
4210

11+
12+
[lint]
13+
select = ["ALL"]
14+
4315
ignore = [
16+
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
17+
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
18+
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
19+
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
20+
4421
"RET501", # https://docs.astral.sh/ruff/rules/unnecessary-return-none/#unnecessary-return-none-ret501
4522
"TRY400", # https://docs.astral.sh/ruff/rules/error-instead-of-exception/
4623

47-
"A003", # https://docs.astral.sh/ruff/rules/builtin-attribute-shadowing/
24+
# https://docs.astral.sh/ruff/rules/#flake8-builtins-a
25+
"A003", # Python builtin is shadowed by class attribute {name} from {row}
26+
27+
# https://docs.astral.sh/ruff/rules/#pyflakes-f
28+
"F401", # {name} imported but unused; consider using importlib.util.find_spec to test for availability
29+
30+
# https://docs.astral.sh/ruff/rules/#flake8-bandit-s
31+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
32+
33+
# https://docs.astral.sh/ruff/rules/#pyupgrade-up
34+
"UP038", # Use X | Y in {} call instead of (X, Y)
35+
36+
# https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
37+
"ANN101", # Missing type annotation for {name} in method
38+
"ANN102", # Missing type annotation for {name} in classmethod
39+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {name}
40+
41+
# https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble
42+
"BLE001", # Do not catch blind exception: {name}
43+
44+
# https://docs.astral.sh/ruff/rules/#flake8-raise-rse
45+
"RSE102", # Unnecessary parentheses on raised exception
46+
47+
# https://docs.astral.sh/ruff/rules/#flake8-commas-com
48+
"COM812", # Trailing comma missing
49+
"COM819", # Trailing comma prohibited
50+
51+
# https://docs.astral.sh/ruff/rules/#warning-w_1
52+
"PLW0603", # Using the global statement to update {name} is discouraged
53+
54+
# https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
55+
"G004", # Logging statement uses f-string
56+
57+
# https://docs.astral.sh/ruff/rules/#refactor-r
58+
"PLR1711", # Useless return statement at end of function
59+
60+
# https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
61+
"RUF005", # Consider {expression} instead of concatenation
4862
]
4963

5064

5165
[format]
52-
# Use single quotes for non-triple-quoted strings.
5366
quote-style = "single"
5467

5568

69+
# https://docs.astral.sh/ruff/settings/#lintflake8-quotes
70+
[lint.flake8-quotes]
71+
inline-quotes = "single"
72+
multiline-quotes = "single"
5673

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-
]
6574

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-
]
75+
[lint.flake8-builtins]
76+
builtins-ignorelist = ["id", "input"]
7077

71-
"setup.py" = ["PTH123"]
7278

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-
]
79+
# https://docs.astral.sh/ruff/settings/#lintisort
80+
[lint.isort]
81+
lines-after-imports = 2 # https://docs.astral.sh/ruff/settings/#lint_isort_lines-after-imports
7782

7883

79-
[lint.isort]
80-
# https://docs.astral.sh/ruff/settings/#isort-lines-after-imports
81-
lines-after-imports = 2
84+
[lint.per-file-ignores]
85+
"setup.py" = ["PTH123"]
8286

87+
"tests/*" = [
88+
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
89+
90+
# https://docs.astral.sh/ruff/rules/#flake8-bandit-s
91+
"S101", # Use of assert detected
8392

84-
[lint.pylint]
85-
max-args = 6
93+
# https://docs.astral.sh/ruff/rules/#refactor-r
94+
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
95+
"PLR0913", # Too many arguments in function definition ({c_args} > {max_args})
96+
]

requirements.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
pytest == 7.4.4
2-
pre-commit == 3.5.0
1+
# Dependencies for old python versions
2+
pre-commit == 3.5.0; python_version < '3.9'
3+
pytest == 7.4.4; python_version < '3.10'
4+
sphinx == 7.4.7; python_version == '3.9'
5+
sphinx == 7.1.2; python_version == '3.8'
36

4-
ruff == 0.1.11
7+
# Current dependencies
8+
pre-commit == 4.0.1; python_version >= '3.9'
9+
pytest == 8.3.3; python_version >= '3.10'
10+
sphinx == 8.1.3; python_version >= '3.10'
511

6-
sphinx == 7.1.2
7-
sphinx-rtd-theme == 2.0.0
12+
ruff == 0.6.9
13+
14+
sphinx-rtd-theme == 3.0.1

setup.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def load_version() -> str:
88
version: typing.Dict[str, str] = {}
9-
with open("src/sphinx_exec_code/__version__.py") as fp:
9+
with open('src/sphinx_exec_code/__version__.py') as fp:
1010
exec(fp.read(), version)
1111
assert version['__version__'], version
1212
return version['__version__']
@@ -21,42 +21,43 @@ def load_version() -> str:
2121
readme = Path(__file__).with_name('readme.md')
2222
long_description = ''
2323
if readme.is_file():
24-
with readme.open("r", encoding='utf-8') as fh:
24+
with readme.open('r', encoding='utf-8') as fh:
2525
long_description = fh.read()
2626

2727
setup(
28-
name="sphinx-exec-code",
28+
name='sphinx-exec-code',
2929
version=__version__,
30-
author="spaceman_spiff",
30+
author='spaceman_spiff',
3131
# author_email="",
32-
description="Execute code blocks in Sphinx and display the output",
32+
description='Execute code blocks in Sphinx and display the output',
3333
keywords=[
3434
'sphinx',
3535
'execute',
3636
'exec',
3737
'code'
3838
],
3939
long_description=long_description,
40-
long_description_content_type="text/markdown",
41-
url="https://github.com/spacemanspiff2007/sphinx-exec-code",
40+
long_description_content_type='text/markdown',
41+
url='https://github.com/spacemanspiff2007/sphinx-exec-code',
4242
project_urls={
4343
'GitHub': 'https://github.com/spacemanspiff2007/sphinx-exec-code',
4444
'Documentation': 'https://sphinx-exec-code.readthedocs.io/',
4545
},
4646
package_dir={'': 'src'},
4747
packages=find_packages('src', exclude=['tests*']),
4848
classifiers=[
49-
"Development Status :: 5 - Production/Stable",
49+
'Development Status :: 5 - Production/Stable',
5050
'Intended Audience :: Developers',
5151
'Framework :: Sphinx :: Extension',
52-
"License :: OSI Approved :: Apache Software License",
53-
"Natural Language :: English",
54-
"Operating System :: OS Independent",
55-
"Programming Language :: Python :: 3.8",
56-
"Programming Language :: Python :: 3.9",
57-
"Programming Language :: Python :: 3.10",
58-
"Programming Language :: Python :: 3.11",
59-
"Programming Language :: Python :: 3.12",
60-
"Programming Language :: Python :: 3 :: Only",
52+
'License :: OSI Approved :: Apache Software License',
53+
'Natural Language :: English',
54+
'Operating System :: OS Independent',
55+
'Programming Language :: Python :: 3.8',
56+
'Programming Language :: Python :: 3.9',
57+
'Programming Language :: Python :: 3.10',
58+
'Programming Language :: Python :: 3.11',
59+
'Programming Language :: Python :: 3.12',
60+
'Programming Language :: Python :: 3.13',
61+
'Programming Language :: Python :: 3 :: Only',
6162
],
6263
)

src/sphinx_exec_code/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from .__version__ import __version__
2-
3-
# isort: split
4-
51
from sphinx_exec_code.sphinx_api import setup
2+
3+
from .__version__ import __version__

src/sphinx_exec_code/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.12'
1+
__version__ = '0.13'

src/sphinx_exec_code/code_exec_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class CodeExceptionError(Exception):
10-
def __init__(self, code: str, file: Path, first_loc: int, ret: int, stderr: str):
10+
def __init__(self, code: str, file: Path, first_loc: int, ret: int, stderr: str) -> None:
1111
self.code = code
1212

1313
self.file: Path = file

0 commit comments

Comments
 (0)