typedframes 0.14.3__tar.gz → 0.14.4__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.
- {typedframes-0.14.3 → typedframes-0.14.4}/PKG-INFO +12 -12
- {typedframes-0.14.3 → typedframes-0.14.4}/README.md +11 -11
- {typedframes-0.14.3 → typedframes-0.14.4}/pyproject.toml +2 -2
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/Cargo.lock +2 -2
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/Cargo.toml +1 -1
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/python/Cargo.toml +1 -1
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/args.rs +3 -1
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/report.rs +25 -9
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/column_usage.rs +43 -3
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/engine.rs +12 -4
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/helpers.rs +29 -2
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/linter.rs +633 -34
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/report.rs +288 -28
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/static_eval.rs +21 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/suggest.rs +125 -2
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/tests/cli.rs +60 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/__init__.py +1 -1
- {typedframes-0.14.3 → typedframes-0.14.4}/.cargo/config.toml +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/LICENSE +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/README.md +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/benches/parser_bench.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/build.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/python/build.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/python/src/lib.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/python-data/scripts/typedframes-py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/apply.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/ast_extract.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/call_usage.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/cache.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/check.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/collect.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/config.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/coverage.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/mod.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/pathutil.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/pyfmt.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/style.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/cli/suggest.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/column_consuming_methods.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/config.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/constants.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/contract.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/errors.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/fast_hash.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/frame_ops.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/index.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/lib.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/library_names.txt +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/main.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/notebook.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/parallel.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/phrase.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/report_minimize.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/report_names.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/sql.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/typo.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/src/words.txt +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/rust/tests/integration_test.rs +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/__main__.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/_binary.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/_rust.pyi +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/base_schema.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/column.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/column_group.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/column_group_error.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/column_set.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/missing_dependency_error.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/mypy.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/pandera.py +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/py.typed +0 -0
- {typedframes-0.14.3 → typedframes-0.14.4}/src/typedframes/schema_algebra.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: typedframes
|
|
3
|
-
Version: 0.14.
|
|
3
|
+
Version: 0.14.4
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -44,7 +44,7 @@ Project-URL: Repository, https://github.com/w-martin/typedframes
|
|
|
44
44
|
|
|
45
45
|
> ⚠️ **Project Status: Proof of Concept**
|
|
46
46
|
>
|
|
47
|
-
> `typedframes` (v0.14.
|
|
47
|
+
> `typedframes` (v0.14.4) is currently an experimental proof-of-concept. The core static analysis and mypy/Rust
|
|
48
48
|
> integrations work, but expect rough edges. The codebase prioritizes demonstrating the viability of static DataFrame
|
|
49
49
|
> column checking over production-grade stability.
|
|
50
50
|
>
|
|
@@ -515,7 +515,7 @@ repos:
|
|
|
515
515
|
name: typedframes check
|
|
516
516
|
entry: typedframes check . --strict
|
|
517
517
|
language: python
|
|
518
|
-
additional_dependencies: ["typedframes==0.14.
|
|
518
|
+
additional_dependencies: ["typedframes==0.14.4"]
|
|
519
519
|
types_or: [python, jupyter]
|
|
520
520
|
pass_filenames: false
|
|
521
521
|
```
|
|
@@ -564,7 +564,7 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
564
564
|
| Input | Default | |
|
|
565
565
|
|-------|---------|-|
|
|
566
566
|
| `path` | `.` | File or directory to check |
|
|
567
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.14.
|
|
567
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.14.4"` |
|
|
568
568
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
569
569
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
570
570
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
@@ -592,7 +592,7 @@ and the files are written together or not at all. See the
|
|
|
592
592
|
|
|
593
593
|
If `check` or `suggest` gets a site wrong and the code can't be shared, `typedframes report quiet-amber src/` prints a
|
|
594
594
|
bug-report body with a redacted copy of the code around that site, checked against the checker so it reproduces the same
|
|
595
|
-
result. `typedframes report --all src/` does this for every untyped site, grouped by why the checker decided as it did; add `--format compact` for a few lines per group that fit in one screenshot.
|
|
595
|
+
result. `typedframes report --all src/` does this for every untyped site, grouped by why the checker decided as it did; add `--format compact` for a few lines per group that fit in one screenshot. A frame passed to a call the checker can't follow says what kind of callee it was (a function in this file, an imported function with no summary, a method of another object, ...), and `--outcome untracked` lists the frames used like a DataFrame that the checker doesn't track at all.
|
|
596
596
|
Redacted is not anonymous: read it before posting, and don't use it on code you aren't allowed to share. See
|
|
597
597
|
[Reporting a problem](docs/usage.md#reporting-a-problem-report), and
|
|
598
598
|
[Security and data handling](docs/security.md) for what the tool reads, writes and connects to.
|
|
@@ -708,13 +708,13 @@ Fast feedback reduces development time. The typedframes Rust binary provides nea
|
|
|
708
708
|
|
|
709
709
|
| Tool | Version | What it does | typedframes (12 files) | great_expectations (494 files) |
|
|
710
710
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
711
|
-
| typedframes | 0.14.
|
|
712
|
-
| ruff | 0.17.1 | Linter (no type checking) |
|
|
713
|
-
| ty | 0.0.89 | Type checker |
|
|
714
|
-
| pyrefly | 1.4.0 | Type checker |
|
|
715
|
-
| mypy | 2.4.0 | Type checker (no plugin) |
|
|
716
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker |
|
|
717
|
-
| pyright | 1.1.414 | Type checker |
|
|
711
|
+
| typedframes | 0.14.4 | DataFrame column checker | 21.1 ± 0.4 ms | 49.4 ± 0.5 ms |
|
|
712
|
+
| ruff | 0.17.1 | Linter (no type checking) | 26.4 ± 1.6 ms | 227.1 ± 1.6 ms |
|
|
713
|
+
| ty | 0.0.89 | Type checker | 51.4 ± 0.7 ms | 778.8 ± 8.8 ms |
|
|
714
|
+
| pyrefly | 1.4.0 | Type checker | 110.8 ± 15.2 ms | 333.5 ± 10.3 ms |
|
|
715
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 1.88 ± 0.11 s | 3.15 ± 0.02 s |
|
|
716
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.91 ± 0.02 s | 3.29 ± 0.01 s |
|
|
717
|
+
| pyright | 1.1.414 | Type checker | 683.7 ± 2.5 ms | 4.01 ± 0.08 s |
|
|
718
718
|
|
|
719
719
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
720
720
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> ⚠️ **Project Status: Proof of Concept**
|
|
10
10
|
>
|
|
11
|
-
> `typedframes` (v0.14.
|
|
11
|
+
> `typedframes` (v0.14.4) is currently an experimental proof-of-concept. The core static analysis and mypy/Rust
|
|
12
12
|
> integrations work, but expect rough edges. The codebase prioritizes demonstrating the viability of static DataFrame
|
|
13
13
|
> column checking over production-grade stability.
|
|
14
14
|
>
|
|
@@ -479,7 +479,7 @@ repos:
|
|
|
479
479
|
name: typedframes check
|
|
480
480
|
entry: typedframes check . --strict
|
|
481
481
|
language: python
|
|
482
|
-
additional_dependencies: ["typedframes==0.14.
|
|
482
|
+
additional_dependencies: ["typedframes==0.14.4"]
|
|
483
483
|
types_or: [python, jupyter]
|
|
484
484
|
pass_filenames: false
|
|
485
485
|
```
|
|
@@ -528,7 +528,7 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
528
528
|
| Input | Default | |
|
|
529
529
|
|-------|---------|-|
|
|
530
530
|
| `path` | `.` | File or directory to check |
|
|
531
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.14.
|
|
531
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.14.4"` |
|
|
532
532
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
533
533
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
534
534
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
@@ -556,7 +556,7 @@ and the files are written together or not at all. See the
|
|
|
556
556
|
|
|
557
557
|
If `check` or `suggest` gets a site wrong and the code can't be shared, `typedframes report quiet-amber src/` prints a
|
|
558
558
|
bug-report body with a redacted copy of the code around that site, checked against the checker so it reproduces the same
|
|
559
|
-
result. `typedframes report --all src/` does this for every untyped site, grouped by why the checker decided as it did; add `--format compact` for a few lines per group that fit in one screenshot.
|
|
559
|
+
result. `typedframes report --all src/` does this for every untyped site, grouped by why the checker decided as it did; add `--format compact` for a few lines per group that fit in one screenshot. A frame passed to a call the checker can't follow says what kind of callee it was (a function in this file, an imported function with no summary, a method of another object, ...), and `--outcome untracked` lists the frames used like a DataFrame that the checker doesn't track at all.
|
|
560
560
|
Redacted is not anonymous: read it before posting, and don't use it on code you aren't allowed to share. See
|
|
561
561
|
[Reporting a problem](docs/usage.md#reporting-a-problem-report), and
|
|
562
562
|
[Security and data handling](docs/security.md) for what the tool reads, writes and connects to.
|
|
@@ -672,13 +672,13 @@ Fast feedback reduces development time. The typedframes Rust binary provides nea
|
|
|
672
672
|
|
|
673
673
|
| Tool | Version | What it does | typedframes (12 files) | great_expectations (494 files) |
|
|
674
674
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
675
|
-
| typedframes | 0.14.
|
|
676
|
-
| ruff | 0.17.1 | Linter (no type checking) |
|
|
677
|
-
| ty | 0.0.89 | Type checker |
|
|
678
|
-
| pyrefly | 1.4.0 | Type checker |
|
|
679
|
-
| mypy | 2.4.0 | Type checker (no plugin) |
|
|
680
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker |
|
|
681
|
-
| pyright | 1.1.414 | Type checker |
|
|
675
|
+
| typedframes | 0.14.4 | DataFrame column checker | 21.1 ± 0.4 ms | 49.4 ± 0.5 ms |
|
|
676
|
+
| ruff | 0.17.1 | Linter (no type checking) | 26.4 ± 1.6 ms | 227.1 ± 1.6 ms |
|
|
677
|
+
| ty | 0.0.89 | Type checker | 51.4 ± 0.7 ms | 778.8 ± 8.8 ms |
|
|
678
|
+
| pyrefly | 1.4.0 | Type checker | 110.8 ± 15.2 ms | 333.5 ± 10.3 ms |
|
|
679
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 1.88 ± 0.11 s | 3.15 ± 0.02 s |
|
|
680
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.91 ± 0.02 s | 3.29 ± 0.01 s |
|
|
681
|
+
| pyright | 1.1.414 | Type checker | 683.7 ± 2.5 ms | 4.01 ± 0.08 s |
|
|
682
682
|
|
|
683
683
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
684
684
|
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "typedframes"
|
|
7
|
-
version = "0.14.
|
|
7
|
+
version = "0.14.4"
|
|
8
8
|
description = "Static analysis for pandas and polars DataFrames. Catch column errors at lint-time, not runtime."
|
|
9
9
|
keywords = ["pandas", "polars", "type-checking", "static-analysis", "dataframe", "linter", "mypy-plugin"]
|
|
10
10
|
readme = "README.md"
|
|
@@ -100,7 +100,7 @@ ignore = [
|
|
|
100
100
|
|
|
101
101
|
[tool.ruff.lint.per-file-ignores]
|
|
102
102
|
"tests/*" = ["S101", "SLF001", "S603", "S607"]
|
|
103
|
-
"tests/fixtures/*" = ["T201"]
|
|
103
|
+
"tests/fixtures/*" = ["T201", "ANN", "ARG", "B007", "D", "F841", "INP001", "PD011", "RET504"]
|
|
104
104
|
"examples/*" = ["T201", "INP001", "D100", "D101", "D103", "BLE001", "ERA001", "F821", "PLR2004"]
|
|
105
105
|
# S608: these connector examples deliberately build a query at runtime (an f-string, not
|
|
106
106
|
# a literal) to demonstrate the untracked-dataframe case -- not a real injection risk in
|
|
@@ -1469,7 +1469,7 @@ checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
|
|
|
1469
1469
|
|
|
1470
1470
|
[[package]]
|
|
1471
1471
|
name = "typedframes_checker"
|
|
1472
|
-
version = "0.14.
|
|
1472
|
+
version = "0.14.4"
|
|
1473
1473
|
dependencies = [
|
|
1474
1474
|
"anyhow",
|
|
1475
1475
|
"clap",
|
|
@@ -1491,7 +1491,7 @@ dependencies = [
|
|
|
1491
1491
|
|
|
1492
1492
|
[[package]]
|
|
1493
1493
|
name = "typedframes_python"
|
|
1494
|
-
version = "0.14.
|
|
1494
|
+
version = "0.14.4"
|
|
1495
1495
|
dependencies = [
|
|
1496
1496
|
"pyo3",
|
|
1497
1497
|
"pyo3-build-config",
|
|
@@ -169,6 +169,8 @@ pub(crate) struct SuggestArgs {
|
|
|
169
169
|
pub(crate) enum Outcome {
|
|
170
170
|
Suggested,
|
|
171
171
|
Withheld,
|
|
172
|
+
/// Frames used like a DataFrame that the checker does not track at all.
|
|
173
|
+
Untracked,
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, ValueEnum)]
|
|
@@ -188,7 +190,7 @@ pub(crate) struct ReportArgs {
|
|
|
188
190
|
/// Report every untyped site, grouped by why the checker decided as it did. Takes PATH, not NAME.
|
|
189
191
|
#[arg(long)]
|
|
190
192
|
pub(crate) all: bool,
|
|
191
|
-
/// With --all, only the sites the checker decided this way about.
|
|
193
|
+
/// With --all, only the sites the checker decided this way about. `untracked` lists instead the frames used like a DataFrame that the checker does not track, which are in no other report.
|
|
192
194
|
#[arg(long, value_enum)]
|
|
193
195
|
pub(crate) outcome: Option<Outcome>,
|
|
194
196
|
/// With --all, how to print the groups (default: markdown).
|
|
@@ -147,12 +147,14 @@ fn names(group: &Group) -> Vec<&str> {
|
|
|
147
147
|
group.iter().map(|r| text(r, "name")).collect()
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
fn format_report_groups(groups: &[Group]) -> String {
|
|
150
|
+
fn format_report_groups(groups: &[Group], untracked: bool) -> String {
|
|
151
151
|
let total: usize = groups.iter().map(Vec::len).sum();
|
|
152
|
-
let
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
let noun = if untracked {
|
|
153
|
+
"untracked frame"
|
|
154
|
+
} else {
|
|
155
|
+
"untyped site"
|
|
156
|
+
};
|
|
157
|
+
let sites = format!("{total} {noun}{}", if total == 1 { "" } else { "s" });
|
|
156
158
|
let group_count = format!(
|
|
157
159
|
"{} {}",
|
|
158
160
|
groups.len(),
|
|
@@ -280,6 +282,10 @@ fn write_report_groups(groups: &[Group], directory: &Path) -> io::Result<Vec<Pat
|
|
|
280
282
|
// The site name (None with --all) and path a `report` call names; exit status 2 on a bad
|
|
281
283
|
// combination.
|
|
282
284
|
fn report_target(args: &ReportArgs) -> Result<(Option<String>, PathBuf), i32> {
|
|
285
|
+
if args.outcome.is_some() && !args.all {
|
|
286
|
+
eprintln!("Error: `--outcome` needs --all");
|
|
287
|
+
return Err(2);
|
|
288
|
+
}
|
|
283
289
|
if args.all {
|
|
284
290
|
if args.name.is_some() && args.path != Path::new(".") {
|
|
285
291
|
eprintln!("Error: `report --all` takes a path, not a site name");
|
|
@@ -315,7 +321,8 @@ fn run_report_all(args: &ReportArgs, path: &Path, out: &mut impl Write) -> io::R
|
|
|
315
321
|
.map(|f| f.to_string_lossy().into_owned())
|
|
316
322
|
.collect();
|
|
317
323
|
let mut reports: Vec<Value> = Vec::new();
|
|
318
|
-
|
|
324
|
+
let untracked = args.outcome == Some(Outcome::Untracked);
|
|
325
|
+
for (name, (result, error)) in names.iter().zip(report_all_batch(&names, index, untracked)) {
|
|
319
326
|
let Some(found) = result
|
|
320
327
|
.as_deref()
|
|
321
328
|
.and_then(|j| serde_json::from_str::<Value>(j).ok())
|
|
@@ -329,11 +336,17 @@ fn run_report_all(args: &ReportArgs, path: &Path, out: &mut impl Write) -> io::R
|
|
|
329
336
|
let wanted = match outcome {
|
|
330
337
|
Outcome::Suggested => "suggested",
|
|
331
338
|
Outcome::Withheld => "withheld",
|
|
339
|
+
Outcome::Untracked => "untracked",
|
|
332
340
|
};
|
|
333
341
|
reports.retain(|r| text(&r["verdict"], "outcome") == wanted);
|
|
334
342
|
}
|
|
335
343
|
if reports.is_empty() {
|
|
336
|
-
|
|
344
|
+
let none = if untracked {
|
|
345
|
+
"No untracked frames."
|
|
346
|
+
} else {
|
|
347
|
+
"No untyped sites."
|
|
348
|
+
};
|
|
349
|
+
writeln!(out, "{none}")?;
|
|
337
350
|
return Ok(0);
|
|
338
351
|
}
|
|
339
352
|
let groups = group_reports(reports);
|
|
@@ -346,7 +359,7 @@ fn run_report_all(args: &ReportArgs, path: &Path, out: &mut impl Write) -> io::R
|
|
|
346
359
|
} else if args.report_format == ReportFormat::Compact {
|
|
347
360
|
writeln!(out, "{}", format_report_groups_compact(&groups))?;
|
|
348
361
|
} else {
|
|
349
|
-
writeln!(out, "{}", format_report_groups(&groups))?;
|
|
362
|
+
writeln!(out, "{}", format_report_groups(&groups, untracked))?;
|
|
350
363
|
}
|
|
351
364
|
eprintln!("{REVIEW_REMINDER}");
|
|
352
365
|
Ok(0)
|
|
@@ -398,7 +411,10 @@ pub(crate) fn run_report(args: &ReportArgs, out: &mut impl Write) -> io::Result<
|
|
|
398
411
|
}
|
|
399
412
|
}
|
|
400
413
|
if matches.is_empty() {
|
|
401
|
-
eprintln!(
|
|
414
|
+
eprintln!(
|
|
415
|
+
"Error: no untyped site or untracked frame is named {}",
|
|
416
|
+
repr_str(&name)
|
|
417
|
+
);
|
|
402
418
|
return Ok(2);
|
|
403
419
|
}
|
|
404
420
|
if matches.len() > 1 {
|
|
@@ -69,6 +69,12 @@ pub(crate) trait HelperResolver {
|
|
|
69
69
|
fn method_usage_of(&self, _method: &str) -> Option<Vec<ParamUsage>> {
|
|
70
70
|
None
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
/// What kind of function `func` is, for the reason a frame passed to it can't be
|
|
74
|
+
/// followed (one of the `CALLEE_*` labels), or `None` when it can't be told.
|
|
75
|
+
fn callee_class(&self, _func: &Expr) -> Option<&'static str> {
|
|
76
|
+
None
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/// A resolver that knows no function: every call is an unknown use.
|
|
@@ -126,8 +132,24 @@ pub struct OtherUse {
|
|
|
126
132
|
/// See `ColumnAccess::line`.
|
|
127
133
|
#[serde(skip)]
|
|
128
134
|
pub(crate) line: usize,
|
|
135
|
+
/// For a frame passed to a call the checker can't follow: what kind of callee it is,
|
|
136
|
+
/// in words that name nothing from the user's code.
|
|
137
|
+
#[serde(skip)]
|
|
138
|
+
pub(crate) callee: Option<&'static str>,
|
|
129
139
|
}
|
|
130
140
|
|
|
141
|
+
pub(crate) const CALLEE_SAME_FILE: &str =
|
|
142
|
+
"a function in this file whose use of the frame can't be followed";
|
|
143
|
+
pub(crate) const CALLEE_IMPORTED: &str = "an imported function the checker has no summary of";
|
|
144
|
+
pub(crate) const CALLEE_UNBOUND: &str =
|
|
145
|
+
"a name this file never defines or imports (a builtin, or from a star import)";
|
|
146
|
+
pub(crate) const CALLEE_MODULE_FUNCTION: &str = "a function of an imported module";
|
|
147
|
+
pub(crate) const CALLEE_IMPORTED_NAME: &str =
|
|
148
|
+
"a function or method reached through an imported name";
|
|
149
|
+
pub(crate) const CALLEE_OWN_METHOD: &str = "a method of this class that can't be followed";
|
|
150
|
+
pub(crate) const CALLEE_OTHER_METHOD: &str = "a method of another object";
|
|
151
|
+
pub(crate) const CALLEE_FORWARDS: &str = "a function that returns, stores or forwards the frame";
|
|
152
|
+
|
|
131
153
|
#[derive(Debug, Clone, Default, PartialEq)]
|
|
132
154
|
pub(crate) struct ColumnUsage {
|
|
133
155
|
pub(crate) accesses: Vec<ColumnAccess>,
|
|
@@ -420,9 +442,15 @@ impl UsageScan<'_> {
|
|
|
420
442
|
passed: &str,
|
|
421
443
|
via: Option<&str>,
|
|
422
444
|
summary: Option<&ParamUsage>,
|
|
445
|
+
callee: Option<&'static str>,
|
|
423
446
|
) {
|
|
424
447
|
let (Some(summary), Some(via)) = (summary, via) else {
|
|
425
|
-
|
|
448
|
+
let callee = if via.is_some() {
|
|
449
|
+
Some(CALLEE_FORWARDS)
|
|
450
|
+
} else {
|
|
451
|
+
callee
|
|
452
|
+
};
|
|
453
|
+
self.record_other_via(at, passed.to_string(), Consumption::Unknown, callee);
|
|
426
454
|
return;
|
|
427
455
|
};
|
|
428
456
|
let line = (self.line_of)(at);
|
|
@@ -540,6 +568,16 @@ impl UsageScan<'_> {
|
|
|
540
568
|
at: TextSize,
|
|
541
569
|
description: impl Into<String>,
|
|
542
570
|
consumes: Consumption,
|
|
571
|
+
) {
|
|
572
|
+
self.record_other_via(at, description, consumes, None);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
fn record_other_via(
|
|
576
|
+
&mut self,
|
|
577
|
+
at: TextSize,
|
|
578
|
+
description: impl Into<String>,
|
|
579
|
+
consumes: Consumption,
|
|
580
|
+
callee: Option<&'static str>,
|
|
543
581
|
) {
|
|
544
582
|
let line = (self.line_of)(at);
|
|
545
583
|
self.usage.other_uses.push(OtherUse {
|
|
@@ -547,6 +585,7 @@ impl UsageScan<'_> {
|
|
|
547
585
|
conditional: self.depth > 0,
|
|
548
586
|
consumes,
|
|
549
587
|
line,
|
|
588
|
+
callee,
|
|
550
589
|
});
|
|
551
590
|
}
|
|
552
591
|
|
|
@@ -942,13 +981,14 @@ impl UsageScan<'_> {
|
|
|
942
981
|
_ => passed_to(&call.func),
|
|
943
982
|
};
|
|
944
983
|
let resolved = self.summaries_for(&call.func);
|
|
984
|
+
let callee_class = self.helpers.callee_class(&call.func);
|
|
945
985
|
let via = resolved.as_ref().map(|(name, _)| name.as_str());
|
|
946
986
|
let summaries = resolved.as_ref().map(|(_, all)| all);
|
|
947
987
|
for (position, arg) in call.arguments.args.iter().enumerate() {
|
|
948
988
|
if self.is_tainted(arg) {
|
|
949
989
|
let summary =
|
|
950
990
|
summaries.and_then(|all| all.iter().find(|p| p.position == position));
|
|
951
|
-
self.passed_argument(at, &passed, via, summary);
|
|
991
|
+
self.passed_argument(at, &passed, via, summary, callee_class);
|
|
952
992
|
} else {
|
|
953
993
|
self.visit_expr(arg);
|
|
954
994
|
}
|
|
@@ -958,7 +998,7 @@ impl UsageScan<'_> {
|
|
|
958
998
|
let summary = kw.arg.as_ref().and_then(|name| {
|
|
959
999
|
summaries.and_then(|all| all.iter().find(|p| p.name == name.as_str()))
|
|
960
1000
|
});
|
|
961
|
-
self.passed_argument(at, &passed, via, summary);
|
|
1001
|
+
self.passed_argument(at, &passed, via, summary, callee_class);
|
|
962
1002
|
} else {
|
|
963
1003
|
self.visit_expr(&kw.value);
|
|
964
1004
|
}
|
|
@@ -144,9 +144,16 @@ pub(crate) fn report_all_file_impl(
|
|
|
144
144
|
file_path: &str,
|
|
145
145
|
index: Option<Arc<ProjectIndex>>,
|
|
146
146
|
contexts: &ProjectContexts,
|
|
147
|
+
untracked: bool,
|
|
147
148
|
) -> Result<String, CheckError> {
|
|
148
149
|
let reports = checked_for_report(file_path, index, contexts)?
|
|
149
|
-
.map(|(source, linter)|
|
|
150
|
+
.map(|(source, linter)| {
|
|
151
|
+
if untracked {
|
|
152
|
+
crate::report::untracked_all(&source, &linter)
|
|
153
|
+
} else {
|
|
154
|
+
crate::report::report_all(&source, &linter)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
150
157
|
.unwrap_or_default();
|
|
151
158
|
serde_json::to_string(&reports).map_err(runtime)
|
|
152
159
|
}
|
|
@@ -226,17 +233,18 @@ pub(crate) fn report_batch(
|
|
|
226
233
|
)
|
|
227
234
|
}
|
|
228
235
|
|
|
229
|
-
/// Every untyped site's report in each file (a JSON array),
|
|
230
|
-
/// input order.
|
|
236
|
+
/// Every untyped site's report in each file (a JSON array), or with `untracked` the report of every
|
|
237
|
+
/// frame the checker does not track, in parallel, as one outcome per file in input order.
|
|
231
238
|
pub(crate) fn report_all_batch(
|
|
232
239
|
files: &[String],
|
|
233
240
|
index: Option<Arc<ProjectIndex>>,
|
|
241
|
+
untracked: bool,
|
|
234
242
|
) -> Vec<FileOutcome> {
|
|
235
243
|
let contexts = ProjectContexts::default();
|
|
236
244
|
run_batch(
|
|
237
245
|
files,
|
|
238
246
|
|file| file,
|
|
239
|
-
|file| report_all_file_impl(file, index.clone(), &contexts),
|
|
247
|
+
|file| report_all_file_impl(file, index.clone(), &contexts, untracked),
|
|
240
248
|
)
|
|
241
249
|
}
|
|
242
250
|
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
use crate::column_usage::{
|
|
11
11
|
blocks_narrowing, declares_global_or_nonlocal, first_nested_scope_mention, scan_usage_with,
|
|
12
|
-
HelperResolver, ParamUsage,
|
|
12
|
+
HelperResolver, ParamUsage, CALLEE_IMPORTED, CALLEE_IMPORTED_NAME, CALLEE_MODULE_FUNCTION,
|
|
13
|
+
CALLEE_OTHER_METHOD, CALLEE_OWN_METHOD, CALLEE_SAME_FILE, CALLEE_UNBOUND,
|
|
13
14
|
};
|
|
14
|
-
use crate::static_eval::{Analysis, CalleeBinding};
|
|
15
|
+
use crate::static_eval::{Analysis, CalleeBinding, ImportKind};
|
|
15
16
|
use ruff_python_ast::{self as ast, ModModule, Stmt};
|
|
16
17
|
use ruff_text_size::{Ranged, TextSize};
|
|
17
18
|
use std::cell::RefCell;
|
|
@@ -153,6 +154,32 @@ impl HelperResolver for FileHelpers<'_> {
|
|
|
153
154
|
)
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
fn callee_class(&self, func: &ast::Expr) -> Option<&'static str> {
|
|
158
|
+
match func {
|
|
159
|
+
ast::Expr::Name(name) => {
|
|
160
|
+
if self.analysis.is_unbound_name(name) {
|
|
161
|
+
return Some(CALLEE_UNBOUND);
|
|
162
|
+
}
|
|
163
|
+
match self.analysis.callee_binding(name)? {
|
|
164
|
+
CalleeBinding::Function(_) => Some(CALLEE_SAME_FILE),
|
|
165
|
+
CalleeBinding::Imported { .. } => Some(CALLEE_IMPORTED),
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
ast::Expr::Attribute(attribute) => {
|
|
169
|
+
let ast::Expr::Name(base) = &*attribute.value else {
|
|
170
|
+
return None;
|
|
171
|
+
};
|
|
172
|
+
Some(match self.analysis.import_kind(base) {
|
|
173
|
+
Some(ImportKind::Module) => CALLEE_MODULE_FUNCTION,
|
|
174
|
+
Some(ImportKind::From) => CALLEE_IMPORTED_NAME,
|
|
175
|
+
None if matches!(base.id.as_str(), "self" | "cls") => CALLEE_OWN_METHOD,
|
|
176
|
+
None => CALLEE_OTHER_METHOD,
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
_ => None,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
156
183
|
fn usage_of(&self, callee: &ast::ExprName) -> Option<Vec<ParamUsage>> {
|
|
157
184
|
match self.analysis.callee_binding(callee)? {
|
|
158
185
|
CalleeBinding::Function(def) => self.summarize(def),
|