Skip to content

Commit

Permalink
Drop Python 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jbms committed Jul 10, 2024
1 parent 99ba8ab commit d50317c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 87 deletions.
70 changes: 32 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- main
workflow_dispatch:
schedule:
- cron: '0 0 1,16 * *'
- cron: "0 0 1,16 * *"

jobs:
check_conventions:
Expand All @@ -20,19 +20,17 @@ jobs:
fail-fast: false
matrix:
include:
- nox-sessions: 'black check_yaml check_json check_toml check_eof check_trailing_space check_lf'
python-version: '3.x'
node-version: '16.x'
- nox-sessions: 'mypy pylint'
python-version: '3.8'
- nox-sessions: 'mypy pylint'
python-version: '3.9'
- nox-sessions: 'mypy pylint'
python-version: '3.10'
- nox-sessions: 'mypy pylint'
python-version: '3.11'
- nox-sessions: 'mypy pylint'
python-version: '3.12'
- nox-sessions: "black check_yaml check_json check_toml check_eof check_trailing_space check_lf"
python-version: "3.x"
node-version: "16.x"
- nox-sessions: "mypy pylint"
python-version: "3.9"
- nox-sessions: "mypy pylint"
python-version: "3.10"
- nox-sessions: "mypy pylint"
python-version: "3.11"
- nox-sessions: "mypy pylint"
python-version: "3.12"
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
Expand Down Expand Up @@ -71,13 +69,13 @@ jobs:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
python-version:
- '3.x'
- "3.x"
node-version:
- '16.x'
- "16.x"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -116,7 +114,7 @@ jobs:
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2
with:
macos-skip-brew-update: 'true'
macos-skip-brew-update: "true"
- uses: actions/cache@v4
with:
path: ${{ github.workspace }}/theme_build_cache
Expand All @@ -143,25 +141,21 @@ jobs:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- "3.9"
- "3.10"
- "3.11"
- "3.12"
sphinx-version:
- 'sphinx4'
- 'sphinx5'
- 'sphinx6'
- 'sphinx7'
- "sphinx4"
- "sphinx5"
- "sphinx6"
- "sphinx7"
node-version:
- '16.x'
exclude:
- python-version: '3.8'
sphinx-version: 'sphinx7'
- "16.x"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -183,7 +177,7 @@ jobs:
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2
with:
macos-skip-brew-update: 'true'
macos-skip-brew-update: "true"
- uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/theme_build_cache
Expand Down Expand Up @@ -214,7 +208,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: "3.x"
- name: Create coverage report
run: pipx run nox -s coverage
- name: Upload comprehensive coverage HTML report
Expand Down
11 changes: 4 additions & 7 deletions docs/test_py_module/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""Test Module for sphinx_rtd_theme."""
import functools
import sys
from typing import Union


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

if sys.version_info >= (3, 8):

@functools.cached_property
def qux_caps_cached(self) -> str:
"""Return the cached value of instance qux as uppercase."""
return self.qux_caps
@functools.cached_property
def qux_caps_cached(self) -> str:
"""Return the cached value of instance qux as uppercase."""
return self.qux_caps


def func(long: int, param: str, args: None, flags: bool, lists: Union[list, tuple]):
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"check_lf",
]

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


@nox.session
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def run(self):
],
"sphinx_immaterial.apidoc.cpp.cppreference_data": ["*.xml"],
},
python_requires=">=3.8",
python_requires=">=3.9",
install_requires=REQUIREMENTS,
use_scm_version={
# It would be nice to include the commit hash in the version, but that
Expand Down
42 changes: 2 additions & 40 deletions sphinx_immaterial/apidoc/python/type_annotation_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ast
import functools
import re
import sys
from typing import (
cast,
Dict,
Expand All @@ -23,30 +22,6 @@
import sphinx.environment
import sphinx.util.logging

# `ast.unparse` added in Python 3.9
if sys.version_info >= (3, 9):
from ast import unparse as ast_unparse
else:
from sphinx.pycode.ast import unparse as ast_unparse
from sphinx.pycode.ast import _UnparseVisitor

def _monkey_patch_sphinx_ast_unparse():
"""Monkey patch Sphinx's `ast_unparse`.
This adds support for some additional ast nodes that we require.
"""

def visit_Module(self: _UnparseVisitor, node: ast.Module) -> str:
return "\n".join(self.visit(el) for el in node.body)

def visit_Expr(self: _UnparseVisitor, node: ast.Expr) -> str:
return self.visit(node.value)

_UnparseVisitor.visit_Module = visit_Module # type: ignore[assignment]
_UnparseVisitor.visit_Expr = visit_Expr # type: ignore[assignment]

_monkey_patch_sphinx_ast_unparse()

logger = sphinx.util.logging.getLogger(__name__)

PEP585_ALIASES = {
Expand Down Expand Up @@ -128,19 +103,6 @@ def _dotted_name_to_ast(
return tree


if sys.version_info < (3, 8):
_CONSTANT_AST_NODE_TYPES = (
ast.Constant,
ast.Num,
ast.Str,
ast.Bytes,
ast.Ellipsis,
ast.NameConstant,
)
else:
_CONSTANT_AST_NODE_TYPES = (ast.Constant,)


_CONFIG_ATTR = "_sphinx_immaterial_python_type_transform_config"


Expand Down Expand Up @@ -173,7 +135,7 @@ def _retain_explicit_literal(node: ast.AST) -> bool:
Since constants cannot be types, there is no ambiguity.
"""
return not isinstance(node, _CONSTANT_AST_NODE_TYPES)
return not isinstance(node, ast.Constant)


class TypeAnnotationTransformer(ast.NodeTransformer):
Expand Down Expand Up @@ -266,7 +228,7 @@ def _parse_annotation(annotation: str, env: sphinx.environment.BuildEnvironment)
transformer = TypeAnnotationTransformer()
transformer.config = cast(TypeTransformConfig, transformer_config)
tree = ast.fix_missing_locations(transformer.visit(tree))
annotation = ast_unparse(tree)
annotation = ast.unparse(tree)
return orig_parse_annotation(annotation, env)

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

0 comments on commit d50317c

Please sign in to comment.