typedframes 0.14.1__tar.gz → 0.14.3__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.1 → typedframes-0.14.3}/PKG-INFO +14 -13
- {typedframes-0.14.1 → typedframes-0.14.3}/README.md +13 -12
- {typedframes-0.14.1 → typedframes-0.14.3}/pyproject.toml +6 -4
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/Cargo.lock +2 -3
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/Cargo.toml +9 -3
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/python/Cargo.toml +1 -1
- typedframes-0.14.3/rust/python-data/scripts/typedframes-py +4 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/config.rs +128 -33
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/coverage.rs +4 -5
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/report.rs +4 -7
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/sql.rs +96 -20
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/__init__.py +1 -1
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/_binary.py +5 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/.cargo/config.toml +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/LICENSE +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/README.md +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/benches/parser_bench.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/build.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/python/build.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/python/src/lib.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/apply.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/ast_extract.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/call_usage.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/args.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/cache.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/check.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/collect.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/mod.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/pathutil.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/pyfmt.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/style.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/cli/suggest.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/column_consuming_methods.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/column_usage.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/config.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/constants.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/contract.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/engine.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/errors.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/fast_hash.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/frame_ops.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/helpers.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/index.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/lib.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/library_names.txt +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/linter.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/main.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/notebook.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/parallel.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/phrase.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/report.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/report_minimize.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/report_names.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/static_eval.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/suggest.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/typo.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/src/words.txt +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/tests/cli.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/rust/tests/integration_test.rs +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/__main__.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/_rust.pyi +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/base_schema.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/column.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/column_group.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/column_group_error.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/column_set.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/missing_dependency_error.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/mypy.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/pandera.py +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/src/typedframes/py.typed +0 -0
- {typedframes-0.14.1 → typedframes-0.14.3}/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.3
|
|
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.3) 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
|
>
|
|
@@ -145,7 +145,8 @@ Where the Python interpreter may run code but no other executable may be started
|
|
|
145
145
|
the wheel, instead of starting the `typedframes` executable. Results and exit status are the same; when the checker is
|
|
146
146
|
asked to capture its output (as the mypy plugin does), a usage error or a missing path comes back with it, and any
|
|
147
147
|
warning a command prints still goes to the terminal. Without the extension installed (for example from a source
|
|
148
|
-
distribution) `TYPEDFRAMES_INPROC=1` is an error.
|
|
148
|
+
distribution) `TYPEDFRAMES_INPROC=1` is an error. The `typedframes-py` command always runs in the interpreter, without
|
|
149
|
+
the variable.
|
|
149
150
|
|
|
150
151
|
---
|
|
151
152
|
|
|
@@ -514,7 +515,7 @@ repos:
|
|
|
514
515
|
name: typedframes check
|
|
515
516
|
entry: typedframes check . --strict
|
|
516
517
|
language: python
|
|
517
|
-
additional_dependencies: ["typedframes==0.14.
|
|
518
|
+
additional_dependencies: ["typedframes==0.14.3"]
|
|
518
519
|
types_or: [python, jupyter]
|
|
519
520
|
pass_filenames: false
|
|
520
521
|
```
|
|
@@ -563,7 +564,7 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
563
564
|
| Input | Default | |
|
|
564
565
|
|-------|---------|-|
|
|
565
566
|
| `path` | `.` | File or directory to check |
|
|
566
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.14.
|
|
567
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.14.3"` |
|
|
567
568
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
568
569
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
569
570
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
@@ -703,17 +704,17 @@ plus the requested features, so both halves get checked normally. See
|
|
|
703
704
|
Fast feedback reduces development time. The typedframes Rust binary provides near-instant column checking.
|
|
704
705
|
|
|
705
706
|
**Benchmark results** (median of 5 runs ± one standard deviation, 3 warmup, caches cleared between runs):
|
|
706
|
-
*2026-10-
|
|
707
|
+
*2026-10-18 · Darwin 27.0.0 · arm · CPython 3.15.0 · 64GiB RAM · Great Expectations pinned @ 1.23.2*
|
|
707
708
|
|
|
708
709
|
| Tool | Version | What it does | typedframes (12 files) | great_expectations (494 files) |
|
|
709
710
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
710
|
-
| typedframes | 0.14.
|
|
711
|
-
| ruff | 0.17.
|
|
712
|
-
| ty | 0.0.
|
|
713
|
-
| pyrefly | 1.
|
|
714
|
-
| mypy | 2.4.0 | Type checker (no plugin) |
|
|
715
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker |
|
|
716
|
-
| pyright | 1.1.414 | Type checker |
|
|
711
|
+
| typedframes | 0.14.2 | DataFrame column checker | 21.2 ± 0.8 ms | 50.8 ± 0.6 ms |
|
|
712
|
+
| ruff | 0.17.1 | Linter (no type checking) | 25.9 ± 0.4 ms | 224.4 ± 3.4 ms |
|
|
713
|
+
| ty | 0.0.89 | Type checker | 52.5 ± 0.6 ms | 818.7 ± 24.5 ms |
|
|
714
|
+
| pyrefly | 1.4.0 | Type checker | 116.8 ± 5.8 ms | 323.6 ± 10.1 ms |
|
|
715
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 2.01 ± 0.14 s | 3.37 ± 0.03 s |
|
|
716
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 2.04 ± 0.02 s | 3.68 ± 0.10 s |
|
|
717
|
+
| pyright | 1.1.414 | Type checker | 714.9 ± 20.2 ms | 4.59 ± 0.33 s |
|
|
717
718
|
|
|
718
719
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
719
720
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> ⚠️ **Project Status: Proof of Concept**
|
|
10
10
|
>
|
|
11
|
-
> `typedframes` (v0.14.
|
|
11
|
+
> `typedframes` (v0.14.3) 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
|
>
|
|
@@ -109,7 +109,8 @@ Where the Python interpreter may run code but no other executable may be started
|
|
|
109
109
|
the wheel, instead of starting the `typedframes` executable. Results and exit status are the same; when the checker is
|
|
110
110
|
asked to capture its output (as the mypy plugin does), a usage error or a missing path comes back with it, and any
|
|
111
111
|
warning a command prints still goes to the terminal. Without the extension installed (for example from a source
|
|
112
|
-
distribution) `TYPEDFRAMES_INPROC=1` is an error.
|
|
112
|
+
distribution) `TYPEDFRAMES_INPROC=1` is an error. The `typedframes-py` command always runs in the interpreter, without
|
|
113
|
+
the variable.
|
|
113
114
|
|
|
114
115
|
---
|
|
115
116
|
|
|
@@ -478,7 +479,7 @@ repos:
|
|
|
478
479
|
name: typedframes check
|
|
479
480
|
entry: typedframes check . --strict
|
|
480
481
|
language: python
|
|
481
|
-
additional_dependencies: ["typedframes==0.14.
|
|
482
|
+
additional_dependencies: ["typedframes==0.14.3"]
|
|
482
483
|
types_or: [python, jupyter]
|
|
483
484
|
pass_filenames: false
|
|
484
485
|
```
|
|
@@ -527,7 +528,7 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
527
528
|
| Input | Default | |
|
|
528
529
|
|-------|---------|-|
|
|
529
530
|
| `path` | `.` | File or directory to check |
|
|
530
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.14.
|
|
531
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.14.3"` |
|
|
531
532
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
532
533
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
533
534
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
@@ -667,17 +668,17 @@ plus the requested features, so both halves get checked normally. See
|
|
|
667
668
|
Fast feedback reduces development time. The typedframes Rust binary provides near-instant column checking.
|
|
668
669
|
|
|
669
670
|
**Benchmark results** (median of 5 runs ± one standard deviation, 3 warmup, caches cleared between runs):
|
|
670
|
-
*2026-10-
|
|
671
|
+
*2026-10-18 · Darwin 27.0.0 · arm · CPython 3.15.0 · 64GiB RAM · Great Expectations pinned @ 1.23.2*
|
|
671
672
|
|
|
672
673
|
| Tool | Version | What it does | typedframes (12 files) | great_expectations (494 files) |
|
|
673
674
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
674
|
-
| typedframes | 0.14.
|
|
675
|
-
| ruff | 0.17.
|
|
676
|
-
| ty | 0.0.
|
|
677
|
-
| pyrefly | 1.
|
|
678
|
-
| mypy | 2.4.0 | Type checker (no plugin) |
|
|
679
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker |
|
|
680
|
-
| pyright | 1.1.414 | Type checker |
|
|
675
|
+
| typedframes | 0.14.2 | DataFrame column checker | 21.2 ± 0.8 ms | 50.8 ± 0.6 ms |
|
|
676
|
+
| ruff | 0.17.1 | Linter (no type checking) | 25.9 ± 0.4 ms | 224.4 ± 3.4 ms |
|
|
677
|
+
| ty | 0.0.89 | Type checker | 52.5 ± 0.6 ms | 818.7 ± 24.5 ms |
|
|
678
|
+
| pyrefly | 1.4.0 | Type checker | 116.8 ± 5.8 ms | 323.6 ± 10.1 ms |
|
|
679
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 2.01 ± 0.14 s | 3.37 ± 0.03 s |
|
|
680
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 2.04 ± 0.02 s | 3.68 ± 0.10 s |
|
|
681
|
+
| pyright | 1.1.414 | Type checker | 714.9 ± 20.2 ms | 4.59 ± 0.33 s |
|
|
681
682
|
|
|
682
683
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
683
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.3"
|
|
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"
|
|
@@ -47,6 +47,8 @@ python-source = "src"
|
|
|
47
47
|
# The wheel carries the Rust `typedframes` executable (installed as a script) next to the Python package.
|
|
48
48
|
bindings = "bin"
|
|
49
49
|
module-name = "typedframes"
|
|
50
|
+
# `typedframes-py`: a Python script installed beside the executable, which maturin cannot declare as an entry point.
|
|
51
|
+
data = "rust/python-data"
|
|
50
52
|
# The cargo config carries the allocator tuning, so a build from the sdist is tuned too.
|
|
51
53
|
include = [
|
|
52
54
|
{ path = "src/typedframes/_rust.*", format = "wheel" },
|
|
@@ -140,13 +142,13 @@ dev = [
|
|
|
140
142
|
"invoke>=3.0.3",
|
|
141
143
|
"maturin>=1.15.0",
|
|
142
144
|
"pre-commit>=4.7.0",
|
|
143
|
-
"pyrefly>=1.
|
|
145
|
+
"pyrefly>=1.4.0",
|
|
144
146
|
"pyright>=1.1.414",
|
|
145
147
|
"pytest>=9.1.1",
|
|
146
148
|
"pytest-cov>=7.1.0",
|
|
147
149
|
"pytest-xdist>=3.8.0",
|
|
148
|
-
"ruff>=0.17.
|
|
149
|
-
"ty>=0.0.
|
|
150
|
+
"ruff>=0.17.1",
|
|
151
|
+
"ty>=0.0.89",
|
|
150
152
|
"openpyxl>=3.1.5",
|
|
151
153
|
"pyarrow>=26.0.0",
|
|
152
154
|
"xlsxwriter>=3.2.9",
|
|
@@ -1469,13 +1469,12 @@ checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
|
|
|
1469
1469
|
|
|
1470
1470
|
[[package]]
|
|
1471
1471
|
name = "typedframes_checker"
|
|
1472
|
-
version = "0.14.
|
|
1472
|
+
version = "0.14.3"
|
|
1473
1473
|
dependencies = [
|
|
1474
1474
|
"anyhow",
|
|
1475
1475
|
"clap",
|
|
1476
1476
|
"criterion",
|
|
1477
1477
|
"mimalloc",
|
|
1478
|
-
"regex",
|
|
1479
1478
|
"rmp-serde",
|
|
1480
1479
|
"ruff_notebook",
|
|
1481
1480
|
"ruff_python_ast",
|
|
@@ -1492,7 +1491,7 @@ dependencies = [
|
|
|
1492
1491
|
|
|
1493
1492
|
[[package]]
|
|
1494
1493
|
name = "typedframes_python"
|
|
1495
|
-
version = "0.14.
|
|
1494
|
+
version = "0.14.3"
|
|
1496
1495
|
dependencies = [
|
|
1497
1496
|
"pyo3",
|
|
1498
1497
|
"pyo3-build-config",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "typedframes_checker"
|
|
3
|
-
version = "0.14.
|
|
3
|
+
version = "0.14.3"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "A high-performance Rust-based checker for typedframes DataFrame column schemas"
|
|
6
6
|
license = "MIT"
|
|
@@ -20,6 +20,13 @@ codegen-units = 1
|
|
|
20
20
|
# a Python exception and not end the interpreter that loaded it.
|
|
21
21
|
strip = "symbols"
|
|
22
22
|
|
|
23
|
+
# The executable wheel is built with this profile: it never loads into another process, so a panic
|
|
24
|
+
# may end it, and it favours size over the last ~10% of speed. The extension module keeps `release`.
|
|
25
|
+
[profile.cli]
|
|
26
|
+
inherits = "release"
|
|
27
|
+
panic = "abort"
|
|
28
|
+
opt-level = "s"
|
|
29
|
+
|
|
23
30
|
[lints.rust]
|
|
24
31
|
unsafe_code = "forbid"
|
|
25
32
|
|
|
@@ -38,9 +45,8 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
|
|
|
38
45
|
rmp-serde = "1"
|
|
39
46
|
anyhow = "1.0"
|
|
40
47
|
toml = { version = "1.1", features = ["preserve_order"] }
|
|
41
|
-
sqlparser = "0.62"
|
|
48
|
+
sqlparser = { version = "0.62", default-features = false, features = ["std", "recursive-protection"] }
|
|
42
49
|
clap = { version = "4.6.7", features = ["derive"] }
|
|
43
|
-
regex = "1.13.1"
|
|
44
50
|
# The allocator split ruff and ty use: jemalloc where it builds, mimalloc on Windows (jemalloc
|
|
45
51
|
# has no MSVC support), the platform allocator elsewhere. Keep the `cfg`s in `src/lib.rs` in
|
|
46
52
|
# step with these. jemalloc is tuned for a short run on many threads in `../.cargo/config.toml`.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
//! collecting files, and the opt-in DataFrame schema coverage gate.
|
|
3
3
|
|
|
4
4
|
use super::pyfmt::{float_str, repr_str};
|
|
5
|
-
use regex::Regex;
|
|
6
5
|
use std::collections::HashSet;
|
|
7
6
|
use std::fs;
|
|
8
7
|
use std::path::Path;
|
|
@@ -241,42 +240,98 @@ pub(crate) fn load_configured_excludes(path: &Path) -> Option<HashSet<String>> {
|
|
|
241
240
|
)
|
|
242
241
|
}
|
|
243
242
|
|
|
244
|
-
///
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
243
|
+
/// One step of a compiled glob.
|
|
244
|
+
enum Step {
|
|
245
|
+
Literal(char),
|
|
246
|
+
/// `?`: one character other than `/`.
|
|
247
|
+
One,
|
|
248
|
+
/// `*`: any run of characters other than `/`.
|
|
249
|
+
Segment,
|
|
250
|
+
/// `**`: any run of characters, line breaks aside.
|
|
251
|
+
Any,
|
|
252
|
+
/// Front of `**/`: the two steps after it may be skipped, so `**/x.py` still matches a bare `x.py`.
|
|
253
|
+
Optional,
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/// A project-relative path glob, matched against the whole path: `**` spans any number of path
|
|
257
|
+
/// segments (`**/` consumes its separator too), `*` and `?` never cross a `/`, everything else is
|
|
258
|
+
/// literal.
|
|
259
|
+
pub(crate) struct Glob {
|
|
260
|
+
steps: Vec<Step>,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
impl Glob {
|
|
264
|
+
pub(crate) fn new(pattern: &str) -> Self {
|
|
265
|
+
let chars: Vec<char> = pattern.chars().collect();
|
|
266
|
+
let mut steps = Vec::new();
|
|
267
|
+
let mut i = 0;
|
|
268
|
+
while i < chars.len() {
|
|
269
|
+
match chars[i] {
|
|
270
|
+
'*' => {
|
|
271
|
+
let mut end = i;
|
|
272
|
+
while chars.get(end) == Some(&'*') {
|
|
273
|
+
end += 1;
|
|
274
|
+
}
|
|
275
|
+
if end - i < 2 {
|
|
276
|
+
steps.push(Step::Segment);
|
|
277
|
+
} else if chars.get(end) == Some(&'/') {
|
|
278
|
+
steps.extend([Step::Optional, Step::Any, Step::Literal('/')]);
|
|
279
|
+
end += 1;
|
|
280
|
+
} else {
|
|
281
|
+
steps.push(Step::Any);
|
|
282
|
+
}
|
|
283
|
+
i = end;
|
|
284
|
+
}
|
|
285
|
+
'?' => {
|
|
286
|
+
steps.push(Step::One);
|
|
287
|
+
i += 1;
|
|
288
|
+
}
|
|
289
|
+
ch => {
|
|
290
|
+
steps.push(Step::Literal(ch));
|
|
291
|
+
i += 1;
|
|
292
|
+
}
|
|
257
293
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
294
|
+
}
|
|
295
|
+
Self { steps }
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/// Runs every live position through the path at once, so a pattern with several `**` cannot
|
|
299
|
+
/// backtrack exponentially.
|
|
300
|
+
pub(crate) fn is_match(&self, path: &str) -> bool {
|
|
301
|
+
let mut live = vec![false; self.steps.len() + 1];
|
|
302
|
+
self.enter(&mut live, 0);
|
|
303
|
+
for ch in path.chars() {
|
|
304
|
+
let mut next = vec![false; live.len()];
|
|
305
|
+
for (at, step) in self.steps.iter().enumerate() {
|
|
306
|
+
if !live[at] {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
match step {
|
|
310
|
+
Step::Literal(expected) if *expected == ch => self.enter(&mut next, at + 1),
|
|
311
|
+
Step::One if ch != '/' => self.enter(&mut next, at + 1),
|
|
312
|
+
Step::Segment if ch != '/' => self.enter(&mut next, at),
|
|
313
|
+
Step::Any if ch != '\n' => self.enter(&mut next, at),
|
|
314
|
+
_ => {}
|
|
264
315
|
}
|
|
265
|
-
} else {
|
|
266
|
-
out.push_str("[^/]*");
|
|
267
316
|
}
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
317
|
+
live = next;
|
|
318
|
+
}
|
|
319
|
+
live[self.steps.len()]
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
fn enter(&self, live: &mut [bool], at: usize) {
|
|
323
|
+
if std::mem::replace(&mut live[at], true) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
match self.steps.get(at) {
|
|
327
|
+
Some(Step::Segment | Step::Any) => self.enter(live, at + 1),
|
|
328
|
+
Some(Step::Optional) => {
|
|
329
|
+
self.enter(live, at + 1);
|
|
330
|
+
self.enter(live, at + 3);
|
|
331
|
+
}
|
|
332
|
+
_ => {}
|
|
275
333
|
}
|
|
276
334
|
}
|
|
277
|
-
out.push_str(")$");
|
|
278
|
-
// The pattern is built from escaped literals and fixed pieces, so it always compiles.
|
|
279
|
-
Regex::new(&out).unwrap_or_else(|_| Regex::new("$^").expect("empty-match regex compiles"))
|
|
280
335
|
}
|
|
281
336
|
|
|
282
337
|
/// How specific an override pattern is, for most-specific-match-wins: the length of the literal
|
|
@@ -296,7 +351,7 @@ mod tests {
|
|
|
296
351
|
use super::*;
|
|
297
352
|
|
|
298
353
|
fn matches(pattern: &str, path: &str) -> bool {
|
|
299
|
-
|
|
354
|
+
Glob::new(pattern).is_match(path)
|
|
300
355
|
}
|
|
301
356
|
|
|
302
357
|
#[test]
|
|
@@ -326,6 +381,46 @@ mod tests {
|
|
|
326
381
|
assert!(!matches("a.py", "abpy"));
|
|
327
382
|
}
|
|
328
383
|
|
|
384
|
+
#[test]
|
|
385
|
+
fn test_should_match_a_trailing_double_star_directory_only_with_its_separator() {
|
|
386
|
+
assert!(matches("src/**/", "src/a/"));
|
|
387
|
+
assert!(matches("src/**/", "src/"));
|
|
388
|
+
assert!(!matches("src/**/", "src"));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
#[test]
|
|
392
|
+
fn test_should_treat_three_stars_as_a_double_star() {
|
|
393
|
+
assert!(matches("a/***", "a/b/c.py"));
|
|
394
|
+
assert!(matches("a/***/c.py", "a/c.py"));
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
#[test]
|
|
398
|
+
fn test_should_match_the_whole_path_not_a_part_of_it() {
|
|
399
|
+
assert!(!matches("a", "ab"));
|
|
400
|
+
assert!(!matches("a", "ba"));
|
|
401
|
+
assert!(matches("", ""));
|
|
402
|
+
assert!(!matches("", "a"));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
#[test]
|
|
406
|
+
fn test_should_not_let_double_star_cross_a_line_break() {
|
|
407
|
+
assert!(!matches("a/**", "a/b\nc"));
|
|
408
|
+
assert!(matches("a/*", "a/b\nc"));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
#[test]
|
|
412
|
+
fn test_should_count_characters_not_bytes_for_a_question_mark() {
|
|
413
|
+
assert!(matches("src/?.py", "src/\u{e9}.py"));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
#[test]
|
|
417
|
+
fn test_should_match_many_double_stars_in_linear_time() {
|
|
418
|
+
let pattern = "**/".repeat(40) + "x.py";
|
|
419
|
+
let path = "a/".repeat(200) + "y.py";
|
|
420
|
+
assert!(!matches(&pattern, &path));
|
|
421
|
+
assert!(matches(&pattern, &("a/".repeat(200) + "x.py")));
|
|
422
|
+
}
|
|
423
|
+
|
|
329
424
|
#[test]
|
|
330
425
|
fn test_should_rank_a_longer_literal_prefix_as_more_specific() {
|
|
331
426
|
assert!(pattern_specificity("src/new_module/**") > pattern_specificity("src/**"));
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
//! Sites and events are the JSON objects the checker produced for each file, tagged with the
|
|
4
4
|
//! `file` they came from.
|
|
5
5
|
|
|
6
|
-
use super::config::{
|
|
6
|
+
use super::config::{pattern_specificity, CoverageConfig, Glob};
|
|
7
7
|
use super::pathutil::relative_posix;
|
|
8
8
|
use super::pyfmt::{repr_str, round_half_even};
|
|
9
|
-
use regex::Regex;
|
|
10
9
|
use serde_json::{json, Map, Value};
|
|
11
10
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
|
12
11
|
use std::path::Path;
|
|
@@ -133,7 +132,7 @@ pub(crate) fn evaluate_coverage(
|
|
|
133
132
|
root: &Path,
|
|
134
133
|
cli_fail_under: Option<f64>,
|
|
135
134
|
) -> Vec<Bucket> {
|
|
136
|
-
let mut
|
|
135
|
+
let mut globs: HashMap<&str, Glob> = HashMap::new();
|
|
137
136
|
let mut tallies: Vec<(Option<String>, f64, Tally)> = Vec::new();
|
|
138
137
|
for (file, tally) in per_file {
|
|
139
138
|
let (label, threshold) = match cli_fail_under {
|
|
@@ -144,9 +143,9 @@ pub(crate) fn evaluate_coverage(
|
|
|
144
143
|
.overrides
|
|
145
144
|
.iter()
|
|
146
145
|
.filter(|(pattern, _)| {
|
|
147
|
-
|
|
146
|
+
globs
|
|
148
147
|
.entry(pattern.as_str())
|
|
149
|
-
.or_insert_with(||
|
|
148
|
+
.or_insert_with(|| Glob::new(pattern))
|
|
150
149
|
.is_match(&relative)
|
|
151
150
|
})
|
|
152
151
|
.max_by(|a, b| pattern_specificity(&a.0).cmp(&pattern_specificity(&b.0)));
|
|
@@ -6,13 +6,11 @@ use super::collect::collect_files;
|
|
|
6
6
|
use super::config::load_configured_excludes;
|
|
7
7
|
use super::pyfmt::{dumps_indent2, repr_str};
|
|
8
8
|
use crate::engine::{report_all_batch, report_batch};
|
|
9
|
-
use regex::Regex;
|
|
10
9
|
use serde_json::{json, Value};
|
|
11
10
|
use std::collections::HashMap;
|
|
12
11
|
use std::fs;
|
|
13
12
|
use std::io::{self, Write};
|
|
14
13
|
use std::path::{Path, PathBuf};
|
|
15
|
-
use std::sync::OnceLock;
|
|
16
14
|
|
|
17
15
|
const REVIEW_NOTICE: &str = "<!-- Review before posting, then delete this line. Names, comments and most strings are replaced, but numbers 0 and 1, library and option names and the shape of the code are kept as written. -->";
|
|
18
16
|
|
|
@@ -34,11 +32,10 @@ fn text<'a>(value: &'a Value, key: &str) -> &'a str {
|
|
|
34
32
|
|
|
35
33
|
// How many more uses a reason mentions; sites differing only in that are one problem.
|
|
36
34
|
fn strip_more_uses(reason: &str) -> String {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.into_owned()
|
|
35
|
+
reason
|
|
36
|
+
.strip_suffix(", and N more")
|
|
37
|
+
.unwrap_or(reason)
|
|
38
|
+
.to_string()
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
fn snippet(report: &Value) -> Option<&str> {
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
//! `untracked-dataframe` nudge is recoverable but a false `unknown-column` error (from a
|
|
8
8
|
//! short, wrongly-inferred column set) is not.
|
|
9
9
|
|
|
10
|
-
use sqlparser::ast::{Query, SelectItem, SetExpr
|
|
10
|
+
use sqlparser::ast::{Query, SelectItem, SetExpr};
|
|
11
11
|
use sqlparser::dialect::Dialect;
|
|
12
12
|
use sqlparser::parser::Parser;
|
|
13
|
+
use sqlparser::tokenizer::Token;
|
|
13
14
|
|
|
14
15
|
/// The grammar every query is parsed with, regardless of `SqlDialect` — see
|
|
15
16
|
/// [`columns_from_select`]. Identical to [`sqlparser::dialect::GenericDialect`] (its
|
|
@@ -423,26 +424,23 @@ pub(crate) fn columns_from_select(sql: &str, dialect: SqlDialect) -> SqlOutcome
|
|
|
423
424
|
// identifiers — both perfectly valid SQL text) would otherwise cost real
|
|
424
425
|
// inferences for no correctness benefit — we only ever read identifier names out
|
|
425
426
|
// of a successfully parsed `SELECT` list, never validate engine-specific syntax.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
parser.parse_statements()
|
|
432
|
-
}) {
|
|
433
|
-
Ok(stmts) => stmts,
|
|
434
|
-
Err(_) => return SqlOutcome::Unparsed,
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
let [statement] = statements.as_slice() else {
|
|
438
|
-
return SqlOutcome::Unparsed;
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
let Statement::Query(query) = statement else {
|
|
442
|
-
return SqlOutcome::Unparsed;
|
|
443
|
-
};
|
|
427
|
+
match parse_single_query(sql) {
|
|
428
|
+
Some(query) => columns_from_query(&query, dialect),
|
|
429
|
+
None => SqlOutcome::Unparsed,
|
|
430
|
+
}
|
|
431
|
+
}
|
|
444
432
|
|
|
445
|
-
|
|
433
|
+
/// The one query `sql` holds, with any `;` around it; `None` for anything else. Parsing a query
|
|
434
|
+
/// directly, not a statement list, leaves the statement grammar out of the binary.
|
|
435
|
+
fn parse_single_query(sql: &str) -> Option<Box<Query>> {
|
|
436
|
+
let mut parser = Parser::new(&PermissiveDialect)
|
|
437
|
+
.try_with_sql(sql)
|
|
438
|
+
.ok()?
|
|
439
|
+
.with_recursion_limit(50);
|
|
440
|
+
while parser.consume_token(&Token::SemiColon) {}
|
|
441
|
+
let query = parser.parse_query().ok()?;
|
|
442
|
+
while parser.consume_token(&Token::SemiColon) {}
|
|
443
|
+
(parser.peek_token().token == Token::EOF).then_some(query)
|
|
446
444
|
}
|
|
447
445
|
|
|
448
446
|
fn columns_from_query(query: &Query, dialect: SqlDialect) -> SqlOutcome {
|
|
@@ -533,6 +531,84 @@ mod tests {
|
|
|
533
531
|
columns_from_select(sql, dialect)
|
|
534
532
|
}
|
|
535
533
|
|
|
534
|
+
// The statement-list path `parse_single_query` replaced.
|
|
535
|
+
fn via_statements(sql: &str) -> SqlOutcome {
|
|
536
|
+
let parsed = Parser::new(&PermissiveDialect)
|
|
537
|
+
.try_with_sql(sql)
|
|
538
|
+
.and_then(|parser| parser.with_recursion_limit(50).parse_statements());
|
|
539
|
+
match parsed.as_deref() {
|
|
540
|
+
Ok([sqlparser::ast::Statement::Query(query)]) => {
|
|
541
|
+
columns_from_query(query, SqlDialect::Generic)
|
|
542
|
+
}
|
|
543
|
+
_ => SqlOutcome::Unparsed,
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
#[test]
|
|
548
|
+
fn single_query_parse_agrees_with_the_statement_list_parse() {
|
|
549
|
+
let inputs = [
|
|
550
|
+
"SELECT a, b FROM t",
|
|
551
|
+
"SELECT a FROM t;",
|
|
552
|
+
";SELECT a FROM t",
|
|
553
|
+
";;SELECT a FROM t;;",
|
|
554
|
+
"SELECT a FROM t; SELECT b FROM u",
|
|
555
|
+
"SELECT a FROM t;; SELECT b FROM u;",
|
|
556
|
+
"SELECT a FROM t SELECT b FROM u",
|
|
557
|
+
"",
|
|
558
|
+
";",
|
|
559
|
+
";;",
|
|
560
|
+
"(SELECT a FROM t)",
|
|
561
|
+
"((SELECT a FROM t))",
|
|
562
|
+
"(SELECT a FROM t) UNION (SELECT a FROM u)",
|
|
563
|
+
"SELECT a FROM t UNION SELECT b FROM u",
|
|
564
|
+
"WITH c AS (SELECT a FROM t) SELECT a FROM c",
|
|
565
|
+
"WITH c AS (SELECT a FROM t) INSERT INTO u SELECT a FROM c",
|
|
566
|
+
"VALUES (1, 2)",
|
|
567
|
+
"FROM t SELECT a",
|
|
568
|
+
"TABLE t",
|
|
569
|
+
"INSERT INTO t VALUES (1)",
|
|
570
|
+
"UPDATE t SET a = 1",
|
|
571
|
+
"DELETE FROM t",
|
|
572
|
+
"DROP TABLE t",
|
|
573
|
+
"EXPLAIN SELECT a FROM t",
|
|
574
|
+
"CREATE TABLE t AS SELECT a FROM u",
|
|
575
|
+
"SELECT",
|
|
576
|
+
"SELECT a FROM",
|
|
577
|
+
"SELECT a, FROM t",
|
|
578
|
+
"SELECT * FROM t",
|
|
579
|
+
"SELECT a + 1 FROM t",
|
|
580
|
+
"SELECT 'x;y' AS a FROM t",
|
|
581
|
+
"SELECT a FROM t -- trailing; comment",
|
|
582
|
+
"/* lead */ SELECT a FROM t",
|
|
583
|
+
"SELECT a FROM t WHERE b = ?",
|
|
584
|
+
"SELECT [a b] FROM t",
|
|
585
|
+
"SELECT `a` FROM t;\n",
|
|
586
|
+
"\n\t SELECT a FROM t \n",
|
|
587
|
+
"SELECT a FROM t END",
|
|
588
|
+
"not sql at all",
|
|
589
|
+
];
|
|
590
|
+
for sql in inputs {
|
|
591
|
+
if sql == "SELECT a FROM t END" {
|
|
592
|
+
// `parse_statements` stops at a stray `END`; a query followed by anything is `Unparsed` here.
|
|
593
|
+
assert_eq!(SqlOutcome::Unparsed, cols(sql), "{sql:?}");
|
|
594
|
+
} else {
|
|
595
|
+
assert_eq!(via_statements(sql), cols(sql), "{sql:?}");
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
#[test]
|
|
601
|
+
fn deeply_nested_input_is_unparsed_not_a_stack_overflow() {
|
|
602
|
+
let sql = format!("SELECT {}1{} AS a", "(".repeat(5000), ")".repeat(5000));
|
|
603
|
+
let outcome = std::thread::Builder::new()
|
|
604
|
+
.stack_size(512 * 1024)
|
|
605
|
+
.spawn(move || cols(&sql))
|
|
606
|
+
.unwrap()
|
|
607
|
+
.join()
|
|
608
|
+
.unwrap();
|
|
609
|
+
assert_eq!(SqlOutcome::Unparsed, outcome);
|
|
610
|
+
}
|
|
611
|
+
|
|
536
612
|
#[test]
|
|
537
613
|
fn plain_select_list() {
|
|
538
614
|
assert_eq!(
|
|
@@ -113,3 +113,8 @@ def main() -> None:
|
|
|
113
113
|
sys.exit(run_binary(sys.argv[1:]).returncode)
|
|
114
114
|
binary = str(find_binary())
|
|
115
115
|
os.execv(binary, [binary, *sys.argv[1:]])
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def main_in_process() -> None:
|
|
119
|
+
"""Entry point for `typedframes-py`: always the checker inside this process, never the executable."""
|
|
120
|
+
sys.exit(_extension().main(["typedframes", *sys.argv[1:]]))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|