Skip to content

Commit 8efecdc

Browse files
committed
chore: Template upgrade
1 parent e8b85ff commit 8efecdc

File tree

13 files changed

+41
-71
lines changed

13 files changed

+41
-71
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier.
2-
_commit: 1.11.1
2+
_commit: 1.11.6
33
_src_path: gh:pawamoy/copier-uv
44
author_email: dev@pawamoy.fr
55
author_fullname: Timothée Mazzucotelli

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ jobs:
4343
python-version: "3.12"
4444
- os: ubuntu-latest
4545
python-version: "3.13"
46+
- os: ubuntu-latest
47+
python-version: "3.15-dev"
4648

4749
runs-on: ${{ matrix.os }}
50+
continue-on-error: true
4851

4952
steps:
5053
- name: Checkout
@@ -105,7 +108,7 @@ jobs:
105108
- "3.12"
106109
- "3.13"
107110
- "3.14"
108-
- "3.15"
111+
- "3.15-dev"
109112
resolution:
110113
- highest
111114
- lowest-direct
@@ -114,6 +117,7 @@ jobs:
114117
resolution: lowest-direct
115118
- os: windows-latest
116119
resolution: lowest-direct
120+
117121
runs-on: ${{ matrix.os }}
118122
continue-on-error: true
119123

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ uv.lock
2020
# cache
2121
.cache/
2222
.pytest_cache/
23-
.mypy_cache/
2423
.ruff_cache/
2524
__pycache__/
2625

config/mypy.ini

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

config/ruff.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ select = ["ALL"]
99
ignore = [
1010
"A001", # Variable is shadowing a Python builtin
1111
"A005", # Module shadows a Python standard-library module
12-
"ANN101", # Missing type annotation for self
13-
"ANN102", # Missing type annotation for cls
1412
"ANN204", # Missing return type annotation for special method __str__
1513
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
1614
"ARG005", # Unused lambda argument

config/vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"**/.venvs*/**": true,
55
"**/venv*/**": true
66
},
7-
"mypy-type-checker.args": [
8-
"--config-file=config/mypy.ini"
9-
],
107
"python.testing.unittestEnabled": false,
118
"python.testing.pytestEnabled": true,
129
"python.testing.pytestArgs": [

duties.py

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import re
77
import sys
88
import warnings
9-
from contextlib import contextmanager
109
from functools import partial
11-
from importlib.metadata import version as pkgversion
1210
from pathlib import Path
1311
from random import sample
1412
from tempfile import gettempdir
@@ -19,8 +17,6 @@
1917
from pysource_minimize import minimize
2018

2119
if TYPE_CHECKING:
22-
from collections.abc import Iterator
23-
2420
from duty.context import Context
2521

2622

@@ -32,7 +28,7 @@
3228
PTY = not WINDOWS and not CI
3329
MULTIRUN = os.environ.get("MULTIRUN", "0") == "1"
3430
PY_VERSION = f"{sys.version_info.major}{sys.version_info.minor}"
35-
PY_DEV = "314"
31+
PY_DEV = "315"
3632

3733

3834
def _pyprefix(title: str) -> str:
@@ -42,22 +38,10 @@ def _pyprefix(title: str) -> str:
4238
return title
4339

4440

45-
@contextmanager
46-
def _material_insiders() -> Iterator[bool]:
47-
if "+insiders" in pkgversion("mkdocs-material"):
48-
os.environ["MATERIAL_INSIDERS"] = "true"
49-
try:
50-
yield True
51-
finally:
52-
os.environ.pop("MATERIAL_INSIDERS")
53-
else:
54-
yield False
55-
56-
5741
def _get_changelog_version() -> str:
5842
changelog_version_re = re.compile(r"^## \[(\d+\.\d+\.\d+)\].*$")
5943
with Path(__file__).parent.joinpath("CHANGELOG.md").open("r", encoding="utf8") as file:
60-
return next(filter(bool, map(changelog_version_re.match, file))).group(1) # type: ignore[union-attr]
44+
return next(filter(bool, map(changelog_version_re.match, file))).group(1) # ty: ignore[invalid-argument-type]
6145

6246

6347
@duty
@@ -209,11 +193,10 @@ def check_docs(ctx: Context) -> None:
209193
Path("htmlcov/index.html").touch(exist_ok=True)
210194
if CI:
211195
os.environ["DEPLOY"] = "true"
212-
with _material_insiders():
213-
ctx.run(
214-
tools.mkdocs.build(strict=True, verbose=True),
215-
title=_pyprefix("Building documentation"),
216-
)
196+
ctx.run(
197+
tools.mkdocs.build(strict=True, verbose=True),
198+
title=_pyprefix("Building documentation"),
199+
)
217200

218201

219202
@duty(nofail=PY_VERSION == PY_DEV)
@@ -224,15 +207,15 @@ def check_types(ctx: Context) -> None:
224207
make check-types
225208
```
226209
227-
Run type-checking on the code with [Mypy](https://mypy.readthedocs.io/).
210+
Run type-checking on the code with [ty](https://astral.sh/ty/).
228211
229-
The configuration for Mypy is located at `config/mypy.ini`.
212+
The configuration for ty is located at `config/ty.toml`.
230213
231214
If you cannot or don't know how to fix a typing error in your code,
232215
as a last resort you can ignore this specific error with a comment:
233216
234217
```python title="src/your_package/module.py"
235-
print("a code line that triggers a Mypy warning") # type: ignore[ID]
218+
print("a code line that triggers a ty warning") # ty: ignore[ID]
236219
```
237220
238221
...where ID is the name of the warning.
@@ -245,24 +228,25 @@ def check_types(ctx: Context) -> None:
245228
```console
246229
$ make check-types
247230
✗ Checking types (1)
248-
> mypy --config-file=config/mypy.ini src/ tests/ scripts/
249-
src/your_package/module.py:2:1: Item "None" of "Data | None" has no attribute "value" [union-attr]
231+
> ty check --config=config/ty.toml src/ tests/ scripts/
232+
t.py:6:10: warning[possibly-missing-attribute] Attribute `value` may be missing on object of type `Data | None`
250233
```
251234
252235
Now add a comment to ignore this warning.
253236
254237
```python title="src/your_package/module.py"
255-
result = data_dict.get(key, None).value # type: ignore[union-attr]
238+
result = data_dict.get(key, None).value # ty: ignore[possibly-missing-attribute]
256239
```
257240
258241
```console
259242
$ make check-types
260243
✓ Checking types
261244
```
262245
"""
263-
os.environ["FORCE_COLOR"] = "1"
246+
"""Check that the code is correctly typed."""
247+
py = f"{sys.version_info.major}.{sys.version_info.minor}"
264248
ctx.run(
265-
tools.mypy(*PY_SRC_LIST, config_file="config/mypy.ini"),
249+
tools.ty.check(*PY_SRC_LIST, color=True, error_on_warning=True, python_version=py),
266250
title=_pyprefix("Type-checking"),
267251
)
268252

@@ -327,12 +311,11 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000
327311
host: The host to serve the docs from.
328312
port: The port to serve the docs on.
329313
"""
330-
with _material_insiders():
331-
ctx.run(
332-
tools.mkdocs.serve(dev_addr=f"{host}:{port}").add_args(*cli_args),
333-
title="Serving documentation",
334-
capture=False,
335-
)
314+
ctx.run(
315+
tools.mkdocs.serve(dev_addr=f"{host}:{port}").add_args(*cli_args),
316+
title="Serving documentation",
317+
capture=False,
318+
)
336319

337320

338321
@duty
@@ -346,10 +329,7 @@ def docs_deploy(ctx: Context) -> None:
346329
Use [MkDocs](https://www.mkdocs.org/) to build and deploy the documentation to GitHub pages.
347330
"""
348331
os.environ["DEPLOY"] = "true"
349-
with _material_insiders() as insiders:
350-
if not insiders:
351-
ctx.run(lambda: False, title="Not deploying docs without Material for MkDocs Insiders!")
352-
ctx.run(tools.mkdocs.gh_deploy(force=True), title="Deploying documentation")
332+
ctx.run(tools.mkdocs.gh_deploy(force=True), title="Deploying documentation")
353333

354334

355335
@duty

mkdocs.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,7 @@ plugins:
307307
try_it_out.md: playground.md
308308
reference/griffe.md: reference/api.md
309309
code_of_conduct.md: code-of-conduct.md
310-
- group:
311-
enabled: !ENV [MATERIAL_INSIDERS, false]
312-
plugins:
313-
- typeset
310+
- typeset
314311

315312
extra:
316313
social:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ ci = [
110110
"pytest-gitconfig>=0.8.0",
111111
"pytest-randomly>=3.15",
112112
"pytest-xdist>=3.6",
113-
"mypy>=1.10",
114113
"ruff>=0.4",
114+
"ty>=0.0.14",
115115
"types-markdown>=3.6",
116116
"types-pyyaml>=6.0",
117117
]

scripts/gen_credits.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _norm_name(name: str) -> str:
4747
return name.replace("_", "-").replace(".", "-").lower()
4848

4949

50-
def _requirements(deps: list[str]) -> dict[str, Requirement]:
50+
def _requirements(deps: Iterable[str]) -> dict[str, Requirement]:
5151
return {_norm_name((req := Requirement(dep)).name): req for dep in deps}
5252

5353

@@ -67,8 +67,8 @@ def _extra_marker(req: Requirement) -> str | None:
6767
def _get_metadata() -> Metadata:
6868
metadata = {}
6969
for pkg in distributions():
70-
name = _norm_name(pkg.name) # type: ignore[attr-defined,unused-ignore]
71-
metadata[name] = _merge_fields(pkg.metadata) # type: ignore[arg-type]
70+
name = _norm_name(pkg.name)
71+
metadata[name] = _merge_fields(pkg.metadata) # ty: ignore[invalid-argument-type]
7272
metadata[name]["spec"] = set()
7373
metadata[name]["extras"] = set()
7474
metadata[name].setdefault("summary", "")
@@ -95,8 +95,8 @@ def _get_deps(base_deps: dict[str, Requirement], metadata: Metadata) -> Metadata
9595
for dep_name, dep_req in base_deps.items():
9696
if dep_name not in metadata or dep_name == "griffe":
9797
continue
98-
metadata[dep_name]["spec"] |= {str(spec) for spec in dep_req.specifier} # type: ignore[operator]
99-
metadata[dep_name]["extras"] |= dep_req.extras # type: ignore[operator]
98+
metadata[dep_name]["spec"] |= {str(spec) for spec in dep_req.specifier} # ty: ignore[unsupported-operator]
99+
metadata[dep_name]["extras"] |= dep_req.extras # ty: ignore[unsupported-operator]
100100
deps[dep_name] = metadata[dep_name]
101101

102102
again = True
@@ -114,7 +114,7 @@ def _get_deps(base_deps: dict[str, Requirement], metadata: Metadata) -> Metadata
114114
and dep_name != project["name"]
115115
and (not extra_marker or extra_marker in deps[pkg_name]["extras"])
116116
):
117-
metadata[dep_name]["spec"] |= {str(spec) for spec in requirement.specifier} # type: ignore[operator]
117+
metadata[dep_name]["spec"] |= {str(spec) for spec in requirement.specifier} # ty: ignore[unsupported-operator]
118118
deps[dep_name] = metadata[dep_name]
119119
again = True
120120

@@ -126,7 +126,7 @@ def _render_credits() -> str:
126126
dev_dependencies = _get_deps(_requirements(devdeps), metadata)
127127
prod_dependencies = _get_deps(
128128
_requirements(
129-
chain( # type: ignore[arg-type]
129+
chain(
130130
project.get("dependencies", []),
131131
chain(*project.get("optional-dependencies", {}).values()),
132132
),

0 commit comments

Comments
 (0)