Skip to content

Commit ed3f65f

Browse files
authored
Modernize (#69)
1 parent d90835b commit ed3f65f

30 files changed

+337
-301
lines changed

.editorconfig

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
root = true
22

3-
[*.py]
3+
[*]
44
charset = utf-8
5-
indent_size = 4
6-
indent_style = space
5+
end_of_line = lf
76
insert_final_newline = true
7+
trim_trailing_whitespace = true
88
max_line_length = 88
9+
indent_size = 4
10+
indent_style = space
11+
12+
[*.{yml,yaml}]
13+
indent_size = 2

.github/workflows/ci.yml

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ name: Python tests
44

55
on:
66
push:
7-
branches: [ master ]
7+
branches: [main]
88
pull_request:
9-
branches: [ master ]
9+
branches: [main]
1010

1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
16+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1717
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/setup-python@v2
20-
with:
21-
python-version: ${{ matrix.python-version }}
22-
- uses: actions/cache@v2
23-
with:
24-
path: |
25-
~/.cache/pip
26-
~/.cache/pre-commit
27-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
28-
- name: dependencies
29-
run: |
30-
pip install --upgrade pip wheel
31-
pip install .[test,typehints]
32-
- name: tests
33-
run: pytest --color=yes
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- uses: actions/cache@v2
23+
with:
24+
path: |
25+
~/.cache/pip
26+
~/.cache/pre-commit
27+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
28+
- name: dependencies
29+
run: |
30+
pip install --upgrade pip wheel
31+
pip install .[test,typehints]
32+
- name: tests
33+
run: pytest --color=yes

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Python
22
__pycache__/
3+
_version.py
34
/build/
45
/dist/
56

67
# Testing
7-
/.tox/
88
/.coverage
99
.pytest_cache/
1010

.pre-commit-config.yaml

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
4-
hooks:
5-
- id: trailing-whitespace
6-
- repo: https://github.com/psf/black
7-
rev: 23.3.0
8-
hooks:
9-
- id: black
10-
language_version: python3
11-
- repo: https://github.com/pycqa/isort
12-
rev: 5.12.0
13-
hooks:
14-
- id: isort
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- repo: https://github.com/psf/black
7+
rev: "23.3.0"
8+
hooks:
9+
- id: black
10+
language_version: python3
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.0.276
13+
hooks:
14+
- id: ruff
15+
args: ["--fix"]
16+
- repo: https://github.com/pre-commit/mirrors-prettier
17+
rev: v2.7.1
18+
hooks:
19+
- id: prettier

.prettierrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": ["settings.json", ".prettierrc"],
5+
"options": {
6+
"parser": "json5",
7+
"quoteProps": "preserve",
8+
"singleQuote": false,
9+
"trailingComma": "all",
10+
},
11+
},
12+
],
13+
}

.readthedocs.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
version: 2
22
build:
3-
image: latest
4-
sphinx:
5-
configuration: docs/conf.py
3+
os: ubuntu-22.04
4+
tools:
5+
python: "3.11"
66
python:
7-
version: 3.8
87
install:
9-
- method: pip
10-
path: .
11-
extra_requirements:
12-
- doc
8+
- method: pip
9+
path: .
10+
extra_requirements:
11+
- doc
12+
sphinx:
13+
configuration: docs/conf.py

.vscode/settings.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2-
"editor.formatOnSave": true,
3-
"python.formatting.provider": "black",
4-
"python.testing.pytestArgs": ["-v"],
5-
"python.testing.unittestEnabled": false,
6-
"python.testing.pytestEnabled": true
2+
"python.testing.pytestArgs": ["-v"],
3+
"python.testing.unittestEnabled": false,
4+
"python.testing.pytestEnabled": true,
5+
"[python]": {
6+
"editor.defaultFormatter": "ms-python.black-formatter",
7+
"editor.formatOnSave": true,
8+
"editor.codeActionsOnSave": {
9+
"source.fixAll": true,
10+
},
11+
},
712
}

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Check the self-documenting documentation at https://icb-scanpydoc.readthedocs-ho
1414
.. |tests| image:: https://github.com/theislab/scanpydoc/actions/workflows/ci.yml/badge.svg
1515
:target: https://github.com/theislab/scanpydoc/actions/workflows/ci.yml
1616
:alt: python test status
17-
.. |checks| image:: https://results.pre-commit.ci/badge/github/theislab/scanpydoc/master.svg
18-
:target: https://results.pre-commit.ci/latest/github/theislab/scanpydoc/master
17+
.. |checks| image:: https://results.pre-commit.ci/badge/github/theislab/scanpydoc/main.svg
18+
:target: https://results.pre-commit.ci/latest/github/theislab/scanpydoc/main
1919
:alt: pre-commit.ci status
20-
.. |cov| image:: https://codecov.io/gh/theislab/scanpydoc/branch/master/graph/badge.svg
20+
.. |cov| image:: https://codecov.io/gh/theislab/scanpydoc/branch/main/graph/badge.svg
2121
:target: https://codecov.io/gh/theislab/scanpydoc
2222
:alt: coverage

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
html_theme = "scanpydoc"
5656
html_context = dict(
57-
github_user="theislab", github_repo="scanpydoc", github_version="master"
57+
github_user="theislab", github_repo="scanpydoc", github_version="main"
5858
)
5959

6060
# proj/doc/conf.py/../.. → proj

pyproject.toml

+50-36
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
1-
[build-system]
2-
requires = ['flit_core >=2,<4']
3-
build-backend = 'flit_core.buildapi'
4-
5-
[tool.flit.metadata]
6-
module = 'scanpydoc'
7-
author = 'Philipp Angerer'
8-
author-email = 'phil.angerer@gmail.com'
9-
home-page = 'https://github.com/theislab/scanpydoc/'
10-
urls = { Documentation = 'https://icb-scanpydoc.readthedocs-hosted.com/' }
11-
description-file = 'README.rst'
1+
[project]
2+
name = 'scanpydoc'
3+
dynamic = ['version']
4+
description = 'A series of Sphinx extensions to get maintainable numpydoc style documentation.'
5+
authors = [
6+
{ name = 'Philipp Angerer', email = '[email protected]' },
7+
]
8+
urls.Source = 'https://github.com/theislab/scanpydoc/'
9+
urls.Documentation = 'https://icb-scanpydoc.readthedocs-hosted.com/'
10+
readme = 'README.rst'
11+
license = 'GPL-3.0-or-later'
1212
classifiers = [
1313
'Intended Audience :: Developers',
14-
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
1514
'Programming Language :: Python :: 3',
1615
'Topic :: Documentation :: Sphinx',
1716
'Topic :: Software Development :: Libraries :: Python Modules',
1817
'Framework :: Sphinx :: Extension',
1918
]
20-
requires-python = '>=3.7'
21-
requires = [
19+
requires-python = '>=3.8.1'
20+
dependencies = [
2221
'sphinx>=3.0',
23-
'get_version',
2422
]
2523

26-
[tool.flit.metadata.requires-extra]
24+
[project.optional-dependencies]
2725
dev = [
2826
'pre-commit',
2927
]
3028
test = [
3129
'pytest',
3230
'pytest-cov',
33-
'typing_extensions>=3.10; python_version<"3.8"',
3431
]
3532
doc = [
3633
'scanpydoc[typehints]',
@@ -39,27 +36,44 @@ doc = [
3936
typehints = ['sphinx-autodoc-typehints>=1.15.2']
4037
theme = ['sphinx-rtd-theme']
4138

42-
[tool.flit.entrypoints.'sphinx.html_themes']
39+
[project.entry-points.'sphinx.html_themes']
4340
scanpydoc = 'scanpydoc.theme'
4441

45-
[tool.black]
46-
target-version = ['py37']
42+
[tool.ruff]
43+
select = [
44+
'E', 'W', # Pycodestyle
45+
'F', # Pyflakes
46+
'I', # isort
47+
'UP', # Pyupgrade
48+
'RUF', # Ruff’s own rules
49+
]
50+
allowed-confusables = ['', '×', 'l']
51+
ignore = [
52+
'E741', # Ambiguous variable name
53+
]
4754

48-
[tool.isort]
49-
profile = 'black'
50-
lines_after_imports = 2
51-
multi_line_output = 3
55+
[tool.ruff.isort]
56+
lines-after-imports = 2
57+
known-first-party = ['scanpydoc']
5258

53-
[tool.tox]
54-
legacy_tox_ini = """
55-
[tox]
56-
envlist = py37,py38,py39
57-
skipsdist = True
59+
[tool.hatch.version]
60+
source = 'vcs'
61+
[tool.hatch.build.hooks.vcs]
62+
version-file = 'src/scanpydoc/_version.py'
5863

59-
[testenv]
60-
deps =
61-
flit
62-
commands =
63-
flit install
64-
pytest
65-
"""
64+
[[tool.hatch.envs.test.matrix]]
65+
python = ['3.8', '3.9', '3.10', '3.11']
66+
[tool.hatch.envs.test]
67+
features = ['test', 'typehints']
68+
[tool.hatch.envs.test.scripts]
69+
test = 'pytest -vv'
70+
71+
[tool.pytest.ini_options]
72+
addopts = [
73+
'--import-mode=importlib',
74+
'-psphinx.testing.fixtures',
75+
]
76+
77+
[build-system]
78+
requires = ['hatchling', 'hatch-vcs']
79+
build-backend = 'hatchling.build'

scanpydoc/elegant_typehints/static/typehints.css

-2
This file was deleted.

scanpydoc/theme/layout.html

-40
This file was deleted.

scanpydoc/__init__.py renamed to src/scanpydoc/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
"""A series of Sphinx extensions to get easy to maintain, numpydoc style documentation.
1+
"""A series of Sphinx extensions to get maintainable numpydoc style documentation.
22
33
This module is also an extension itself which simply sets up all included extensions.
44
"""
5+
from __future__ import annotations
6+
57
from textwrap import indent
6-
from typing import Any, Dict
8+
from typing import Any
79

8-
from get_version import get_version
910
from sphinx.application import Sphinx
1011

12+
from ._version import __version__
1113

12-
__version__ = get_version(__file__, vcs="git")
1314

1415
metadata = dict(version=__version__, env_version=1, parallel_read_safe=True)
1516

@@ -30,8 +31,8 @@ def _setup_sig(fn):
3031

3132

3233
@_setup_sig
33-
def setup(app: Sphinx) -> Dict[str, Any]:
34-
"""Set up all included extensions!"""
34+
def setup(app: Sphinx) -> dict[str, Any]:
35+
"""Set up all included extensions!."""
3536
app.setup_extension("scanpydoc.autosummary_generate_imported")
3637
app.setup_extension("scanpydoc.definition_list_typed_field")
3738
app.setup_extension("scanpydoc.elegant_typehints")

0 commit comments

Comments
 (0)