Skip to content

Commit 69b7a7d

Browse files
authored
Drop Python 3.8 support (#368)
1 parent 3615072 commit 69b7a7d

File tree

5 files changed

+40
-87
lines changed

5 files changed

+40
-87
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- main
1212
workflow_dispatch:
1313
schedule:
14-
- cron: '0 0 1,16 * *'
14+
- cron: "0 0 1,16 * *"
1515

1616
jobs:
1717
check_conventions:
@@ -20,19 +20,17 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
include:
23-
- nox-sessions: 'black check_yaml check_json check_toml check_eof check_trailing_space check_lf'
24-
python-version: '3.x'
25-
node-version: '16.x'
26-
- nox-sessions: 'mypy pylint'
27-
python-version: '3.8'
28-
- nox-sessions: 'mypy pylint'
29-
python-version: '3.9'
30-
- nox-sessions: 'mypy pylint'
31-
python-version: '3.10'
32-
- nox-sessions: 'mypy pylint'
33-
python-version: '3.11'
34-
- nox-sessions: 'mypy pylint'
35-
python-version: '3.12'
23+
- nox-sessions: "black check_yaml check_json check_toml check_eof check_trailing_space check_lf"
24+
python-version: "3.x"
25+
node-version: "16.x"
26+
- nox-sessions: "mypy pylint"
27+
python-version: "3.9"
28+
- nox-sessions: "mypy pylint"
29+
python-version: "3.10"
30+
- nox-sessions: "mypy pylint"
31+
python-version: "3.11"
32+
- nox-sessions: "mypy pylint"
33+
python-version: "3.12"
3634
steps:
3735
- uses: actions/checkout@v4
3836
- name: Setup Node.js
@@ -71,13 +69,13 @@ jobs:
7169
fail-fast: false
7270
matrix:
7371
os:
74-
- 'ubuntu-latest'
75-
- 'windows-latest'
76-
- 'macos-latest'
72+
- "ubuntu-latest"
73+
- "windows-latest"
74+
- "macos-latest"
7775
python-version:
78-
- '3.x'
76+
- "3.x"
7977
node-version:
80-
- '16.x'
78+
- "16.x"
8179
runs-on: ${{ matrix.os }}
8280
steps:
8381
- uses: actions/checkout@v4
@@ -116,7 +114,7 @@ jobs:
116114
- name: Setup Graphviz
117115
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2
118116
with:
119-
macos-skip-brew-update: 'true'
117+
macos-skip-brew-update: "true"
120118
- uses: actions/cache@v4
121119
with:
122120
path: ${{ github.workspace }}/theme_build_cache
@@ -143,25 +141,21 @@ jobs:
143141
fail-fast: false
144142
matrix:
145143
os:
146-
- 'ubuntu-latest'
147-
- 'windows-latest'
148-
- 'macos-latest'
144+
- "ubuntu-latest"
145+
- "windows-latest"
146+
- "macos-latest"
149147
python-version:
150-
- '3.8'
151-
- '3.9'
152-
- '3.10'
153-
- '3.11'
154-
- '3.12'
148+
- "3.9"
149+
- "3.10"
150+
- "3.11"
151+
- "3.12"
155152
sphinx-version:
156-
- 'sphinx4'
157-
- 'sphinx5'
158-
- 'sphinx6'
159-
- 'sphinx7'
153+
- "sphinx4"
154+
- "sphinx5"
155+
- "sphinx6"
156+
- "sphinx7"
160157
node-version:
161-
- '16.x'
162-
exclude:
163-
- python-version: '3.8'
164-
sphinx-version: 'sphinx7'
158+
- "16.x"
165159
runs-on: ${{ matrix.os }}
166160
steps:
167161
- uses: actions/checkout@v4
@@ -183,7 +177,7 @@ jobs:
183177
- name: Setup Graphviz
184178
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2
185179
with:
186-
macos-skip-brew-update: 'true'
180+
macos-skip-brew-update: "true"
187181
- uses: actions/cache/restore@v4
188182
with:
189183
path: ${{ github.workspace }}/theme_build_cache
@@ -214,7 +208,7 @@ jobs:
214208
- name: Setup python
215209
uses: actions/setup-python@v5
216210
with:
217-
python-version: '3.x'
211+
python-version: "3.x"
218212
- name: Create coverage report
219213
run: pipx run nox -s coverage
220214
- name: Upload comprehensive coverage HTML report

docs/test_py_module/test.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Test Module for sphinx_rtd_theme."""
33
import functools
4-
import sys
54
from typing import Union
65

76

@@ -120,12 +119,10 @@ def qux_caps(self) -> str:
120119
"""Return the instance qux as uppercase."""
121120
return self.capitalize(self.qux)
122121

123-
if sys.version_info >= (3, 8):
124-
125-
@functools.cached_property
126-
def qux_caps_cached(self) -> str:
127-
"""Return the cached value of instance qux as uppercase."""
128-
return self.qux_caps
122+
@functools.cached_property
123+
def qux_caps_cached(self) -> str:
124+
"""Return the cached value of instance qux as uppercase."""
125+
return self.qux_caps
129126

130127

131128
def func(long: int, param: str, args: None, flags: bool, lists: Union[list, tuple]):

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"check_lf",
1818
]
1919

20-
SUPPORTED_PY_VER = list(f"3.{x}" for x in range(8, 13))
20+
SUPPORTED_PY_VER = list(f"3.{x}" for x in range(9, 13))
2121

2222

2323
@nox.session

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def run(self):
198198
],
199199
"sphinx_immaterial.apidoc.cpp.cppreference_data": ["*.xml"],
200200
},
201-
python_requires=">=3.8",
201+
python_requires=">=3.9",
202202
install_requires=REQUIREMENTS,
203203
use_scm_version={
204204
# It would be nice to include the commit hash in the version, but that

sphinx_immaterial/apidoc/python/type_annotation_transforms.py

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import ast
44
import functools
55
import re
6-
import sys
76
from typing import (
87
cast,
98
Dict,
@@ -23,30 +22,6 @@
2322
import sphinx.environment
2423
import sphinx.util.logging
2524

26-
# `ast.unparse` added in Python 3.9
27-
if sys.version_info >= (3, 9):
28-
from ast import unparse as ast_unparse
29-
else:
30-
from sphinx.pycode.ast import unparse as ast_unparse
31-
from sphinx.pycode.ast import _UnparseVisitor
32-
33-
def _monkey_patch_sphinx_ast_unparse():
34-
"""Monkey patch Sphinx's `ast_unparse`.
35-
36-
This adds support for some additional ast nodes that we require.
37-
"""
38-
39-
def visit_Module(self: _UnparseVisitor, node: ast.Module) -> str:
40-
return "\n".join(self.visit(el) for el in node.body)
41-
42-
def visit_Expr(self: _UnparseVisitor, node: ast.Expr) -> str:
43-
return self.visit(node.value)
44-
45-
_UnparseVisitor.visit_Module = visit_Module # type: ignore[assignment]
46-
_UnparseVisitor.visit_Expr = visit_Expr # type: ignore[assignment]
47-
48-
_monkey_patch_sphinx_ast_unparse()
49-
5025
logger = sphinx.util.logging.getLogger(__name__)
5126

5227
PEP585_ALIASES = {
@@ -128,19 +103,6 @@ def _dotted_name_to_ast(
128103
return tree
129104

130105

131-
if sys.version_info < (3, 8):
132-
_CONSTANT_AST_NODE_TYPES = (
133-
ast.Constant,
134-
ast.Num,
135-
ast.Str,
136-
ast.Bytes,
137-
ast.Ellipsis,
138-
ast.NameConstant,
139-
)
140-
else:
141-
_CONSTANT_AST_NODE_TYPES = (ast.Constant,)
142-
143-
144106
_CONFIG_ATTR = "_sphinx_immaterial_python_type_transform_config"
145107

146108

@@ -173,7 +135,7 @@ def _retain_explicit_literal(node: ast.AST) -> bool:
173135
174136
Since constants cannot be types, there is no ambiguity.
175137
"""
176-
return not isinstance(node, _CONSTANT_AST_NODE_TYPES)
138+
return not isinstance(node, ast.Constant)
177139

178140

179141
class TypeAnnotationTransformer(ast.NodeTransformer):
@@ -266,7 +228,7 @@ def _parse_annotation(annotation: str, env: sphinx.environment.BuildEnvironment)
266228
transformer = TypeAnnotationTransformer()
267229
transformer.config = cast(TypeTransformConfig, transformer_config)
268230
tree = ast.fix_missing_locations(transformer.visit(tree))
269-
annotation = ast_unparse(tree)
231+
annotation = ast.unparse(tree)
270232
return orig_parse_annotation(annotation, env)
271233

272234
if sphinx.version_info >= (7, 3):

0 commit comments

Comments
 (0)