readability-cli 0.11.1__tar.gz → 0.12.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.
Files changed (39) hide show
  1. {readability_cli-0.11.1 → readability_cli-0.12.0}/PKG-INFO +14 -6
  2. {readability_cli-0.11.1 → readability_cli-0.12.0}/README.md +13 -5
  3. {readability_cli-0.11.1 → readability_cli-0.12.0}/pyproject.toml +1 -1
  4. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/tools.py +81 -0
  5. readability_cli-0.12.0/test_type_checking.py +114 -0
  6. {readability_cli-0.11.1 → readability_cli-0.12.0}/uv.lock +1 -1
  7. {readability_cli-0.11.1 → readability_cli-0.12.0}/.github/workflows/ci.yml +0 -0
  8. {readability_cli-0.11.1 → readability_cli-0.12.0}/.github/workflows/publish.yml +0 -0
  9. {readability_cli-0.11.1 → readability_cli-0.12.0}/.github/workflows/update-guides.yml +0 -0
  10. {readability_cli-0.11.1 → readability_cli-0.12.0}/.gitignore +0 -0
  11. {readability_cli-0.11.1 → readability_cli-0.12.0}/.python-version +0 -0
  12. {readability_cli-0.11.1 → readability_cli-0.12.0}/LICENSE +0 -0
  13. {readability_cli-0.11.1 → readability_cli-0.12.0}/biome.json +0 -0
  14. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/__init__.py +0 -0
  15. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/checking.py +0 -0
  16. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/cli.py +0 -0
  17. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/configs/biome-default.json +0 -0
  18. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/configs/pyrefly.toml +0 -0
  19. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/configs/ruff.toml +0 -0
  20. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guide.py +0 -0
  21. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/Rguide.md +0 -0
  22. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/cppguide.md +0 -0
  23. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/csharpguide.md +0 -0
  24. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/docguide-style.md +0 -0
  25. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/go-guide.md +0 -0
  26. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/htmlcssguide.md +0 -0
  27. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/javaguide.md +0 -0
  28. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/jsguide.md +0 -0
  29. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/jsoncguide.md +0 -0
  30. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/objcguide.md +0 -0
  31. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/pyguide.md +0 -0
  32. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/shellguide.md +0 -0
  33. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/tsguide.md +0 -0
  34. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/guides/vimscriptguide.md +0 -0
  35. {readability_cli-0.11.1 → readability_cli-0.12.0}/readability/outline.py +0 -0
  36. {readability_cli-0.11.1 → readability_cli-0.12.0}/test_checking.py +0 -0
  37. {readability_cli-0.11.1 → readability_cli-0.12.0}/test_guide.py +0 -0
  38. {readability_cli-0.11.1 → readability_cli-0.12.0}/test_outline.py +0 -0
  39. {readability_cli-0.11.1 → readability_cli-0.12.0}/test_package.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readability-cli
3
- Version: 0.11.1
3
+ Version: 0.12.0
4
4
  Summary: A CLI to lint, format, and type-check code with Google-style defaults, and pull Google style guides in markdown format.
5
5
  Project-URL: Homepage, https://github.com/owahltinez/readability
6
6
  Project-URL: Repository, https://github.com/owahltinez/readability
@@ -23,8 +23,8 @@ quick access to style conventions without browsing HTML pages.
23
23
  ## Features
24
24
 
25
25
  - **Linting & Formatting**: A `check` command that automatically detects and
26
- runs relevant tools (Ruff, Pyrefly, Biome, gofmt, goimports, shfmt,
27
- shellcheck, and rustfmt) for your project.
26
+ runs relevant tools (Ruff, Pyrefly, Biome, tsc, gofmt, goimports, go vet,
27
+ shfmt, shellcheck, and rustfmt) for your project.
28
28
  - **Predictable Ownership**: Every supported format has fixed tools, so
29
29
  configuration customizes checks without changing which formatter runs.
30
30
  - **Style Guides**: A `guide` command that fetches the latest Google style
@@ -107,7 +107,8 @@ such as gofmt and goimports, are unaffected by it.
107
107
  | ---------------------------------------------------------------- | --------------------------------------- | ------------------------------------- |
108
108
  | `.py` | Ruff lint/format; Pyrefly type checking | Ruff and Pyrefly native configuration |
109
109
  | `.js`, `.jsx`, `.ts`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | Biome | `biome.json` or `biome.jsonc` |
110
- | `.go` | gofmt, goimports | None |
110
+ | `.ts`, `.tsx` | tsc type checking | `tsconfig.json`, required |
111
+ | `.go` | gofmt, goimports; go vet | `go.mod`, required by go vet |
111
112
  | `.sh`, `.bash` | shfmt format; shellcheck lint | None |
112
113
  | `.rs` | rustfmt | None |
113
114
 
@@ -117,8 +118,8 @@ successfully.
117
118
 
118
119
  Biome first checks a project's `node_modules/.bin`. Ruff, Pyrefly, and Biome
119
120
  then use `PATH`, followed by `uvx` for the Python tools or `npx` for Biome. The
120
- runners cache downloads, so subsequent runs work offline. Gofmt and goimports
121
- must be available on `PATH`.
121
+ runners cache downloads, so subsequent runs work offline. Gofmt, goimports, and
122
+ Go itself, for go vet, must be available on `PATH`.
122
123
 
123
124
  That keeps this package at ~4 MB rather than the ~54 MB it would take to carry
124
125
  Ruff and Pyrefly itself — a cost that would fall on everyone using only `guide`.
@@ -145,6 +146,13 @@ Ruff, Pyrefly, and Biome ship with bundled configurations, so they run on every
145
146
  file they own without project setup. Gofmt and goimports run on `.go` files even
146
147
  when there is no `go.mod`.
147
148
 
149
+ Tsc and go vet have no bundled configuration, since neither can type-check a
150
+ file without its project's imports. They run only inside a `tsconfig.json`
151
+ project or a Go module, and check that whole project or package rather than the
152
+ named files. Tsc comes from the nearest `node_modules/.bin`, searching upward
153
+ as Node does, then `PATH`; it is never fetched, so a project whose dependencies
154
+ are not installed reports it as not installed.
155
+
148
156
  A tool that could not be reached at all is never skipped quietly:
149
157
 
150
158
  ```bash
@@ -9,8 +9,8 @@ quick access to style conventions without browsing HTML pages.
9
9
  ## Features
10
10
 
11
11
  - **Linting & Formatting**: A `check` command that automatically detects and
12
- runs relevant tools (Ruff, Pyrefly, Biome, gofmt, goimports, shfmt,
13
- shellcheck, and rustfmt) for your project.
12
+ runs relevant tools (Ruff, Pyrefly, Biome, tsc, gofmt, goimports, go vet,
13
+ shfmt, shellcheck, and rustfmt) for your project.
14
14
  - **Predictable Ownership**: Every supported format has fixed tools, so
15
15
  configuration customizes checks without changing which formatter runs.
16
16
  - **Style Guides**: A `guide` command that fetches the latest Google style
@@ -93,7 +93,8 @@ such as gofmt and goimports, are unaffected by it.
93
93
  | ---------------------------------------------------------------- | --------------------------------------- | ------------------------------------- |
94
94
  | `.py` | Ruff lint/format; Pyrefly type checking | Ruff and Pyrefly native configuration |
95
95
  | `.js`, `.jsx`, `.ts`, `.tsx`, `.json`, `.jsonc`, `.css`, `.html` | Biome | `biome.json` or `biome.jsonc` |
96
- | `.go` | gofmt, goimports | None |
96
+ | `.ts`, `.tsx` | tsc type checking | `tsconfig.json`, required |
97
+ | `.go` | gofmt, goimports; go vet | `go.mod`, required by go vet |
97
98
  | `.sh`, `.bash` | shfmt format; shellcheck lint | None |
98
99
  | `.rs` | rustfmt | None |
99
100
 
@@ -103,8 +104,8 @@ successfully.
103
104
 
104
105
  Biome first checks a project's `node_modules/.bin`. Ruff, Pyrefly, and Biome
105
106
  then use `PATH`, followed by `uvx` for the Python tools or `npx` for Biome. The
106
- runners cache downloads, so subsequent runs work offline. Gofmt and goimports
107
- must be available on `PATH`.
107
+ runners cache downloads, so subsequent runs work offline. Gofmt, goimports, and
108
+ Go itself, for go vet, must be available on `PATH`.
108
109
 
109
110
  That keeps this package at ~4 MB rather than the ~54 MB it would take to carry
110
111
  Ruff and Pyrefly itself — a cost that would fall on everyone using only `guide`.
@@ -131,6 +132,13 @@ Ruff, Pyrefly, and Biome ship with bundled configurations, so they run on every
131
132
  file they own without project setup. Gofmt and goimports run on `.go` files even
132
133
  when there is no `go.mod`.
133
134
 
135
+ Tsc and go vet have no bundled configuration, since neither can type-check a
136
+ file without its project's imports. They run only inside a `tsconfig.json`
137
+ project or a Go module, and check that whole project or package rather than the
138
+ named files. Tsc comes from the nearest `node_modules/.bin`, searching upward
139
+ as Node does, then `PATH`; it is never fetched, so a project whose dependencies
140
+ are not installed reports it as not installed.
141
+
134
142
  A tool that could not be reached at all is never skipped quietly:
135
143
 
136
144
  ```bash
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readability-cli"
3
- version = "0.11.1"
3
+ version = "0.12.0"
4
4
  description = "A CLI to lint, format, and type-check code with Google-style defaults, and pull Google style guides in markdown format."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -352,6 +352,8 @@ TOOL_EXTENSIONS = {
352
352
  "shfmt": (".sh", ".bash"),
353
353
  "shellcheck": (".sh", ".bash"),
354
354
  "rustfmt": (".rs",),
355
+ "tsc": (".ts", ".tsx"),
356
+ "go vet": (".go",),
355
357
  }
356
358
 
357
359
  # Headroom below common argv limits; long target lists are split before exec
@@ -390,6 +392,7 @@ CONFIG_SOURCES = {
390
392
  "--project-excludes",
391
393
  ),
392
394
  "biome": (("biome.json", "biome.jsonc"), None, "--config-path", None),
395
+ "tsc": (("tsconfig.json",), None, "-p", None),
393
396
  }
394
397
 
395
398
  # Words each phase needs, before config and targets
@@ -513,6 +516,82 @@ def _tool_command(binary: str, project_root: Path) -> list[str]:
513
516
  return TOOL_RUNNERS.get(binary, [binary])
514
517
 
515
518
 
519
+ def _tsc_command(project: Path) -> list[str]:
520
+ """Build the argv prefix that reaches a project's TypeScript compiler.
521
+
522
+ Args:
523
+ project: The directory holding the tsconfig.json.
524
+
525
+ Returns:
526
+ The nearest installed tsc, else whatever PATH resolves.
527
+ """
528
+ # Node resolves upward, which is where workspaces hoist it
529
+ for directory in (project, *project.parents):
530
+ local = directory / "node_modules" / ".bin" / "tsc"
531
+ if local.is_file() and os.access(local, os.X_OK):
532
+ return [str(local)]
533
+ return [shutil.which("tsc") or "tsc"]
534
+
535
+
536
+ def _type_checker_plans(path: Path, boundary: Path) -> list[ToolPlan]:
537
+ """Plan tsc and go vet, which only run inside a project they can build.
538
+
539
+ Both check whole projects or packages rather than the named files, since
540
+ neither can type-check a file without its imports.
541
+
542
+ Args:
543
+ path: The path being checked.
544
+ boundary: The outermost directory config discovery may consider.
545
+
546
+ Returns:
547
+ One plan per tsconfig.json and per Go module the path reaches.
548
+ """
549
+ plans = [
550
+ ToolPlan(
551
+ name="tsc",
552
+ extensions=TOOL_EXTENSIONS["tsc"],
553
+ check=(*_tsc_command(root), "--noEmit", "-p", str(root)),
554
+ )
555
+ for root, _, _ in _config_groups(path, boundary, "tsc")
556
+ if root is not None
557
+ ]
558
+
559
+ # ./... skips nested modules, so each of those needs its own run
560
+ modules = _config_roots_below(path, ("go.mod",), None, "go vet")
561
+ if _config_root(path, boundary, ("go.mod",), None):
562
+ if path.is_dir():
563
+ # A pattern matching no package is an error, not a pass
564
+ own = [
565
+ file
566
+ for file in _matching_paths(path, TOOL_EXTENSIONS["go vet"])
567
+ if not any(m in Path(file).resolve().parents for m in modules)
568
+ ]
569
+ if own:
570
+ modules.append(path.resolve())
571
+ else:
572
+ plans.append(_go_vet_plan(path.parent.resolve(), "."))
573
+ plans.extend(_go_vet_plan(module, "./...") for module in modules)
574
+ return plans
575
+
576
+
577
+ def _go_vet_plan(directory: Path, pattern: str) -> ToolPlan:
578
+ """Plan go vet over a package pattern, run where the pattern resolves.
579
+
580
+ Args:
581
+ directory: The directory the pattern is relative to.
582
+ pattern: The package pattern to vet.
583
+
584
+ Returns:
585
+ The plan.
586
+ """
587
+ return ToolPlan(
588
+ name="go vet",
589
+ extensions=TOOL_EXTENSIONS["go vet"],
590
+ check=("go", "vet", pattern),
591
+ cwd=directory,
592
+ )
593
+
594
+
516
595
  def _get_tool_definitions(
517
596
  path: Path, project_root: Path, boundary: Path | None = None
518
597
  ) -> list[ToolPlan]:
@@ -610,6 +689,8 @@ def _get_tool_definitions(
610
689
  )
611
690
  )
612
691
 
692
+ plans.extend(_type_checker_plans(path, boundary))
693
+
613
694
  # A directory owning its config alone lets Pyrefly select the files
614
695
  files, section = CONFIG_SOURCES["pyrefly"][:2]
615
696
  groups = _config_groups(path, boundary, "pyrefly")
@@ -0,0 +1,114 @@
1
+ from pathlib import Path
2
+
3
+ from readability.tools import _get_tool_definitions
4
+
5
+
6
+ def _plans(path: Path, root: Path, name: str) -> list:
7
+ return [p for p in _get_tool_definitions(path, root) if p.name == name]
8
+
9
+
10
+ def _executable(path: Path) -> Path:
11
+ path.parent.mkdir(parents=True, exist_ok=True)
12
+ path.write_text("#!/bin/sh\n")
13
+ path.chmod(0o755)
14
+ return path
15
+
16
+
17
+ def test_tsc_checks_the_project_that_owns_the_tsconfig(
18
+ tmp_path: Path,
19
+ ) -> None:
20
+ (tmp_path / "tsconfig.json").write_text("{}")
21
+ (tmp_path / "src").mkdir()
22
+ source = tmp_path / "src" / "app.ts"
23
+ source.touch()
24
+ tsc = _executable(tmp_path / "node_modules" / ".bin" / "tsc")
25
+
26
+ [plan] = _plans(source, tmp_path, "tsc")
27
+
28
+ assert plan.check == (str(tsc), "--noEmit", "-p", str(tmp_path.resolve()))
29
+ assert plan.format == plan.fix == plan.check_format == ()
30
+
31
+
32
+ def test_tsc_does_not_run_without_a_tsconfig(tmp_path: Path) -> None:
33
+ (tmp_path / "app.ts").touch()
34
+
35
+ assert _plans(tmp_path, tmp_path, "tsc") == []
36
+
37
+
38
+ def test_tsc_is_found_where_a_workspace_hoisted_it(tmp_path: Path) -> None:
39
+ package = tmp_path / "packages" / "web"
40
+ package.mkdir(parents=True)
41
+ (package / "tsconfig.json").write_text("{}")
42
+ (package / "app.ts").touch()
43
+ tsc = _executable(tmp_path / "node_modules" / ".bin" / "tsc")
44
+
45
+ [plan] = _plans(package, tmp_path, "tsc")
46
+
47
+ assert plan.check[0] == str(tsc)
48
+
49
+
50
+ def test_tsc_checks_each_nested_project_once(tmp_path: Path) -> None:
51
+ (tmp_path / "tsconfig.json").write_text("{}")
52
+ (tmp_path / "a.ts").touch()
53
+ (tmp_path / "web").mkdir()
54
+ (tmp_path / "web" / "tsconfig.json").write_text("{}")
55
+ (tmp_path / "web" / "b.ts").touch()
56
+ (tmp_path / "web" / "c.tsx").touch()
57
+
58
+ projects = sorted(p.check[-1] for p in _plans(tmp_path, tmp_path, "tsc"))
59
+
60
+ assert projects == sorted(
61
+ [str(tmp_path.resolve()), str((tmp_path / "web").resolve())]
62
+ )
63
+
64
+
65
+ def test_go_vet_checks_every_package_below_a_directory(
66
+ tmp_path: Path,
67
+ ) -> None:
68
+ (tmp_path / "go.mod").write_text("module example.com/m\n")
69
+ (tmp_path / "cmd").mkdir()
70
+ (tmp_path / "cmd" / "main.go").touch()
71
+
72
+ [plan] = _plans(tmp_path / "cmd", tmp_path, "go vet")
73
+
74
+ assert plan.check == ("go", "vet", "./...")
75
+ assert plan.cwd == (tmp_path / "cmd").resolve()
76
+
77
+
78
+ def test_go_vet_checks_a_files_whole_package(tmp_path: Path) -> None:
79
+ (tmp_path / "go.mod").write_text("module example.com/m\n")
80
+ source = tmp_path / "main.go"
81
+ source.touch()
82
+
83
+ [plan] = _plans(source, tmp_path, "go vet")
84
+
85
+ assert plan.check == ("go", "vet", ".")
86
+ assert plan.cwd == tmp_path.resolve()
87
+
88
+
89
+ def test_go_vet_does_not_run_outside_a_module(tmp_path: Path) -> None:
90
+ (tmp_path / "main.go").touch()
91
+
92
+ assert _plans(tmp_path, tmp_path, "go vet") == []
93
+
94
+
95
+ def test_go_vet_runs_inside_each_nested_module(tmp_path: Path) -> None:
96
+ (tmp_path / "tools").mkdir()
97
+ (tmp_path / "tools" / "go.mod").write_text("module example.com/t\n")
98
+ (tmp_path / "tools" / "gen.go").touch()
99
+
100
+ [plan] = _plans(tmp_path, tmp_path, "go vet")
101
+
102
+ assert plan.check == ("go", "vet", "./...")
103
+ assert plan.cwd == (tmp_path / "tools").resolve()
104
+
105
+
106
+ def test_go_vet_skips_a_module_whose_go_is_all_nested(tmp_path: Path) -> None:
107
+ (tmp_path / "go.mod").write_text("module example.com/m\n")
108
+ (tmp_path / "tools").mkdir()
109
+ (tmp_path / "tools" / "go.mod").write_text("module example.com/t\n")
110
+ (tmp_path / "tools" / "gen.go").touch()
111
+
112
+ [plan] = _plans(tmp_path, tmp_path, "go vet")
113
+
114
+ assert plan.cwd == (tmp_path / "tools").resolve()
@@ -198,7 +198,7 @@ wheels = [
198
198
 
199
199
  [[package]]
200
200
  name = "readability-cli"
201
- version = "0.11.1"
201
+ version = "0.12.0"
202
202
  source = { editable = "." }
203
203
  dependencies = [
204
204
  { name = "click" },