Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ for family, grp in itertools.groupby(collected.checks.items(), key=lambda x: x[1
- [`PY005`](https://learn.scientific-python.org/development/guides/packaging-simple#PY005): Has tests folder
- [`PY006`](https://learn.scientific-python.org/development/guides/style#PY006): Has pre-commit config
- [`PY007`](https://learn.scientific-python.org/development/guides/tasks#PY007): Supports an easy task runner (nox, tox, pixi, etc.)
- [`PY008`](https://learn.scientific-python.org/development/guides/packaging-simple#PY008): Has a .gitignore file

### PyProject

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/packaging_simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ support versioning.
This is tool specific.

- [Hatchling info here](https://hatch.pypa.io/latest/config/build/#file-selection).
Hatchling uses your VCS ignore file by default, so make sure it is accurate
(which is a good idea anyway).
{rr}`PY008` Hatchling uses your VCS ignore file by default, so make sure your
project has an accurate `.gitignore` file (which is a good idea anyway).
- [Flit info here](https://flit.readthedocs.io/en/latest/pyproject_toml.html#sdist-section).
Flit requires manual inclusion/exclusion in many cases, like using a dirty
working directory.
Expand Down
11 changes: 11 additions & 0 deletions src/sp_repo_review/checks/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,16 @@ def check(root: Traversable, pyproject: dict[str, Any]) -> bool:
return False


class PY008(General):
"Has a .gitignore file"

url = mk_url("packaging-simple")

@staticmethod
def check(root: Traversable) -> bool:
"Projects must have a `.gitignore` file"
return root.joinpath(".gitignore").is_file()


def repo_review_checks() -> dict[str, General]:
return {p.__name__: p() for p in General.__subclasses__()}
20 changes: 20 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,23 @@ def test_py007_missing(tmp_path: Path):
simple = tmp_path / "simple"
simple.mkdir()
assert not compute_check("PY007", root=simple, pyproject={}).result


def test_py008(tmp_path: Path):
simple = tmp_path / "simple"
simple.mkdir()
simple.joinpath(".gitignore").touch()
assert compute_check("PY008", root=simple).result


def test_py008_not_file(tmp_path: Path):
simple = tmp_path / "simple"
simple.mkdir()
simple.joinpath(".gitignore").mkdir()
assert not compute_check("PY008", root=simple).result


def test_py008_missing(tmp_path: Path):
simple = tmp_path / "simple"
simple.mkdir()
assert not compute_check("PY008", root=simple).result
Loading