tanh-tooling 0.1.0__py3-none-any.whl
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.
- tanh_tooling/__init__.py +3 -0
- tanh_tooling/_cli.py +47 -0
- tanh_tooling/data/pyright_base.json +7 -0
- tanh_tooling/data/ruff_base.toml +12 -0
- tanh_tooling-0.1.0.dist-info/METADATA +40 -0
- tanh_tooling-0.1.0.dist-info/RECORD +8 -0
- tanh_tooling-0.1.0.dist-info/WHEEL +4 -0
- tanh_tooling-0.1.0.dist-info/entry_points.txt +2 -0
tanh_tooling/__init__.py
ADDED
tanh_tooling/_cli.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import importlib.resources as res
|
|
3
|
+
import shutil
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from . import __version__
|
|
8
|
+
|
|
9
|
+
# package-relative source -> filename written into the consuming repo
|
|
10
|
+
FILES = {"ruff_base.toml": "ruff_base.toml", "pyright_base.json": "pyright_base.json"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _bundled(name: str) -> Path:
|
|
14
|
+
# wheels unpack into site-packages, so this resolves to a real path
|
|
15
|
+
return Path(str(res.files("tanh_tooling").joinpath("data", name)))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main() -> int:
|
|
19
|
+
p = argparse.ArgumentParser(prog="tanh-tooling")
|
|
20
|
+
p.add_argument("--version", action="version", version=__version__)
|
|
21
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
22
|
+
s = sub.add_parser("sync", help="materialise Python base configs into this repo")
|
|
23
|
+
s.add_argument(
|
|
24
|
+
"--check",
|
|
25
|
+
action="store_true",
|
|
26
|
+
help="fail if a base config is missing or differs (CI)",
|
|
27
|
+
)
|
|
28
|
+
args = p.parse_args()
|
|
29
|
+
|
|
30
|
+
dest, drift = Path.cwd(), False
|
|
31
|
+
for src_name, out_name in FILES.items():
|
|
32
|
+
src, tgt = _bundled(src_name), dest / out_name
|
|
33
|
+
if args.check:
|
|
34
|
+
if not tgt.exists() or tgt.read_bytes() != src.read_bytes():
|
|
35
|
+
print(f"out of date: {out_name}")
|
|
36
|
+
drift = True
|
|
37
|
+
else:
|
|
38
|
+
shutil.copy(src, tgt)
|
|
39
|
+
print(f"wrote {out_name}")
|
|
40
|
+
if args.check and drift:
|
|
41
|
+
print("run `tanh-tooling sync` and commit the result", file=sys.stderr)
|
|
42
|
+
return 1
|
|
43
|
+
return 0
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Reusable pyright policy (strictness + shared rule overrides).
|
|
3
|
+
// Other projects inherit via "extends": "<path>/pyright_base.json".
|
|
4
|
+
// Keep repo-specific paths (include/exclude/venv) in each project's pyrightconfig.json,
|
|
5
|
+
// since relative paths in a base file resolve against the base file's location.
|
|
6
|
+
"typeCheckingMode": "standard"
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Reusable Ruff base config (shared style + rule selection).
|
|
2
|
+
# Standalone ruff.toml format: keys are top-level, NOT under [tool.ruff].
|
|
3
|
+
# Other projects can inherit this via `extend = "<path>/ruff_base.toml"`.
|
|
4
|
+
# Named ruff_base.toml (not ruff.toml) on purpose: a bare ruff.toml would be
|
|
5
|
+
# auto-discovered and would override pyproject.toml's [tool.ruff] instead of merging.
|
|
6
|
+
|
|
7
|
+
line-length = 100
|
|
8
|
+
target-version = "py311"
|
|
9
|
+
|
|
10
|
+
[lint]
|
|
11
|
+
# E/F = pyflakes + pycodestyle, I = isort, UP = pyupgrade, B = bugbear.
|
|
12
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tanh-tooling
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: tanh-lab shared Python developer configuration (ruff + pyright bases) and a sync CLI.
|
|
5
|
+
Author: Fares Schulz
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: pyright>=1.1.400
|
|
8
|
+
Requires-Dist: ruff>=0.14
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# tanh-tooling (Python)
|
|
12
|
+
|
|
13
|
+
Shared tanh-lab Python developer configuration: a `ruff` base and a `pyright`
|
|
14
|
+
base, plus a `tanh-tooling sync` CLI that materialises them into a consuming repo.
|
|
15
|
+
|
|
16
|
+
## Use it
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
uv add tanh-tooling
|
|
20
|
+
uv run tanh-tooling sync # writes ruff_base.toml + pyright_base.json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then keep thin, hand-owned configs that extend the bases:
|
|
24
|
+
|
|
25
|
+
```toml
|
|
26
|
+
# ruff.toml
|
|
27
|
+
extend = "ruff_base.toml"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
// pyrightconfig.json
|
|
32
|
+
{ "extends": "pyright_base.json", "include": ["src"] }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The synced `ruff_base.toml` / `pyright_base.json` are committed but **generated** —
|
|
36
|
+
treat them like a lockfile, never hand-edit. CI drift check:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
uv run tanh-tooling sync --check
|
|
40
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
tanh_tooling/__init__.py,sha256=qs7C_q4cG8210WILzcfa6hITDJdswYsdn-Mpcs7KsEc,77
|
|
2
|
+
tanh_tooling/_cli.py,sha256=-PcJ1cP3xB0iNEzHr_dwk7gOS12Q4-jLkkOPcuwy7r8,1509
|
|
3
|
+
tanh_tooling/data/pyright_base.json,sha256=iooIpeQA82s5XWToZD5s0NT-h_vVp9VluHM-VD83cJY,349
|
|
4
|
+
tanh_tooling/data/ruff_base.toml,sha256=yuvs0dIjco5acxqHyryC-cvwPXMrSvpQCIcKGEhgvrE,532
|
|
5
|
+
tanh_tooling-0.1.0.dist-info/METADATA,sha256=DKda8fIBqlW_Zk3utCRM7pvhUz92h_6rxvDYfP0xF5g,991
|
|
6
|
+
tanh_tooling-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
7
|
+
tanh_tooling-0.1.0.dist-info/entry_points.txt,sha256=j6gZdU29PjqX1705lfaY3Q873Taml_EO6uYBtJannRg,56
|
|
8
|
+
tanh_tooling-0.1.0.dist-info/RECORD,,
|