Skip to content

Commit eac55d9

Browse files
authored
Adopt sp-repo-review (#126)
* cleanup * cleanup * Add strict typing * fix tests * fixups * cleanup * bump min version * bump min version
1 parent ae0468c commit eac55d9

File tree

20 files changed

+186
-104
lines changed

20 files changed

+186
-104
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ jobs:
9898
steps:
9999
- uses: actions/checkout@v3
100100
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
101-
- name: Run Linters
102-
run: |
101+
- name: Run Linters
102+
run: |
103103
hatch run typing:test
104104
hatch run lint:style
105105
pipx run interrogate -v .

.pre-commit-config.yaml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ci:
22
autoupdate_schedule: monthly
3+
autoupdate_commit_msg: "chore: update pre-commit hooks"
34

45
repos:
56
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -29,13 +30,44 @@ repos:
2930
hooks:
3031
- id: mdformat
3132

32-
- repo: https://github.com/psf/black
33+
- repo: https://github.com/pre-commit/mirrors-prettier
34+
rev: "v3.0.2"
35+
hooks:
36+
- id: prettier
37+
types_or: [yaml, html, json]
38+
39+
- repo: https://github.com/adamchainz/blacken-docs
40+
rev: "1.16.0"
41+
hooks:
42+
- id: blacken-docs
43+
additional_dependencies: [black==23.7.0]
44+
45+
- repo: https://github.com/psf/black-pre-commit-mirror
3346
rev: 23.7.0
3447
hooks:
3548
- id: black
3649

50+
- repo: https://github.com/codespell-project/codespell
51+
rev: "v2.2.5"
52+
hooks:
53+
- id: codespell
54+
args: ["-L", "sur,nd"]
55+
56+
- repo: https://github.com/pre-commit/pygrep-hooks
57+
rev: "v1.10.0"
58+
hooks:
59+
- id: rst-backticks
60+
- id: rst-directive-colons
61+
- id: rst-inline-touching-normal
62+
3763
- repo: https://github.com/astral-sh/ruff-pre-commit
3864
rev: v0.0.287
3965
hooks:
4066
- id: ruff
41-
args: ["--fix"]
67+
args: ["--fix", "--show-fixes"]
68+
69+
- repo: https://github.com/scientific-python/cookie
70+
rev: "2023.08.23"
71+
hooks:
72+
- id: sp-repo-review
73+
additional_dependencies: ["repo-review[cli]"]

.readthedocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
version: 2
32
sphinx:
43
configuration: docs/conf.py
@@ -12,4 +11,4 @@ python:
1211
build:
1312
os: ubuntu-22.04
1413
tools:
15-
python: "3.11"
14+
python: "3.11"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This provides a [build hook](https://hatch.pypa.io/latest/config/build/#build-ho
1717

1818
## Documentation
1919

20-
The full documenation is available on [Read The Docs](https://hatch-jupyter-builder.readthedocs.io/en/latest/).
20+
The full documentation is available on [Read The Docs](https://hatch-jupyter-builder.readthedocs.io/en/latest/).
2121

2222
## Installation
2323

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. hatch-jupyter-builder documentation master file, created by
22
sphinx-quickstart on Mon Jul 4 07:51:40 2022.
33
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
4+
contain the root ``toctree`` directive.
55
66
Welcome to hatch-jupyter-builder's documentation!
77
=================================================

docs/source/background/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Background
22
==========
33
Explanation. Clarification and discussion of key topics.
44

5-
Hatch Jupyter Builder is a plugin for the `hatchling` Python build backend.
5+
Hatch Jupyter Builder is a plugin for the ``hatchling`` Python build backend.
66
It is primarily targeted for package authors who are providing JavaScript
77
as part of their Python packages.
88

docs/source/get_started/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Tutorials. A hands-on introduction to Hatch Jupyter Builder for maintainers.
88

99
config
1010

11-
If starting from a new project, use `hatch new "my project name"`, and follow
12-
along with the prompts. Then add the appropriate [configuration](./config) for `hatch_jupyter_builder` in your `pyproject.toml` flag.
11+
If starting from a new project, use ``hatch new "my project name"``, and follow
12+
along with the prompts. Then add the appropriate [configuration](./config) for
13+
``hatch_jupyter_builder`` in your ``pyproject.toml`` flag.
1314

1415
If migrating from existing project, find the appropriate [how to guides](../how_to_guides).

hatch_jupyter_builder/compare_migrated/cli.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Compare the dist file created by a migrated package to one created by the original."""
2+
from __future__ import annotations
3+
24
import argparse
35
import glob
46
import logging
@@ -8,10 +10,9 @@
810
import sys
911
import tarfile
1012
import zipfile
11-
from typing import Optional
1213

1314

14-
def build_file(dirname, dist_name):
15+
def build_file(dirname: str, dist_name: str) -> None:
1516
"""Build a dist file in a directory."""
1617
orig_dir = os.getcwd()
1718
os.chdir(dirname)
@@ -21,21 +22,21 @@ def build_file(dirname, dist_name):
2122
os.chdir(orig_dir)
2223

2324

24-
def get_tar_names(dirname):
25+
def get_tar_names(dirname: str) -> set[str]:
2526
"""Get the tarball names in a directory."""
2627
dist_file = glob.glob(f"{dirname}/dist/*.tar.gz")[0]
2728
tarf = tarfile.open(dist_file, "r:gz")
2829
return set(tarf.getnames())
2930

3031

31-
def get_zip_names(dirname):
32+
def get_zip_names(dirname: str) -> set[str]:
3233
"""Get the zip (wheel) file names in a directory."""
3334
wheel_file = glob.glob(f"{dirname}/dist/*.whl")[0]
3435
with zipfile.ZipFile(wheel_file, "r") as f:
3536
return set(f.namelist())
3637

3738

38-
def filter_file(path):
39+
def filter_file(path: str) -> bool:
3940
"""Filter a file path for interesting files."""
4041
if "egg-info" in path:
4142
return True
@@ -47,7 +48,7 @@ def filter_file(path):
4748
return False
4849

4950

50-
def main(source_dir, target_dir, dist_name):
51+
def main(source_dir: str, target_dir: str, dist_name: str) -> dict[str, list[str]]:
5152
"""The main script."""
5253
subprocess.check_call([sys.executable, "-m", "pip", "install", "build"])
5354

@@ -64,25 +65,25 @@ def main(source_dir, target_dir, dist_name):
6465
source_names = get_zip_names(source_dir)
6566
target_names = get_zip_names(target_dir)
6667

67-
removed = source_names - target_names
68+
removed = list(source_names - target_names)
6869
removed = [r for r in removed if not filter_file(r)]
6970
if removed:
7071
logger.info("\nRemoved_files:")
71-
[logger.info(f) for f in removed] # type:ignore
72+
[logger.info(f) for f in removed] # type:ignore[func-returns-value]
7273

73-
added = target_names - source_names
74+
added = list(target_names - source_names)
7475
added = [a for a in added if not filter_file(a)]
7576
if added:
7677
logger.info("\nAdded files:")
77-
[logger.info(f) for f in added] # type:ignore
78+
[logger.info(f) for f in added] # type:ignore[func-returns-value]
7879

7980
logger.info("")
8081

8182
return {"added": added, "removed": removed}
8283

8384

8485
def make_parser(
85-
parser: Optional[argparse.ArgumentParser] = None, prog: Optional[str] = None
86+
parser: argparse.ArgumentParser | None = None, prog: str | None = None
8687
) -> argparse.ArgumentParser:
8788
"""Make an arg parser."""
8889
if parser is None:
@@ -93,7 +94,7 @@ def make_parser(
9394
return parser
9495

9596

96-
def run(args: Optional[argparse.Namespace] = None) -> None:
97+
def run(args: argparse.Namespace | None = None) -> None:
9798
"""Run the cli."""
9899
if args is None:
99100
parser = make_parser(prog=f"{sys.executable} -m hatch_jupyter_builder.compare_migrated")

hatch_jupyter_builder/hooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Register hooks for the plugin."""
2+
from typing import Type
3+
24
from hatchling.plugin import hookimpl
35

46
from .plugin import JupyterBuildHook
57

68

79
@hookimpl
8-
def hatch_register_build_hook():
10+
def hatch_register_build_hook() -> Type[JupyterBuildHook]:
911
"""Get the hook implementation."""
1012
return JupyterBuildHook

0 commit comments

Comments
 (0)