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.
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/PKG-INFO +1 -1
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/pyproject.toml +1 -1
- habit_hooks_python-1.2.0/src/habit_hooks_python/config.toml +16 -0
- habit_hooks_python-1.2.0/tests/test_the_python_files_leave_installed_packages_alone.py +51 -0
- habit_hooks_python-1.1.0/src/habit_hooks_python/config.toml +0 -5
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/.gitignore +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/docs/python-plugin.spec.md +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/__init__.py +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/guides/high-complexity.md +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/guides/swallowed-exception.md +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/ruff.toml +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/sensors/deptry.toml +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/sensors/deptry_sensor.py +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/sensors/ruff.toml +0 -0
- {habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/tests/test_a_deptry_nobody_installed_is_named.py +0 -0
|
@@ -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)] == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/sensors/deptry.toml
RENAMED
|
File without changes
|
|
File without changes
|
{habit_hooks_python-1.1.0 → habit_hooks_python-1.2.0}/src/habit_hooks_python/sensors/ruff.toml
RENAMED
|
File without changes
|
|
File without changes
|