Skip to content

Commit

Permalink
⬆️ Python v3.9-3.12 (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored May 18, 2024
1 parent e1acce2 commit 3dd92ac
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 60 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: pre-commit/[email protected].0
python-version: 3.9
- uses: pre-commit/[email protected].1

tests:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
sphinx-version: ["~=7.0"]
include:
- os: ubuntu-latest
python-version: 3.8
python-version: 3.9
sphinx-version: "~=5.0"
- os: ubuntu-latest
python-version: 3.8
python-version: 3.9
sphinx-version: "~=6.0"
- os: windows-latest
python-version: 3.8
python-version: 3.9
sphinx-version: "~=7.0"

runs-on: ${{ matrix.os }}
Expand All @@ -57,7 +57,7 @@ jobs:
run: |
pytest --cov=sphinx_design --cov-report=xml --cov-report=term-missing
- name: Upload to Codecov
if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: install flit
run: |
pip install flit~=3.4
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"

python:
install:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
"Topic :: Text Processing :: Markup :: Markdown",
"Topic :: Text Processing :: Markup :: reStructuredText",
]
keywords = ["sphinx", "extension", "material design", "web components"]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = ["sphinx>=5,<8"]

[project.urls]
Expand Down
3 changes: 2 additions & 1 deletion sphinx_design/_compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Helpers for cross compatibility across dependency versions."""

from collections.abc import Iterable
from importlib import resources
from typing import Callable, Iterable
from typing import Callable

from docutils.nodes import Element

Expand Down
4 changes: 2 additions & 2 deletions sphinx_design/article_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -48,7 +48,7 @@ def _parse_text(
output = [para]
return output

def run(self) -> List[nodes.Node]: # noqa: PLR0915
def run(self) -> list[nodes.Node]: # noqa: PLR0915
"""Run the directive."""
parse_fields = True # parse field text

Expand Down
18 changes: 9 additions & 9 deletions sphinx_design/badges_buttons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Tuple
from typing import Optional

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -45,7 +45,7 @@ def setup_badges_and_buttons(app: Sphinx) -> None:
app.add_directive(DIRECTIVE_NAME_BUTTON_REF, ButtonRefDirective)


def create_bdg_classes(color: Optional[str], outline: bool) -> List[str]:
def create_bdg_classes(color: Optional[str], outline: bool) -> list[str]:
"""Create the badge classes."""
classes = [
"sd-sphinx-override",
Expand All @@ -68,7 +68,7 @@ def __init__(self, color: Optional[str] = None, *, outline: bool = False) -> Non
self.color = color
self.outline = outline

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
node = nodes.inline(
self.rawtext,
Expand All @@ -87,7 +87,7 @@ def __init__(self, color: Optional[str] = None, *, outline: bool = False) -> Non
self.color = color
self.outline = outline

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
node = nodes.reference(
self.rawtext,
Expand All @@ -110,7 +110,7 @@ def __init__(self, color: Optional[str] = None, *, outline: bool = False) -> Non
self.color = color
self.outline = outline

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
options = {
"classes": create_bdg_classes(self.color, self.outline),
Expand Down Expand Up @@ -150,12 +150,12 @@ class _ButtonDirective(SphinxDirective):
}

def create_ref_node(
self, rawtext: str, target: str, explicit_title: bool, classes: List[str]
self, rawtext: str, target: str, explicit_title: bool, classes: list[str]
) -> nodes.Node:
"""Create the reference node."""
raise NotImplementedError

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
rawtext = self.arguments[0]
target = directives.uri(rawtext)
Expand Down Expand Up @@ -205,7 +205,7 @@ class ButtonLinkDirective(_ButtonDirective):
"""A button directive with an external link."""

def create_ref_node(
self, rawtext: str, target: str, explicit_title: bool, classes: List[str]
self, rawtext: str, target: str, explicit_title: bool, classes: list[str]
) -> nodes.Node:
"""Create the reference node."""
return nodes.reference(
Expand All @@ -219,7 +219,7 @@ class ButtonRefDirective(_ButtonDirective):
"""A button directive with an internal link."""

def create_ref_node(
self, rawtext: str, target: str, explicit_title: bool, classes: List[str]
self, rawtext: str, target: str, explicit_title: bool, classes: list[str]
) -> nodes.Node:
"""Create the reference node."""
ref_type = self.options.get("ref-type", "any")
Expand Down
12 changes: 6 additions & 6 deletions sphinx_design/cards.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import List, NamedTuple, Optional, Tuple
from typing import NamedTuple, Optional

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -40,9 +40,9 @@ class CardContent(NamedTuple):
(offset, content)
"""

body: Tuple[int, StringList]
header: Optional[Tuple[int, StringList]] = None
footer: Optional[Tuple[int, StringList]] = None
body: tuple[int, StringList]
header: Optional[tuple[int, StringList]] = None
footer: Optional[tuple[int, StringList]] = None


class CardDirective(SphinxDirective):
Expand Down Expand Up @@ -73,7 +73,7 @@ class CardDirective(SphinxDirective):
"class-img-bottom": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
return [self.create_card(self, self.arguments, self.options)]

@classmethod
Expand Down Expand Up @@ -266,7 +266,7 @@ class CardCarouselDirective(SphinxDirective):
"class": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
self.assert_has_content()
try:
Expand Down
16 changes: 8 additions & 8 deletions sphinx_design/grids.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -39,7 +39,7 @@ def _media_option(
allow_auto: bool = False,
min_num: int = 1,
max_num: int = 12,
) -> List[str]:
) -> list[str]:
"""Validate the number of columns (out of 12).
One or four integers (for "xs sm md lg") between 1 and 12.
Expand Down Expand Up @@ -70,23 +70,23 @@ def _media_option(
]


def row_columns_option(argument: Optional[str]) -> List[str]:
def row_columns_option(argument: Optional[str]) -> list[str]:
"""Validate the number of columns (out of 12) a grid row will have.
One or four integers (for "xs sm md lg") between 1 and 12 (or 'auto').
"""
return _media_option(argument, "sd-row-cols-", allow_auto=True)


def item_columns_option(argument: Optional[str]) -> List[str]:
def item_columns_option(argument: Optional[str]) -> list[str]:
"""Validate the number of columns (out of 12) a grid-item will take up.
One or four integers (for "xs sm md lg") between 1 and 12 (or 'auto').
"""
return _media_option(argument, "sd-col-", allow_auto=True)


def gutter_option(argument: Optional[str]) -> List[str]:
def gutter_option(argument: Optional[str]) -> list[str]:
"""Validate the gutter size between grid items.
One or four integers (for "xs sm md lg") between 0 and 5.
Expand All @@ -111,7 +111,7 @@ class GridDirective(SphinxDirective):
"class-row": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
try:
column_classes = (
Expand Down Expand Up @@ -174,7 +174,7 @@ class GridItemDirective(SphinxDirective):
"class": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
if not is_component(self.state_machine.node, "grid-row"):
LOGGER.warning(
Expand Down Expand Up @@ -237,7 +237,7 @@ class GridItemCardDirective(SphinxDirective):
"class-img-bottom": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
if not is_component(self.state_machine.node, "grid-row"):
LOGGER.warning(
Expand Down
17 changes: 9 additions & 8 deletions sphinx_design/icons.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from collections.abc import Sequence
from functools import lru_cache
import json
import re
from typing import Any, Dict, List, Optional, Sequence, Tuple
from typing import Any, Optional

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -46,13 +47,13 @@ def setup_icons(app: Sphinx) -> None:


@lru_cache(1)
def get_octicon_data() -> Dict[str, Any]:
def get_octicon_data() -> dict[str, Any]:
"""Load all octicon data."""
content = read_text(compiled, "octicons.json")
return json.loads(content)


def list_octicons() -> List[str]:
def list_octicons() -> list[str]:
"""List available octicon names."""
return list(get_octicon_data().keys())

Expand Down Expand Up @@ -120,7 +121,7 @@ class OcticonRole(SphinxRole):
Additional classes can be added to the element after a semicolon.
"""

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
values = self.text.split(";") if ";" in self.text else [self.text]
icon = values[0]
Expand Down Expand Up @@ -151,7 +152,7 @@ class AllOcticons(SphinxDirective):
"class": directives.class_option,
}

def run(self) -> List[nodes.Node]:
def run(self) -> list[nodes.Node]:
"""Run the directive."""
classes = self.options.get("class", [])
list_node = nodes.bullet_list()
Expand Down Expand Up @@ -186,7 +187,7 @@ def __init__(self, style: str) -> None:
super().__init__()
self.style = style

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
icon, classes = self.text.split(";", 1) if ";" in self.text else [self.text, ""]
icon = icon.strip()
Expand Down Expand Up @@ -238,7 +239,7 @@ def visit_fontawesome_warning(self, node: nodes.Element) -> None:


@lru_cache(1)
def get_material_icon_data(style: str) -> Dict[str, Any]:
def get_material_icon_data(style: str) -> dict[str, Any]:
"""Load all octicon data."""
content = read_text(compiled, f"material_{style}.json")
return json.loads(content)
Expand Down Expand Up @@ -309,7 +310,7 @@ def __init__(self, style: str) -> None:
super().__init__()
self.style = style

def run(self) -> Tuple[List[nodes.Node], List[nodes.system_message]]:
def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Run the role."""
values = self.text.split(";") if ";" in self.text else [self.text]
icon = values[0]
Expand Down
Loading

0 comments on commit 3dd92ac

Please sign in to comment.