Skip to content

Commit 97f22f6

Browse files
authored
Merge pull request #80 from braingram/pyproject_toml
Convert setup.cfg to pyproject.toml, update tools
2 parents d81d949 + 461f57d commit 97f22f6

File tree

14 files changed

+151
-117
lines changed

14 files changed

+151
-117
lines changed

.github/workflows/sphinx_asdf_ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ on:
99
pull_request:
1010
branches:
1111

12+
# Only cancel in-progress jobs or runs for the current workflow
13+
# This cancels the already triggered workflows for a specific PR without canceling
14+
# other instances of this workflow (other PRs, scheduled triggers, etc) when something
15+
# within that PR re-triggers this CI
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
1220
jobs:
1321
tox_pytest:
1422
name: ${{ matrix.name }}
1523
runs-on: ${{ matrix.os }}
1624
strategy:
1725
matrix:
1826
include:
27+
- name: Python 3.12 Tests
28+
python-version: "3.12-dev"
29+
os: ubuntu-latest
30+
toxenv: py312
31+
1932
- name: Python 3.11 Tests
2033
python-version: "3.11"
2134
os: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,58 @@ repos:
44
rev: v4.4.0
55
hooks:
66
- id: check-added-large-files
7+
- id: check-ast
78
- id: check-case-conflict
89
- id: check-yaml
910
args: ["--unsafe"]
11+
- id: check-toml
12+
- id: check-merge-conflict
13+
- id: check-symlinks
1014
- id: debug-statements
15+
- id: detect-private-key
1116
- id: end-of-file-fixer
1217
- id: trailing-whitespace
1318

14-
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.13.0
19+
- repo: https://github.com/pre-commit/pygrep-hooks
20+
rev: v1.10.0
1621
hooks:
17-
- id: pyupgrade
18-
args: ["--py38-plus"]
22+
- id: python-check-blanket-noqa
23+
- id: python-check-mock-methods
24+
- id: rst-directive-colons
25+
- id: rst-inline-touching-normal
26+
- id: text-unicode-replacement-char
1927

20-
- repo: https://github.com/pycqa/isort
21-
rev: 5.12.0
28+
- repo: https://github.com/codespell-project/codespell
29+
rev: v2.2.5
2230
hooks:
23-
- id: isort
31+
- id: codespell
32+
args: ["--write-changes"]
33+
additional_dependencies:
34+
- tomli
35+
36+
- repo: https://github.com/ikamensh/flynt/
37+
rev: '1.0.1'
38+
hooks:
39+
- id: flynt
40+
exclude: "asdf/(extern||_jsonschema)/.*"
41+
42+
- repo: https://github.com/astral-sh/ruff-pre-commit
43+
rev: 'v0.0.288'
44+
hooks:
45+
- id: ruff
46+
args: ["--fix"]
2447

2548
- repo: https://github.com/psf/black
2649
rev: 23.9.1
2750
hooks:
2851
- id: black
2952

30-
- repo: https://github.com/PyCQA/flake8
31-
rev: 6.1.0
53+
- repo: https://github.com/asottile/blacken-docs
54+
rev: '1.16.0'
3255
hooks:
33-
- id: flake8
56+
- id: blacken-docs
3457

35-
- repo: https://github.com/PyCQA/bandit
36-
rev: 1.7.5
58+
- repo: https://github.com/abravalheri/validate-pyproject
59+
rev: "v0.14"
3760
hooks:
38-
- id: bandit
39-
args: ["-c", "bandit.yaml"]
61+
- id: validate-pyproject

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ resolved as links, include the following in your ``docs/conf.py`` file:
171171
.. code-block:: python
172172
173173
asdf_schema_reference_mappings = [
174-
('tag:stsci.edu:asdf',
175-
'http://asdf-standard.readthedocs.io/en/latest/generated/stsci.edu/asdf/'),
174+
(
175+
"tag:stsci.edu:asdf",
176+
"http://asdf-standard.readthedocs.io/en/latest/generated/stsci.edu/asdf/",
177+
),
176178
]
177179
178180
Inline documentation

bandit.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

pyproject.toml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
[project]
2+
name = "sphinx-asdf"
3+
description = "Sphinx plugin for generating documentation from ASDF schemas"
4+
readme = 'README.rst'
5+
license = { file = 'LICENSE' }
6+
authors = [{ name = 'The ASDF Developers', email = 'help@stsci.edu' }]
7+
requires-python = '>=3.9'
8+
classifiers = [
9+
'Development Status :: 5 - Production/Stable',
10+
"License :: OSI Approved :: BSD License",
11+
'Programming Language :: Python',
12+
'Programming Language :: Python :: 3',
13+
'Programming Language :: Python :: 3.9',
14+
'Programming Language :: Python :: 3.10',
15+
'Programming Language :: Python :: 3.11',
16+
'Programming Language :: Python :: 3.12',
17+
]
18+
dynamic = [
19+
'version',
20+
]
21+
dependencies = [
22+
"asdf",
23+
"astropy>=5.0.4",
24+
"docutils",
25+
"mistune>=3",
26+
"packaging",
27+
"sphinx",
28+
"sphinx-astropy",
29+
"sphinx_bootstrap_theme",
30+
"sphinx-rtd-theme",
31+
"toml",
32+
33+
]
34+
[project.optional-dependencies]
35+
tests = [
36+
"pytest",
37+
]
38+
[project.urls]
39+
'documentation' = 'https://sphinx-asdf.readthedocs.io/en/stable'
40+
'repository' = 'https://github.com/asdf-format/sphinx-asdf'
41+
'tracker' = 'https://github.com/asdf-format/sphinx-asdf/issues'
42+
43+
[tool.setuptools.packages.find]
44+
include = ['sphinx_asdf*']
45+
146
[build-system]
247
requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4", "wheel"]
348
build-backend = "setuptools.build_meta"
@@ -20,5 +65,26 @@ force-exclude = '''
2065

2166
[tool.isort]
2267
profile = "black"
23-
filter_files = true
24-
line_length = 120
68+
filter-files = true
69+
line-length = 120
70+
71+
[tool.ruff]
72+
target-version = "py38"
73+
line-length = 120
74+
select = [
75+
# minimal set to match pre-ruff behavior
76+
"E", # pycodestyle
77+
"F", # pyflakes, autoflake
78+
"I", # isort
79+
"S", # bandit
80+
"UP", # pyupgrade
81+
"RUF", # ruff specific, includes yesqa
82+
]
83+
extend-ignore = [
84+
"F403", "F405", # uses if import * should be removed
85+
"S101", # asserts used in tests
86+
"RUF012", # we don't use typing
87+
]
88+
89+
[tool.codespell]
90+
skip="*.pdf,*.asdf,.tox,build,./tags,.git,docs/_build"

setup.cfg

Lines changed: 0 additions & 51 deletions
This file was deleted.

sphinx_asdf/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
22

3-
from sphinx.builders.html import StandaloneHTMLBuilder
4-
53
from .asdf2rst import AsdfDirective, RunCodeDirective
64
from .connections import (
75
add_labels_to_nodes,
@@ -10,7 +8,7 @@
108
on_build_finished,
119
update_app_config,
1210
)
13-
from .directives import AsdfAutoschemas, AsdfSchema, schema_def
11+
from .directives import AsdfAutoschemas, AsdfSchema
1412
from .nodes import add_asdf_nodes
1513

1614

sphinx_asdf/asdf2rst.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run(self):
2929

3030
try:
3131
try:
32-
exec(code, GLOBALS)
32+
exec(code, GLOBALS) # noqa: S102
3333
except Exception:
3434
print(code)
3535
raise
@@ -75,7 +75,7 @@ def _block_to_string(block):
7575
if header["flags"] & key:
7676
human_flags.append(val)
7777
if len(human_flags):
78-
lines.append(" flags: {}".format(" | ".join(human_flags)))
78+
lines.append(f" flags: {' | '.join(human_flags)}")
7979
if header["compression"] and header["compression"] != b"\0\0\0\0":
8080
lines.append(f" compression: {header['compression']}")
8181
lines.append(f" allocated_size: {header['allocated_size']}")
@@ -100,8 +100,8 @@ def run(self):
100100
cwd = os.getcwd()
101101
os.chdir(TMPDIR)
102102

103-
show_header = not ("no_header" in self.arguments)
104-
show_bocks = not ("no_blocks" in self.arguments)
103+
show_header = "no_header" not in self.arguments
104+
show_bocks = "no_blocks" not in self.arguments
105105

106106
parts = []
107107
try:

sphinx_asdf/conf.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import datetime
1+
# datetime is kept here as some downstream packages currently
2+
# expect it to be imported when this file is star imported
3+
import datetime # noqa: F401
24
import os
35
import sys
4-
from pathlib import Path
5-
6-
import numpy
7-
import toml
8-
9-
# Ensure documentation examples are determinstically random.
10-
try:
11-
numpy.random.seed(int(os.environ["SOURCE_DATE_EPOCH"]))
12-
except KeyError:
13-
pass
146

157
try:
168
from sphinx_astropy.conf.v1 import *

sphinx_asdf/connections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import os
33
import posixpath
4-
import warnings
54

65
import docutils
76
import packaging.version

0 commit comments

Comments
 (0)