habit-hooks-python 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: habit-hooks-python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: The Python Habit Hooks plugin
5
5
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "habit-hooks-python"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "The Python Habit Hooks plugin"
5
5
  requires-python = ">=3.11"
6
6
  dependencies = []
@@ -0,0 +1,16 @@
1
+ # Python plugin defaults.
2
+ language = "python"
3
+ # A project naming no `files` of its own scans what its plugins declare, so this
4
+ # is the first run for anyone `habit-hooks init` set up. An installed package is
5
+ # never the project's source; `site-packages` is where one lands whatever the
6
+ # environment is called, so it answers for a `venv/` as well as a `.venv/`.
7
+ files = ["**/*.py", "!**/site-packages/**", "!**/.venv/**", "!**/venv/**"]
8
+ sensors = ["ruff", "deptry"]
9
+ transformers = []
10
+
11
+ # The ruff sensor pipes its JSON through jq, so a python-only project needs it.
12
+ detectors = [
13
+ { name = "ruff", kind = "command", install = "pip install ruff" },
14
+ { name = "deptry", kind = "command", install = "pip install deptry" },
15
+ { name = "jq", kind = "command", install = "brew install jq" },
16
+ ]
@@ -0,0 +1,51 @@
1
+ """What this plugin means when it says which files are its language's.
2
+
3
+ A project that names no ``files`` of its own scans what its plugins declare, and
4
+ ``habit-hooks init`` writes exactly such a config — so what is declared here *is*
5
+ the first run for anyone init set up. A bare ``**/*.py`` reaches into the
6
+ project's virtualenv and reports on every installed package, which buries the
7
+ project's own findings under thousands that are nobody's to fix.
8
+
9
+ ``site-packages`` is where an installed package lands whatever the environment is
10
+ called, so it answers for a ``venv/`` as well as a ``.venv/``.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import tomllib
16
+ from pathlib import Path
17
+
18
+ import pathspec
19
+
20
+ PACKAGE = Path(__file__).resolve().parents[1] / "src" / "habit_hooks_python"
21
+
22
+ PROJECT_SOURCE = ("src/billing.py", "tests/test_billing.py", "conftest.py")
23
+ DEPENDENCIES = (
24
+ ".venv/lib/python3.12/site-packages/attrs/__init__.py",
25
+ "venv/lib/python3.11/site-packages/jinja2/environment.py",
26
+ ".tox/py312/lib/python3.12/site-packages/pytest/__init__.py",
27
+ # Not under site-packages, so only the environment's own name excludes these
28
+ # — and it is spelled both ways about equally often.
29
+ ".venv/bin/activate_this.py",
30
+ "venv/bin/activate_this.py",
31
+ )
32
+
33
+
34
+ def _declared_files() -> pathspec.PathSpec:
35
+ config = tomllib.loads((PACKAGE / "config.toml").read_text(encoding="utf-8"))
36
+ return pathspec.PathSpec.from_lines("gitignore", config["files"])
37
+
38
+
39
+ def test_the_project_s_own_python_is_source() -> None:
40
+ spec = _declared_files()
41
+
42
+ assert [path for path in PROJECT_SOURCE if spec.match_file(path)] == list(
43
+ PROJECT_SOURCE
44
+ )
45
+
46
+
47
+ def test_an_installed_package_is_not_this_project_s_source() -> None:
48
+ """Under either name a virtualenv usually goes by."""
49
+ spec = _declared_files()
50
+
51
+ assert [path for path in DEPENDENCIES if spec.match_file(path)] == []
@@ -1,5 +0,0 @@
1
- # Python plugin defaults.
2
- language = "python"
3
- files = ["**/*.py"]
4
- sensors = ["ruff", "deptry"]
5
- transformers = []