Skip to content

Commit 3e8baa6

Browse files
authored
πŸ€– dprint (#45)
* βž• add `dprint` as development dependency * πŸ”§ configure `dprint` * πŸ§‘β€πŸ’» create a `dprint` job for `lefthook` * πŸ‘· run `dprint` in CI * πŸ€– `uv run dprint fmt` * πŸ™ˆ prevent `dprint fmt` from messing up the doctest
1 parent 3957234 commit 3e8baa6

File tree

7 files changed

+187
-145
lines changed

7 files changed

+187
-145
lines changed

β€Ž.dprint.jsonc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"json": {
3+
"lineWidth": 88,
4+
"array.preferSingleLine": true,
5+
},
6+
"markdown": {
7+
"lineWidth": 88,
8+
"emphasisKind": "asterisks",
9+
},
10+
"yaml": {
11+
"printWidth": 88,
12+
"formatComments": true,
13+
"braceSpacing": false,
14+
},
15+
"excludes": ["**/*-lock.json", "**/*.lock", "**/node_modules/", "dist/"],
16+
"plugins": [
17+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
18+
"https://plugins.dprint.dev/json-0.20.0.wasm",
19+
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
20+
"https://plugins.dprint.dev/toml-0.7.0.wasm",
21+
],
22+
}

β€Ž.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2626

27+
- name: dprint
28+
uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3
29+
2730
- name: Install uv
2831
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
2932

β€ŽREADME.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
> for working with the [Python array API standard](https://data-apis.org/array-api/latest/), but it
99
> may change significantly in the future.
1010
11-
1211
## Installation
1312

1413
```bash
@@ -45,6 +44,7 @@ pip install -e . # editable mode
4544

4645
### Quick example
4746

47+
<!-- dprint-ignore-start -->
4848
```pycon
4949
>>> import array_api_typing as xpt
5050
>>> import numpy as np
@@ -56,3 +56,4 @@ pip install -e . # editable mode
5656
array([1, 2, 3])
5757

5858
```
59+
<!-- dprint-ignore-end -->

β€Žlefthook.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ templates:
77
pre-commit:
88
parallel: true
99
jobs:
10+
- name: dprint
11+
glob: "*.{json,jsonc,md,toml,yaml,yml}"
12+
stage_fixed: true
13+
run: uv {run} dprint fmt --incremental=false
1014
- name: ruff
1115
glob: "*.{py,pyi}"
1216
stage_fixed: true

β€Žpyproject.toml

Lines changed: 131 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,152 @@
11
[project]
2-
name = "array-api-typing"
3-
dynamic = ["version"]
4-
description = "Static typing support for the array API standard"
5-
readme = "README.md"
6-
requires-python = ">=3.10"
7-
license = "MIT"
8-
authors = [
9-
{ name = "Consortium for Python Data API Standards", email = "[email protected]" },
10-
{ name = "Joren Hammudoglu", email = "[email protected]" },
11-
{ name = "Nathaniel Starkman", email = "[email protected]" },
12-
]
13-
classifiers = [
14-
"Development Status :: 1 - Planning",
15-
"Intended Audience :: Developers",
16-
"License :: OSI Approved :: MIT License",
17-
"Operating System :: OS Independent",
18-
"Programming Language :: Python :: 3 :: Only",
19-
"Programming Language :: Python :: 3",
20-
"Programming Language :: Python :: 3.10",
21-
"Programming Language :: Python :: 3.11",
22-
"Programming Language :: Python :: 3.12",
23-
"Programming Language :: Python :: 3.13",
24-
"Programming Language :: Python",
25-
"Topic :: Scientific/Engineering",
26-
"Typing :: Typed",
27-
]
28-
dependencies = [
29-
"typing-extensions>=4.14.1",
30-
]
31-
32-
[project.urls]
33-
Repository = "https://github.com/data-apis/array-api-typing"
34-
Changelog = "https://github.com/data-apis/array-api-typing/releases"
35-
2+
name = "array-api-typing"
3+
dynamic = ["version"]
4+
description = "Static typing support for the array API standard"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
license = "MIT"
8+
authors = [
9+
{ name = "Consortium for Python Data API Standards", email = "[email protected]" },
10+
{ name = "Joren Hammudoglu", email = "[email protected]" },
11+
{ name = "Nathaniel Starkman", email = "[email protected]" },
12+
]
13+
classifiers = [
14+
"Development Status :: 1 - Planning",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3 :: Only",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
"Programming Language :: Python",
25+
"Topic :: Scientific/Engineering",
26+
"Typing :: Typed",
27+
]
28+
dependencies = [
29+
"typing-extensions>=4.14.1",
30+
]
31+
32+
[project.urls]
33+
Repository = "https://github.com/data-apis/array-api-typing"
34+
Changelog = "https://github.com/data-apis/array-api-typing/releases"
3635

3736
[build-system]
38-
requires = ["hatch-vcs", "hatchling"]
39-
build-backend = "hatchling.build"
40-
37+
requires = ["hatch-vcs", "hatchling"]
38+
build-backend = "hatchling.build"
4139

4240
[dependency-groups]
43-
dev = [
44-
{ include-group = "lint" },
45-
{ include-group = "mypy" },
46-
{ include-group = "test_runtime" },
47-
{ include-group = "test_numpy" },
48-
"lefthook==1.12.0",
49-
"orjson>=3.11.0; python_version<'3.14'", # used by mypy
50-
]
51-
lint = [
52-
"ruff==0.12.4",
53-
]
54-
mypy = [
55-
"mypy==1.17.0",
56-
]
57-
test_runtime = [
58-
"pytest==8.4.1",
59-
"pytest-cov>=6.2.1",
60-
"pytest-github-actions-annotate-failures==0.3.0",
61-
"sybil==9.1.0",
62-
]
63-
test_numpy = [
64-
"numpy>=1.25",
65-
]
66-
41+
dev = [
42+
{ include-group = "lint" },
43+
{ include-group = "mypy" },
44+
{ include-group = "test_runtime" },
45+
{ include-group = "test_numpy" },
46+
"lefthook==1.12.2",
47+
"orjson>=3.11.0; python_version<'3.14'", # used by mypy
48+
]
49+
lint = [
50+
"ruff==0.12.4",
51+
"dprint-py>=0.50.0.0",
52+
]
53+
mypy = [
54+
"mypy==1.17.0",
55+
]
56+
test_runtime = [
57+
"pytest==8.4.1",
58+
"pytest-cov>=6.2.1",
59+
"pytest-github-actions-annotate-failures==0.3.0",
60+
"sybil==9.1.0",
61+
]
62+
test_numpy = [
63+
"numpy>=1.25",
64+
]
6765

6866
[tool.hatch]
69-
version.source = "vcs"
67+
version.source = "vcs"
7068

71-
[tool.hatch.build.hooks.vcs]
72-
version-file = "src/array_api_typing/_version.py"
73-
template = '''
69+
[tool.hatch.build.hooks.vcs]
70+
version-file = "src/array_api_typing/_version.py"
71+
template = '''
7472
# This file is automatically generated by Hatch
7573
version = {version!r}
7674
version_tuple = {version_tuple!r}
7775
'''
7876

79-
8077
[tool.coverage]
81-
report.exclude_also = ['\.\.\.', 'if typing.TYPE_CHECKING:']
82-
run.source = ["array-api-typing"]
83-
run.branch = true
84-
78+
report.exclude_also = ['\.\.\.', 'if typing.TYPE_CHECKING:']
79+
run.source = ["array-api-typing"]
80+
run.branch = true
8581

8682
[tool.mypy]
87-
mypy_path = ["src"]
88-
namespace_packages = true
89-
90-
strict = true
91-
allow_redefinition_new = true
92-
local_partial_types = true
93-
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
94-
warn_unreachable = true
83+
mypy_path = ["src"]
84+
namespace_packages = true
9585

86+
strict = true
87+
allow_redefinition_new = true
88+
local_partial_types = true
89+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
90+
warn_unreachable = true
9691

9792
[tool.pytest.ini_options]
98-
addopts = [
99-
"--showlocals",
100-
"--strict-config",
101-
"--strict-markers",
102-
"-p no:doctest", # using sybil
103-
"-ra",
104-
]
105-
filterwarnings = [
106-
"error",
107-
# Sybil
108-
"ignore:Attribute s is deprecated and will be removed in Python 3\\.14:DeprecationWarning",
109-
"ignore:ast\\.Str is deprecated and will be removed in Python 3\\.14:DeprecationWarning",
110-
]
111-
log_cli_level = "INFO"
112-
minversion = "8.4"
113-
testpaths = ["README.md", "src/", "tests/runtime/"]
114-
xfail_strict = true
115-
93+
addopts = [
94+
"--showlocals",
95+
"--strict-config",
96+
"--strict-markers",
97+
"-p no:doctest", # using sybil
98+
"-ra",
99+
]
100+
filterwarnings = [
101+
"error",
102+
# Sybil
103+
"ignore:Attribute s is deprecated and will be removed in Python 3\\.14:DeprecationWarning",
104+
"ignore:ast\\.Str is deprecated and will be removed in Python 3\\.14:DeprecationWarning",
105+
]
106+
log_cli_level = "INFO"
107+
minversion = "8.4"
108+
testpaths = ["README.md", "src/", "tests/runtime/"]
109+
xfail_strict = true
116110

117111
[tool.ruff]
118-
preview = true
119-
force-exclude = true
120-
121-
[tool.ruff.lint]
122-
extend-select = ["ALL"]
123-
ignore = [
124-
"COM812", # Conflicts with formatter
125-
"CPY", # Missing copyright notice at top of file (NOTE revisit when autofixable)
126-
"D105", # Missing docstring in magic method
127-
"D107", # Missing docstring in __init__
128-
"D203", # 1 blank line required before class docstring
129-
"D213", # Multi-line docstring summary should start at the second line
130-
"FBT", # flake8-boolean-trap
131-
"FIX", # flake8-fixme
132-
"ISC001", # Conflicts with formatter
133-
]
134-
135-
[tool.ruff.lint.pylint]
136-
allow-dunder-method-names = [
137-
"__array_api_version__",
138-
"__array_namespace__",
139-
"__array_namespace_info__",
140-
"__dlpack__",
141-
"__dlpack_device__",
142-
"__dlpack_device__",
143-
]
144-
145-
[tool.ruff.lint.flake8-import-conventions]
146-
banned-from = ["array_api_typing"]
147-
148-
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
149-
array_api_typing = "xpt"
150-
151-
[tool.ruff.lint.isort]
152-
combine-as-imports = true
153-
extra-standard-library = ["_typeshed", "typing_extensions"]
154-
known-local-folder = ["array_api_typing"]
155-
156-
[tool.ruff.format]
157-
docstring-code-format = true
158-
line-ending = "lf"
112+
preview = true
113+
force-exclude = true
114+
115+
[tool.ruff.lint]
116+
extend-select = ["ALL"]
117+
ignore = [
118+
"COM812", # Conflicts with formatter
119+
"CPY", # Missing copyright notice at top of file (NOTE revisit when autofixable)
120+
"D105", # Missing docstring in magic method
121+
"D107", # Missing docstring in __init__
122+
"D203", # 1 blank line required before class docstring
123+
"D213", # Multi-line docstring summary should start at the second line
124+
"FBT", # flake8-boolean-trap
125+
"FIX", # flake8-fixme
126+
"ISC001", # Conflicts with formatter
127+
]
128+
129+
[tool.ruff.lint.pylint]
130+
allow-dunder-method-names = [
131+
"__array_api_version__",
132+
"__array_namespace__",
133+
"__array_namespace_info__",
134+
"__dlpack__",
135+
"__dlpack_device__",
136+
"__dlpack_device__",
137+
]
138+
139+
[tool.ruff.lint.flake8-import-conventions]
140+
banned-from = ["array_api_typing"]
141+
142+
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
143+
array_api_typing = "xpt"
144+
145+
[tool.ruff.lint.isort]
146+
combine-as-imports = true
147+
extra-standard-library = ["_typeshed", "typing_extensions"]
148+
known-local-folder = ["array_api_typing"]
149+
150+
[tool.ruff.format]
151+
docstring-code-format = true
152+
line-ending = "lf"

β€Žtests/.ruff.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extend = "../pyproject.toml"
33
[lint]
44
extend-ignore = [
55
"ANN201", # https://docs.astral.sh/ruff/rules/missing-return-type-undocumented-public-function/
6-
"D1", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
6+
"D1", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
77
"INP001", # https://docs.astral.sh/ruff/rules/implicit-namespace-package/
8-
"S101", # https://docs.astral.sh/ruff/rules/assert/
8+
"S101", # https://docs.astral.sh/ruff/rules/assert/
99
]

0 commit comments

Comments
Β (0)