Skip to content

Commit 909a56b

Browse files
maint: update tooling, cleanup and drop python 3.9 (#484)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent f7f7252 commit 909a56b

File tree

16 files changed

+103
-115
lines changed

16 files changed

+103
-115
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
fail-fast: false
9898
matrix:
9999
os: [ubuntu-latest, windows-latest, macos-latest]
100-
python-version: ['3.9', '3.10', '3.11', '3.12']
100+
python-version: ['3.10', '3.11', '3.12']
101101
should-release:
102102
- ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
103103
exclude:

.pre-commit-config.yaml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 24.8.0
4-
hooks:
5-
- id: black
6-
7-
- repo: https://github.com/pycqa/isort
8-
rev: 5.13.2
9-
hooks:
10-
- id: isort
112

12-
- repo: https://github.com/PyCQA/flake8
13-
rev: 7.1.1
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.6.2
145
hooks:
15-
- id: flake8
6+
- id: ruff
7+
args: [--fix]
8+
- id: ruff-format
169

1710
- repo: https://github.com/codespell-project/codespell
1811
rev: v2.3.0
1912
hooks:
2013
- id: codespell
2114

22-
- repo: https://github.com/pycqa/pydocstyle
23-
rev: 6.3.0
24-
hooks:
25-
- id: pydocstyle
26-
additional_dependencies: [toml]
27-
2815
- repo: https://github.com/pre-commit/mirrors-prettier
2916
rev: 'v4.0.0-alpha.8'
3017
hooks:
@@ -41,18 +28,10 @@ repos:
4128

4229
# this validates our github workflow files
4330
- repo: https://github.com/python-jsonschema/check-jsonschema
44-
rev: 0.29.1
31+
rev: 0.29.2
4532
hooks:
4633
- id: check-github-workflows
4734

48-
49-
- repo: https://github.com/adamchainz/blacken-docs
50-
rev: 1.18.0
51-
hooks:
52-
- id: blacken-docs
53-
additional_dependencies: [black==24.4.2]
54-
exclude: 'src/ansys_sphinx_theme/theme/ansys_sphinx_theme/_templates/'
55-
5635
- repo: https://github.com/ansys/pre-commit-hooks
5736
rev: v0.4.3
5837
hooks:

README.rst

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Ansys Sphinx theme
66
:target: https://github.com/ansys
77
:alt: Ansys
88

9-
.. |python| image:: https://img.shields.io/badge/Python-%3E%3D3.9-blue
9+
.. |python| image:: https://img.shields.io/pypi/pyversions/ansys_sphinx_theme?logo=pypi
1010
:target: https://pypi.org/project/ansys-sphinx-theme/
1111
:alt: Python
1212

@@ -55,48 +55,25 @@ If you are new to using Sphinx, see `Sphinx Getting Started
5555

5656
Documentation and issues
5757
~~~~~~~~~~~~~~~~~~~~~~~~
58-
In addition to installation information, the
59-
`Ansys Sphinx theme documentation <https://sphinxdocs.ansys.com>`_
60-
provides information on how you can customize the theme. Because
61-
this documentation is created using this theme, viewing it is
62-
an easy way to preview the theme itself.
58+
Documentation for the latest stabe release of Ansys Sphinx theme is hosted at
59+
`Ansys Sphinx Theme documentation <https://sphinxdocs.ansys.com>`_.
60+
61+
The documentation has these sections:
62+
63+
- `Getting started <https://sphinxdocs.ansys.com/version/stable/getting_started.html>`_ : Learn
64+
how to install the theme and use it in your Sphinx project.
65+
- `User guide <https://sphinxdocs.ansys.com/version/stable/user_guide.html>`_ : Learn how to
66+
customize the theme and use its features.
67+
- `Examples <https://sphinxdocs.ansys.com/version/stable/examples.html>`_ : See examples of
68+
Sphinx components and how it renders with the Ansys Sphinx theme.
69+
- `Release notes <https://sphinxdocs.ansys.com/version/stable/changelog.html>`_ : See the
70+
changes in each release of the theme.
6371

6472
On the `Issues page <https://github.com/ansys/ansys-sphinx-theme/issues>`_
6573
for this repository, you can create issues to submit questions, report bugs,
6674
and request new features. To reach the PyAnsys support team, email
6775
6876

69-
Getting started
70-
~~~~~~~~~~~~~~~
71-
Install the ``ansys-sphinx-theme`` package with:
72-
73-
.. code::
74-
75-
python -m pip install ansys-sphinx-theme
76-
77-
Modify your Sphinx ``conf.py`` file to use ``html_theme =
78-
'ansys_sphinx_theme'``.
79-
80-
Development and contributions
81-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82-
If you want to contribute to the PyAnsys Sphinx theme, install
83-
the ``ansys-sphinx-theme`` package in development mode with::
84-
85-
git clone https://github.com/ansys/ansys-sphinx-theme.git
86-
python -m pip install -U pip tox
87-
tox -e style,doc
88-
89-
To simplify checks, this repository uses `pre-commit <https://pre-commit.com/>`_.
90-
You can optionally install and use this tool. For more information, see its
91-
`installation <https://pre-commit.com/#install>`_ and `usage
92-
<https://pre-commit.com/#usage>`_ documentation.
93-
94-
Before contributing to a PyAnsys library, see
95-
`Contributing <https://dev.docs.pyansys.com//how-to/contributing.html>`_
96-
in the *PyAnsys Developer's Guide* for overall guidance, paying particular
97-
attention to `How-to <https://dev.docs.pyansys.com//how-to/index.html>`_ for
98-
guidelines and best practices.
99-
10077
License
10178
~~~~~~~
10279
This theme is licensed under the `MIT License

doc/changelog.d/484.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
maint: update tooling, cleanup and drop python 3.9

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"examples/gallery-examples/*.ipynb",
147147
]
148148
rst_epilog = ""
149-
with open("links.rst") as f:
149+
with Path.open(THIS_PATH / "links.rst", "r") as f:
150150
rst_epilog += f.read()
151151

152152
sphinx_gallery_conf = {
@@ -234,7 +234,7 @@ def download_and_process_files(example_links: List[str]) -> List[str]:
234234
for link in example_links:
235235
file_name = link.split("/")[-1]
236236
file_path = str((EXAMPLE_PATH / file_name).absolute())
237-
with open(file_path, "wb") as f:
237+
with open(file_path, "wb") as f: # noqa: PTH123
238238
response = requests.get(link)
239239
content = response.content.decode()
240240
lines = content.splitlines()

doc/source/examples/nbsphinx/jupyter-notebook.ipynb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"source": [
2424
"import pyvista as pv\n",
2525
"\n",
26-
"pv.set_jupyter_backend('html')\n",
26+
"pv.set_jupyter_backend(\"html\")\n",
2727
"\n",
2828
"sphere = pv.Sphere()\n",
2929
"sphere.plot()"
@@ -36,8 +36,8 @@
3636
"outputs": [],
3737
"source": [
3838
"plotter = pv.Plotter(notebook=True)\n",
39-
"plotter.add_mesh(sphere, color='white', show_edges=True)\n",
40-
"plotter.title = '3D Sphere Visualization'\n",
39+
"plotter.add_mesh(sphere, color=\"white\", show_edges=True)\n",
40+
"plotter.title = \"3D Sphere Visualization\"\n",
4141
"plotter.show()"
4242
]
4343
},
@@ -55,7 +55,8 @@
5555
"outputs": [],
5656
"source": [
5757
"from IPython.display import Math\n",
58-
"eq = Math(r'\\int\\limits_{-\\infty}^\\infty f(x) \\delta(x - x_0) dx = f(x_0)')\n",
58+
"\n",
59+
"eq = Math(r\"\\int\\limits_{-\\infty}^\\infty f(x) \\delta(x - x_0) dx = f(x_0)\")\n",
5960
"eq"
6061
]
6162
},
@@ -66,7 +67,8 @@
6667
"outputs": [],
6768
"source": [
6869
"from IPython.display import Latex\n",
69-
"Latex(r'This is a \\LaTeX{} equation: $a^2 + b^2 = c^2$')"
70+
"\n",
71+
"Latex(r\"This is a \\LaTeX{} equation: $a^2 + b^2 = c^2$\")"
7072
]
7173
},
7274
{
@@ -107,9 +109,9 @@
107109
"\n",
108110
"# Create a dictionary of data\n",
109111
"data = {\n",
110-
" 'A': [True, False, True, False],\n",
111-
" 'B': [False, True, False, True],\n",
112-
" 'C': [True, True, False, False],\n",
112+
" \"A\": [True, False, True, False],\n",
113+
" \"B\": [False, True, False, True],\n",
114+
" \"C\": [True, True, False, False],\n",
113115
"}\n",
114116
"\n",
115117
"# Create DataFrame from the dictionary\n",

doc/source/examples/snippet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def func(arg1, arg2):
4848
4949
Examples
5050
--------
51-
>>> func(1, 'foo')
51+
>>> func(1, "foo")
5252
True
5353
5454
"""

pyproject.toml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "ansys-sphinx-theme"
88
version = "1.1.dev0"
99
description = "A theme devised by ANSYS, Inc. for Sphinx documentation."
1010
readme = "README.rst"
11-
requires-python = ">=3.9,<4"
11+
requires-python = ">=3.10,<4"
1212
license = {file = "LICENSE"}
1313
authors = [{ name = "ANSYS, Inc.", email = "[email protected]" }]
1414
maintainers = [{ name = "ANSYS, Inc.", email = "[email protected]" }]
@@ -18,7 +18,9 @@ classifiers = [
1818
"Framework :: Sphinx :: Theme",
1919
"License :: OSI Approved :: MIT License",
2020
"Operating System :: OS Independent",
21-
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
2224
]
2325
dependencies = [
2426
"Sphinx>=4.2.0",
@@ -74,14 +76,39 @@ Source = "https://github.com/ansys/ansys-sphinx-theme"
7476
Tracker = "https://github.com/ansys/ansys-sphinx-theme/issues"
7577
Documentation = "https://sphinxdocs.ansys.com/"
7678

77-
[tool.black]
79+
[tool.ruff]
7880
line-length = 100
81+
fix = true
82+
83+
[tool.ruff.format]
84+
quote-style = "double"
85+
indent-style = "space"
86+
87+
[tool.ruff.lint]
88+
select = [
89+
"E", # pycodestyle, see https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
90+
"D", # pydocstyle, see https://docs.astral.sh/ruff/rules/#pydocstyle-d
91+
"F", # pyflakes, see https://docs.astral.sh/ruff/rules/#pyflakes-f
92+
"I", # isort, see https://docs.astral.sh/ruff/rules/#isort-i
93+
"N", # pep8-naming, see https://docs.astral.sh/ruff/rules/#pep8-naming-n
94+
"PTH", # flake8-use-pathlib, https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
95+
"TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td
96+
]
97+
ignore = [
98+
"TD002", # Missing author in TODOs comment
99+
]
100+
101+
[tool.ruff.lint.per-file-ignores]
102+
"__init__.py" = ["F401"]
103+
"doc/source/examples/sphinx-gallery/sphinx-gallery.py" = ["D205", "E402", "D400"]
104+
"src/ansys_sphinx_theme/extension/linkcode.py" = ["E501"]
79105

80-
[tool.isort]
81-
profile = "black"
82-
force_sort_within_sections = true
83-
line_length = 100
84-
src_paths = ["doc", "src"]
106+
[tool.ruff.lint.pydocstyle]
107+
convention = "numpy"
108+
109+
[tool.ruff.lint.isort]
110+
combine-as-imports = true
111+
force-sort-within-sections = true
85112

86113
[tool.coverage.run]
87114
source = ["src"]
@@ -122,8 +149,6 @@ directory = "miscellaneous"
122149
name = "Miscellaneous"
123150
showcontent = true
124151

125-
126-
127152
[[tool.towncrier.type]]
128153
directory = "documentation"
129154
name = "Documentation"

src/ansys_sphinx_theme/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
"""This is the ansys-sphinx-theme module."""
23+
"""Module for the Ansys Sphinx theme."""
24+
2425
import logging
2526
import os
2627
import pathlib
@@ -341,9 +342,9 @@ def replace_html_tag(app, exception):
341342

342343
file_names = list(api_path.rglob("*.html"))
343344
for file_name in file_names:
344-
with open(api_dir / file_name, "r", encoding="utf-8") as file:
345+
with pathlib.Path.open(api_dir / file_name, "r", encoding="utf-8") as file:
345346
content = file.read()
346-
with open(api_dir / file_name, "w", encoding="utf-8") as file:
347+
with pathlib.Path.open(api_dir / file_name, "w", encoding="utf-8") as file:
347348
modified_content = content.replace("&lt;", "<").replace("&gt;", ">")
348349
file.write(modified_content)
349350

@@ -472,7 +473,7 @@ def build_quarto_cheatsheet(app: Sphinx):
472473
output_dir_path = pathlib.Path(app.outdir) / output_dir
473474
try:
474475
# Add the cheatsheet to the Quarto project
475-
result = subprocess.run(
476+
subprocess.run(
476477
[
477478
"quarto",
478479
"add",
@@ -485,7 +486,7 @@ def build_quarto_cheatsheet(app: Sphinx):
485486
)
486487

487488
# Render the cheatsheet
488-
render_result = subprocess.run(
489+
subprocess.run(
489490
[
490491
"quarto",
491492
"render",
@@ -501,7 +502,7 @@ def build_quarto_cheatsheet(app: Sphinx):
501502
)
502503

503504
# Remove the cheatsheet from the Quarto project
504-
remove_extension = subprocess.run(
505+
subprocess.run(
505506
["quarto", "remove", "ansys/cheat_sheet", "--no-prompt"],
506507
cwd=file_path,
507508
capture_output=True,

src/ansys_sphinx_theme/examples/sample_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def func(arg1, arg2):
4848
4949
Examples
5050
--------
51-
>>> func(1, 'foo')
51+
>>> func(1, "foo")
5252
True
5353
5454
"""

0 commit comments

Comments
 (0)