Skip to content

Commit 036a76a

Browse files
authored
chores: updated pyproject, ruff, mypy and AGENTS.md (#32)
1 parent 8b17bd1 commit 036a76a

File tree

6 files changed

+183
-117
lines changed

6 files changed

+183
-117
lines changed

AGENTS.md

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ uv sync --locked --all-extras --dev
2121

2222
| Task | Command |
2323
|---|---|
24-
| Format check | `uv run ruff format --check .` |
2524
| Auto-format | `uv run ruff format .` |
26-
| Lint | `uv run ruff check .` |
2725
| Lint + auto-fix | `uv run ruff check --fix --unsafe-fixes .` |
2826
| Type check | `uv run mypy .` |
2927
| Run all tests | `uv run pytest` |
@@ -32,7 +30,7 @@ uv sync --locked --all-extras --dev
3230

3331
**Before marking any task as complete, always run:**
3432
```bash
35-
uv run ruff check . && uv run mypy . && uv run pytest
33+
uv run ruff check --fix --unsafe-fixes . && uv run mypy . && uv run pytest
3634
```
3735

3836
---
@@ -70,60 +68,7 @@ PEP8 + Black. Run `uv run ruff check --fix --unsafe-fixes .` then `uv run ruff f
7068

7169
---
7270

73-
## Import Conventions
7471

75-
Every source file begins with:
76-
77-
```python
78-
from __future__ import annotations
79-
```
80-
81-
Import ordering within a file:
82-
83-
1. `from __future__ import annotations` — always first
84-
2. Standard library bare imports (`import os`, `import sys`, …)
85-
3. Standard library `from … import …`
86-
4. Third-party bare imports
87-
5. Third-party `from … import …`
88-
6. `if TYPE_CHECKING:` block — types needed only for annotations
89-
90-
```python
91-
from __future__ import annotations
92-
93-
import contextlib
94-
import os
95-
from pathlib import Path
96-
from typing import TYPE_CHECKING, Any
97-
98-
import coverage
99-
100-
if TYPE_CHECKING:
101-
from collections.abc import Iterable
102-
from coverage.types import TLineNo
103-
from tree_sitter import Node
104-
```
105-
106-
- Within the package: use **relative** imports (`from .plugin import ShellPlugin`)
107-
- In tests and externally: use **absolute** imports (`from coverage_sh.plugin import …`)
108-
- Put `TYPE_CHECKING`-only imports in the `if TYPE_CHECKING:` block to avoid runtime cost
109-
110-
---
111-
112-
## Naming Conventions
113-
114-
| Construct | Convention | Example |
115-
|---|---|---|
116-
| Modules / files | `snake_case` | `plugin.py`, `test_plugin.py` |
117-
| Classes | `PascalCase` | `ShellFileReporter`, `CovLineParser` |
118-
| Test classes | `Test` prefix | `TestShellFileReporter` |
119-
| Functions / methods | `snake_case` | `find_executable_files()` |
120-
| Private methods | leading `_` | `_parse_ast()`, `_iterdir()` |
121-
| Test methods | `test_<what>_should_<expected_outcome>` | `test_source_should_be_cached` |
122-
| Module constants | `UPPER_SNAKE_CASE` | `TRACEFILE_PREFIX`, `TMP_PATH` |
123-
| Local variables | `snake_case` | `fifo_path`, `line_data` |
124-
| Type aliases | `PascalCase` | `LineData = dict[str, set[int]]` |
125-
126-
---
12772

12873
## Error Handling
12974

coverage_sh/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def write(self, line_data: LineData) -> None:
155155
)
156156

157157
coverage_data.add_file_tracers(
158-
{f: "coverage_sh.ShellPlugin" for f in line_data}
158+
dict.fromkeys(line_data, "coverage_sh.ShellPlugin")
159159
)
160160
coverage_data.add_lines(line_data)
161161
coverage_data.write()

pyproject.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "coverage-sh"
3-
version = "0.4.5 "
3+
version = "0.4.5"
44
description = "A Coverage.py plugin to measure code coverage of shell scripts from python."
55
authors = [
66
{ name = "Kilian Lackhove", email = "kilian@lackhove.de" }
@@ -13,11 +13,10 @@ dependencies = [
1313
]
1414
readme = "README.md"
1515
requires-python = ">= 3.9"
16-
license = { text = "MIT" }
16+
license = "MIT"
1717
keywords = ["coverage", "plugin", "shell", "bash", "sh"]
1818
classifiers = [
1919
"Development Status :: 2 - Pre-Alpha",
20-
"License :: OSI Approved :: MIT License",
2120
"Programming Language :: Python :: 3.9",
2221
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
@@ -34,15 +33,12 @@ build-backend = "hatchling.build"
3433

3534
[dependency-groups]
3635
dev = [
37-
"ruff==0.3.2",
38-
"mypy==1.9.0",
36+
"ruff==0.15.*",
37+
"mypy>=1.19",
3938
"pytest>=7.4.3",
4039
"setuptools>=69.0.2",
4140
]
4241

43-
[tool.hatch.metadata]
44-
allow-direct-references = true
45-
4642
[tool.hatch.build.targets.wheel]
4743
packages = ["coverage_sh"]
4844

@@ -60,10 +56,10 @@ select = ["ALL"]
6056
ignore = [
6157
"E501", # Line too long
6258
"D", # missing docstring
63-
"ANN101", # Missing type annotation for `self` in method
6459
"ANN204", # Missing return type annotation for special method `__init__`
6560
"ANN002", # Missing type annotation for `*args`
6661
"ANN003", # Missing type annotation for `**kwargs`
62+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes (we use os.urandom)
6763
"S603", # subprocess-without-shell-equals-true
6864
"TD", # flake8-todos
6965
"FIX", #flake8-fixme
@@ -74,7 +70,7 @@ ignore = [
7470
"EM102", # Exception must not use an f-string literal, assign to variable first
7571
]
7672

77-
[tool.ruff.per-file-ignores]
73+
[tool.ruff.lint.per-file-ignores]
7874
"tests/**/*.py" = ["ANN", "D", "S101", "PLR2004", "N802", "PT015", "B011", "INP001", "FBT001", "T201"]
7975
"tests/resources/**/*.py" = ["ALL"]
8076

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import pytest
88

99

10-
@pytest.fixture()
10+
@pytest.fixture
1111
def resources_dir():
1212
return Path(__file__).parent / "resources"
1313

1414

15-
@pytest.fixture()
15+
@pytest.fixture
1616
def dummy_project_dir(resources_dir: Path, tmp_path: Path) -> Path:
1717
"""Fixture for a temporary copy of `testproject`"""
1818
source = resources_dir / "testproject"

tests/test_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@
137137
INNER_PY_EXECUTED_LINES = [2]
138138

139139

140-
@pytest.fixture()
140+
@pytest.fixture
141141
def examples_dir(resources_dir):
142142
return resources_dir / "examples"
143143

144144

145-
@pytest.fixture()
145+
@pytest.fixture
146146
def syntax_example_path(resources_dir, tmp_path):
147147
original_path = resources_dir / "syntax_example.sh"
148148
working_copy_path = tmp_path / "syntax_example.sh"
@@ -199,7 +199,7 @@ def test_end2end(
199199

200200

201201
@pytest.fixture(scope="session")
202-
def covpy_installs_pth_at_install_time() -> None: # noqa: PT004
202+
def covpy_installs_pth_at_install_time() -> None:
203203
"""Skip if coveragepy does not install a .pth file into site-packages at install time.
204204
205205
- >= 7.13.0: writes the .pth file during pip install — reliable in all environments.
@@ -255,7 +255,7 @@ def test_end2end_python_subprocess_via_shell(
255255

256256

257257
class TestShellFileReporter:
258-
@pytest.fixture()
258+
@pytest.fixture
259259
def reporter(self, syntax_example_path):
260260
return ShellFileReporter(str(syntax_example_path))
261261

0 commit comments

Comments
 (0)