typedframes 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.
- {typedframes-0.11.1 → typedframes-0.12.0}/PKG-INFO +39 -14
- {typedframes-0.11.1 → typedframes-0.12.0}/README.md +38 -13
- {typedframes-0.11.1 → typedframes-0.12.0}/pyproject.toml +9 -21
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/Cargo.lock +1 -1
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/Cargo.toml +1 -1
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/constants.rs +3 -1
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/index.rs +30 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/__init__.py +1 -5
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/base_schema.py +0 -82
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/cli.py +66 -44
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/column.py +1 -1
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/column_group.py +5 -44
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/column_set.py +2 -8
- typedframes-0.12.0/src/typedframes/compat.py +28 -0
- typedframes-0.12.0/src/typedframes/python315.py +13 -0
- typedframes-0.11.1/src/typedframes/pandas.py +0 -284
- typedframes-0.11.1/src/typedframes/polars.py +0 -234
- {typedframes-0.11.1 → typedframes-0.12.0}/LICENSE +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/.cargo/config.toml +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/README.md +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/benches/parser_bench.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/build.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/apply.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/ast_extract.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/column_consuming_methods.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/column_usage.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/config.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/contract.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/errors.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/frame_ops.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/helpers.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/lib.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/linter.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/main.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/notebook.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/parallel.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/phrase.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/pyapi.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/report.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/report_names.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/sql.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/static_eval.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/suggest.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/typo.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/src/words.txt +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/rust/tests/integration_test.rs +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/_rust_checker.pyi +0 -0
- /typedframes-0.11.1/src/typedframes/_cache.py → /typedframes-0.12.0/src/typedframes/cache.py +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/column_group_error.py +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/missing_dependency_error.py +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/mypy.py +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/pandera.py +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/py.typed +0 -0
- {typedframes-0.11.1 → typedframes-0.12.0}/src/typedframes/schema_algebra.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: typedframes
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0
|
|
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.
|
|
47
|
+
> `typedframes` (v0.12.0) 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
|
>
|
|
@@ -506,7 +506,7 @@ repos:
|
|
|
506
506
|
name: typedframes check
|
|
507
507
|
entry: typedframes check . --strict
|
|
508
508
|
language: python
|
|
509
|
-
additional_dependencies: ["typedframes==0.
|
|
509
|
+
additional_dependencies: ["typedframes==0.12.0"]
|
|
510
510
|
types_or: [python, jupyter]
|
|
511
511
|
pass_filenames: false
|
|
512
512
|
```
|
|
@@ -555,13 +555,38 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
555
555
|
| Input | Default | |
|
|
556
556
|
|-------|---------|-|
|
|
557
557
|
| `path` | `.` | File or directory to check |
|
|
558
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.
|
|
558
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.12.0"` |
|
|
559
559
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
560
560
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
561
561
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
562
562
|
| `no-warnings` | `false` | Suppress warning-level diagnostics |
|
|
563
563
|
| `args` | *(empty)* | Escape hatch for `--no-index`, `--lenient-ingest`, `--no-info` |
|
|
564
564
|
|
|
565
|
+
### Fixing Untyped DataFrames (`suggest`)
|
|
566
|
+
|
|
567
|
+
For a DataFrame the checker can't resolve columns for, `typedframes suggest` works out a fix from the columns the rest
|
|
568
|
+
of its scope reads: a `usecols=`/`columns=` added to a plain `read_csv` or `read_parquet`, or else a column selection on
|
|
569
|
+
the line after the load. It is a dry run that prints diffs. Each site has a two-word name (`quiet-amber`) shown next to it.
|
|
570
|
+
|
|
571
|
+
```shell
|
|
572
|
+
typedframes suggest src/ # dry run: prints diffs, changes nothing
|
|
573
|
+
typedframes suggest src/ --apply # write the safe suggestions
|
|
574
|
+
typedframes suggest src/ --apply --only quiet-amber # act on just that site
|
|
575
|
+
typedframes suggest src/ --interactive # ask about each suggestion
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Edits need a clean git work tree and tracked files, each edited file is re-checked in memory before anything is written,
|
|
579
|
+
and the files are written together or not at all. See the
|
|
580
|
+
[full guide](docs/usage.md#suggesting-fixes-suggest).
|
|
581
|
+
|
|
582
|
+
### Reporting a Problem (`report`)
|
|
583
|
+
|
|
584
|
+
If `check` or `suggest` gets a site wrong and the code can't be shared, `typedframes report quiet-amber src/` prints a
|
|
585
|
+
bug-report body with a redacted copy of the code around that site, checked against the checker so it reproduces the same
|
|
586
|
+
result. Redacted is not anonymous: read it before posting, and don't use it on code you aren't allowed to share. See
|
|
587
|
+
[Reporting a problem](docs/usage.md#reporting-a-problem-report), and
|
|
588
|
+
[Security and data handling](docs/security.md) for what the tool reads, writes and connects to.
|
|
589
|
+
|
|
565
590
|
---
|
|
566
591
|
|
|
567
592
|
## Jupyter Notebooks
|
|
@@ -668,18 +693,18 @@ plus the requested features, so both halves get checked normally. See
|
|
|
668
693
|
|
|
669
694
|
Fast feedback reduces development time. The typedframes Rust binary provides near-instant column checking.
|
|
670
695
|
|
|
671
|
-
**Benchmark results** (
|
|
672
|
-
*2026-10-
|
|
696
|
+
**Benchmark results** (median of 5 runs ± one standard deviation, 3 warmup, caches cleared between runs):
|
|
697
|
+
*2026-10-11 · Darwin 27.0.0 · arm · CPython 3.15.0 · 64GiB RAM · Great Expectations pinned @ 1.23.2*
|
|
673
698
|
|
|
674
699
|
| Tool | Version | What it does | typedframes (14 files) | great_expectations (494 files) |
|
|
675
700
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
676
|
-
| typedframes | 0.
|
|
677
|
-
| ruff | 0.
|
|
678
|
-
| ty | 0.0.84 | Type checker |
|
|
679
|
-
| pyrefly | 1.3.2 | Type checker |
|
|
680
|
-
| mypy | 2.4.0 | Type checker (no plugin) | 1.
|
|
681
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.
|
|
682
|
-
| pyright | 1.1.414 | Type checker |
|
|
701
|
+
| typedframes | 0.12.0 | DataFrame column checker | 41.1 ± 0.7 ms | 122.1 ± 0.6 ms |
|
|
702
|
+
| ruff | 0.17.0 | Linter (no type checking) | 21.5 ± 0.6 ms | 212.9 ± 1.5 ms |
|
|
703
|
+
| ty | 0.0.84 | Type checker | 50.2 ± 0.3 ms | 751.7 ± 7.6 ms |
|
|
704
|
+
| pyrefly | 1.3.2 | Type checker | 91.5 ± 2.5 ms | 268.9 ± 3.8 ms |
|
|
705
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 1.82 ± 0.03 s | 3.04 ± 0.02 s |
|
|
706
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.84 ± 0.02 s | 3.46 ± 0.02 s |
|
|
707
|
+
| pyright | 1.1.414 | Type checker | 794.2 ± 13.8 ms | 3.90 ± 0.03 s |
|
|
683
708
|
|
|
684
709
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
685
710
|
|
|
@@ -924,7 +949,7 @@ Comprehensive comparison of pandas/DataFrame typing and validation tools. **type
|
|
|
924
949
|
|
|
925
950
|
| Feature | typedframes | Pandera | Great Expectations | strictly_typed_pandas | pandas-stubs | dataenforce | pandas-type-checks | StaticFrame | narwhals | dataframely | patito |
|
|
926
951
|
|---------------------------------|------------------------|-------------|--------------------|-----------------------|--------------|-------------|--------------------|------------------|----------|------------------|------------------|
|
|
927
|
-
| **Version tested** | 0.
|
|
952
|
+
| **Version tested** | 0.12.0 | 0.34.1 | 1.23.2 | 0.3.7 | 3.0.5.260914 | 0.1.2 | 1.1.3 | 5.1.1 | 2.26.0 | 3.1.2 | 0.8.6 |
|
|
928
953
|
| **Analysis Type** |
|
|
929
954
|
| When errors are caught | **Static (lint-time)** | Runtime | Runtime | Runtime | Static | Runtime | Runtime | Runtime | Runtime | Runtime | Runtime |
|
|
930
955
|
| **Static Analysis (our focus)** |
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> ⚠️ **Project Status: Proof of Concept**
|
|
10
10
|
>
|
|
11
|
-
> `typedframes` (v0.
|
|
11
|
+
> `typedframes` (v0.12.0) 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
|
>
|
|
@@ -470,7 +470,7 @@ repos:
|
|
|
470
470
|
name: typedframes check
|
|
471
471
|
entry: typedframes check . --strict
|
|
472
472
|
language: python
|
|
473
|
-
additional_dependencies: ["typedframes==0.
|
|
473
|
+
additional_dependencies: ["typedframes==0.12.0"]
|
|
474
474
|
types_or: [python, jupyter]
|
|
475
475
|
pass_filenames: false
|
|
476
476
|
```
|
|
@@ -519,13 +519,38 @@ The action installs the PyPI wheel into a throwaway virtualenv and runs the chec
|
|
|
519
519
|
| Input | Default | |
|
|
520
520
|
|-------|---------|-|
|
|
521
521
|
| `path` | `.` | File or directory to check |
|
|
522
|
-
| `version` | `latest` | PyPI version to install, e.g. `"0.
|
|
522
|
+
| `version` | `latest` | PyPI version to install, e.g. `"0.12.0"` |
|
|
523
523
|
| `strict` | `true` | Fail the step on errors — `typedframes check` exits 0 without it |
|
|
524
524
|
| `coverage-fail-under` | *(unset)* | Minimum DataFrame schema coverage, e.g. `"90"` |
|
|
525
525
|
| `coverage-detail` | `summary` | Or `term-missing` for the per-file breakdown, `explain` to diagnose a lower-than-expected total |
|
|
526
526
|
| `no-warnings` | `false` | Suppress warning-level diagnostics |
|
|
527
527
|
| `args` | *(empty)* | Escape hatch for `--no-index`, `--lenient-ingest`, `--no-info` |
|
|
528
528
|
|
|
529
|
+
### Fixing Untyped DataFrames (`suggest`)
|
|
530
|
+
|
|
531
|
+
For a DataFrame the checker can't resolve columns for, `typedframes suggest` works out a fix from the columns the rest
|
|
532
|
+
of its scope reads: a `usecols=`/`columns=` added to a plain `read_csv` or `read_parquet`, or else a column selection on
|
|
533
|
+
the line after the load. It is a dry run that prints diffs. Each site has a two-word name (`quiet-amber`) shown next to it.
|
|
534
|
+
|
|
535
|
+
```shell
|
|
536
|
+
typedframes suggest src/ # dry run: prints diffs, changes nothing
|
|
537
|
+
typedframes suggest src/ --apply # write the safe suggestions
|
|
538
|
+
typedframes suggest src/ --apply --only quiet-amber # act on just that site
|
|
539
|
+
typedframes suggest src/ --interactive # ask about each suggestion
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Edits need a clean git work tree and tracked files, each edited file is re-checked in memory before anything is written,
|
|
543
|
+
and the files are written together or not at all. See the
|
|
544
|
+
[full guide](docs/usage.md#suggesting-fixes-suggest).
|
|
545
|
+
|
|
546
|
+
### Reporting a Problem (`report`)
|
|
547
|
+
|
|
548
|
+
If `check` or `suggest` gets a site wrong and the code can't be shared, `typedframes report quiet-amber src/` prints a
|
|
549
|
+
bug-report body with a redacted copy of the code around that site, checked against the checker so it reproduces the same
|
|
550
|
+
result. Redacted is not anonymous: read it before posting, and don't use it on code you aren't allowed to share. See
|
|
551
|
+
[Reporting a problem](docs/usage.md#reporting-a-problem-report), and
|
|
552
|
+
[Security and data handling](docs/security.md) for what the tool reads, writes and connects to.
|
|
553
|
+
|
|
529
554
|
---
|
|
530
555
|
|
|
531
556
|
## Jupyter Notebooks
|
|
@@ -632,18 +657,18 @@ plus the requested features, so both halves get checked normally. See
|
|
|
632
657
|
|
|
633
658
|
Fast feedback reduces development time. The typedframes Rust binary provides near-instant column checking.
|
|
634
659
|
|
|
635
|
-
**Benchmark results** (
|
|
636
|
-
*2026-10-
|
|
660
|
+
**Benchmark results** (median of 5 runs ± one standard deviation, 3 warmup, caches cleared between runs):
|
|
661
|
+
*2026-10-11 · Darwin 27.0.0 · arm · CPython 3.15.0 · 64GiB RAM · Great Expectations pinned @ 1.23.2*
|
|
637
662
|
|
|
638
663
|
| Tool | Version | What it does | typedframes (14 files) | great_expectations (494 files) |
|
|
639
664
|
|------|---------|--------------|------------------------|--------------------------------|
|
|
640
|
-
| typedframes | 0.
|
|
641
|
-
| ruff | 0.
|
|
642
|
-
| ty | 0.0.84 | Type checker |
|
|
643
|
-
| pyrefly | 1.3.2 | Type checker |
|
|
644
|
-
| mypy | 2.4.0 | Type checker (no plugin) | 1.
|
|
645
|
-
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.
|
|
646
|
-
| pyright | 1.1.414 | Type checker |
|
|
665
|
+
| typedframes | 0.12.0 | DataFrame column checker | 41.1 ± 0.7 ms | 122.1 ± 0.6 ms |
|
|
666
|
+
| ruff | 0.17.0 | Linter (no type checking) | 21.5 ± 0.6 ms | 212.9 ± 1.5 ms |
|
|
667
|
+
| ty | 0.0.84 | Type checker | 50.2 ± 0.3 ms | 751.7 ± 7.6 ms |
|
|
668
|
+
| pyrefly | 1.3.2 | Type checker | 91.5 ± 2.5 ms | 268.9 ± 3.8 ms |
|
|
669
|
+
| mypy | 2.4.0 | Type checker (no plugin) | 1.82 ± 0.03 s | 3.04 ± 0.02 s |
|
|
670
|
+
| mypy + typedframes | 2.4.0 | Type checker + column checker | 1.84 ± 0.02 s | 3.46 ± 0.02 s |
|
|
671
|
+
| pyright | 1.1.414 | Type checker | 794.2 ± 13.8 ms | 3.90 ± 0.03 s |
|
|
647
672
|
|
|
648
673
|
*Run `uv run python benchmarks/benchmark_checkers.py` to reproduce.*
|
|
649
674
|
|
|
@@ -888,7 +913,7 @@ Comprehensive comparison of pandas/DataFrame typing and validation tools. **type
|
|
|
888
913
|
|
|
889
914
|
| Feature | typedframes | Pandera | Great Expectations | strictly_typed_pandas | pandas-stubs | dataenforce | pandas-type-checks | StaticFrame | narwhals | dataframely | patito |
|
|
890
915
|
|---------------------------------|------------------------|-------------|--------------------|-----------------------|--------------|-------------|--------------------|------------------|----------|------------------|------------------|
|
|
891
|
-
| **Version tested** | 0.
|
|
916
|
+
| **Version tested** | 0.12.0 | 0.34.1 | 1.23.2 | 0.3.7 | 3.0.5.260914 | 0.1.2 | 1.1.3 | 5.1.1 | 2.26.0 | 3.1.2 | 0.8.6 |
|
|
892
917
|
| **Analysis Type** |
|
|
893
918
|
| When errors are caught | **Static (lint-time)** | Runtime | Runtime | Runtime | Static | Runtime | Runtime | Runtime | Runtime | Runtime | Runtime |
|
|
894
919
|
| **Static Analysis (our focus)** |
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "typedframes"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.12.0"
|
|
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"
|
|
@@ -58,6 +58,7 @@ testpaths = ["tests"]
|
|
|
58
58
|
[tool.coverage.run]
|
|
59
59
|
branch = true
|
|
60
60
|
omit = [
|
|
61
|
+
"src/typedframes/python315.py", # needs 3.15; tests/unit/test_compat.py covers it there
|
|
61
62
|
"benchmarks/*",
|
|
62
63
|
"examples/*",
|
|
63
64
|
"tests/*",
|
|
@@ -73,6 +74,8 @@ ignore_missing_imports = true
|
|
|
73
74
|
line-length = 120
|
|
74
75
|
target-version = "py311"
|
|
75
76
|
fix = true
|
|
77
|
+
# Files that use syntax newer than the oldest supported Python (see typedframes/compat.py).
|
|
78
|
+
per-file-target-version = { "src/typedframes/python315.py" = "py315" }
|
|
76
79
|
|
|
77
80
|
[tool.ruff.format]
|
|
78
81
|
# Ensure the formatter respects the limit
|
|
@@ -111,11 +114,6 @@ ignore = [
|
|
|
111
114
|
"tasks.py" = ["T201"]
|
|
112
115
|
"src/typedframes/cli.py" = ["T201"]
|
|
113
116
|
"benchmarks/*" = ["T201", "S603", "S607", "PLR2004", "PLR0912", "PLR0913", "TRY300"]
|
|
114
|
-
# Deprecated PolarsFrame classmethod stubs (read_csv/read_parquet/read_json/read_excel)
|
|
115
|
-
# intentionally don't use `source`/`schema` -- they exist only to raise a deprecation
|
|
116
|
-
# warning and forward to the real pandas/polars call, matching the real signatures
|
|
117
|
-
# they stand in for.
|
|
118
|
-
"src/typedframes/polars.py" = ["ARG003"]
|
|
119
117
|
|
|
120
118
|
[tool.ruff.lint.mccabe]
|
|
121
119
|
max-complexity = 10
|
|
@@ -144,7 +142,7 @@ dev = [
|
|
|
144
142
|
"pytest>=9.1.1",
|
|
145
143
|
"pytest-cov>=7.1.0",
|
|
146
144
|
"pytest-xdist>=3.8.0",
|
|
147
|
-
"ruff>=0.
|
|
145
|
+
"ruff>=0.17.0",
|
|
148
146
|
"ty>=0.0.84",
|
|
149
147
|
"openpyxl>=3.1.5",
|
|
150
148
|
"pyarrow>=25.0.1",
|
|
@@ -174,6 +172,10 @@ branch_coverage_min = 100
|
|
|
174
172
|
file_line_coverage_min = 100
|
|
175
173
|
file_branch_coverage_min = 100
|
|
176
174
|
|
|
175
|
+
[tool.ty.src]
|
|
176
|
+
# Uses syntax newer than requires-python (see typedframes/compat.py); ruff still checks it.
|
|
177
|
+
exclude = ["src/typedframes/python315.py"]
|
|
178
|
+
|
|
177
179
|
[tool.ty.terminal]
|
|
178
180
|
output-format = "concise"
|
|
179
181
|
|
|
@@ -224,20 +226,6 @@ include = ["benchmarks/**/*.py"]
|
|
|
224
226
|
[tool.ty.overrides.rules]
|
|
225
227
|
no-matching-overload = "ignore"
|
|
226
228
|
|
|
227
|
-
# PandasFrame is deprecated (see its module docstring): it subclasses pd.DataFrame to
|
|
228
|
-
# attach schema-aware __getitem__/groupby overrides, which structurally can't satisfy
|
|
229
|
-
# pd.DataFrame's own signatures -- that mismatch is the reason the class is deprecated
|
|
230
|
-
# in favor of Annotated[pd.DataFrame, Schema], not a bug to work around case-by-case.
|
|
231
|
-
[[tool.ty.overrides]]
|
|
232
|
-
include = ["src/typedframes/pandas.py"]
|
|
233
|
-
|
|
234
|
-
[tool.ty.overrides.rules]
|
|
235
|
-
invalid-method-override = "ignore"
|
|
236
|
-
no-matching-overload = "ignore"
|
|
237
|
-
invalid-argument-type = "ignore"
|
|
238
|
-
too-many-positional-arguments = "ignore"
|
|
239
|
-
invalid-return-type = "ignore"
|
|
240
|
-
|
|
241
229
|
[tool.typedframes]
|
|
242
230
|
enabled = true
|
|
243
231
|
warnings = true
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
// Directories that should never be descended into when collecting `.py` files by
|
|
6
6
|
// default: VCS metadata, virtualenvs, caches, editor/tool state, and vendored/build
|
|
7
|
-
// trees. Mirrors ruff's default exclude list (
|
|
7
|
+
// trees. Mirrors ruff's default exclude list, plus `target` (the Rust/maturin build
|
|
8
|
+
// output), and cli.py's own `_EXCLUDED_DIRS`,
|
|
8
9
|
// which MUST be kept in sync with this) -- including ruff's own override semantics:
|
|
9
10
|
// `[tool.typedframes] exclude` in pyproject.toml REPLACES this set entirely rather
|
|
10
11
|
// than adding to it (see `collect_py_files`).
|
|
@@ -35,6 +36,7 @@ pub(crate) const DEFAULT_EXCLUDED_DIRS: &[&str] = &[
|
|
|
35
36
|
"dist",
|
|
36
37
|
"node_modules",
|
|
37
38
|
"site-packages",
|
|
39
|
+
"target",
|
|
38
40
|
"venv",
|
|
39
41
|
];
|
|
40
42
|
|
|
@@ -2653,6 +2653,36 @@ class VendoredSchema(BaseSchema):
|
|
|
2653
2653
|
assert!(!index.all_schemas.contains_key("VendoredSchema"));
|
|
2654
2654
|
}
|
|
2655
2655
|
|
|
2656
|
+
#[test]
|
|
2657
|
+
fn test_should_prune_a_rust_target_directory_by_default() {
|
|
2658
|
+
let dir = tempfile::tempdir().unwrap();
|
|
2659
|
+
let root = dir.path();
|
|
2660
|
+
fs::create_dir_all(root.join("rust").join("target").join("debug")).unwrap();
|
|
2661
|
+
fs::write(
|
|
2662
|
+
root.join("rust")
|
|
2663
|
+
.join("target")
|
|
2664
|
+
.join("debug")
|
|
2665
|
+
.join("generated.py"),
|
|
2666
|
+
"x = 1\n",
|
|
2667
|
+
)
|
|
2668
|
+
.unwrap();
|
|
2669
|
+
fs::write(root.join("app.py"), "x = 1\n").unwrap();
|
|
2670
|
+
|
|
2671
|
+
// act
|
|
2672
|
+
let index = build_index_internal(root);
|
|
2673
|
+
|
|
2674
|
+
// assert
|
|
2675
|
+
let indexed: Vec<&String> = index.files.keys().collect();
|
|
2676
|
+
assert!(
|
|
2677
|
+
indexed.iter().any(|p| p.ends_with("app.py")),
|
|
2678
|
+
"{indexed:#?}"
|
|
2679
|
+
);
|
|
2680
|
+
assert!(
|
|
2681
|
+
!indexed.iter().any(|p| p.ends_with("generated.py")),
|
|
2682
|
+
"{indexed:#?}"
|
|
2683
|
+
);
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2656
2686
|
#[test]
|
|
2657
2687
|
fn test_should_prune_dot_claude_by_default_with_no_config_at_all() {
|
|
2658
2688
|
// .claude is in DEFAULT_EXCLUDED_DIRS -- pruned automatically with no
|
|
@@ -12,10 +12,6 @@ Core Classes:
|
|
|
12
12
|
ColumnSet: Define a group of columns matching a pattern.
|
|
13
13
|
ColumnGroup: Group multiple Columns/ColumnSets for convenient access.
|
|
14
14
|
|
|
15
|
-
Frame Classes (separate imports):
|
|
16
|
-
PandasFrame: ``from typedframes.pandas import PandasFrame``
|
|
17
|
-
PolarsFrame: ``from typedframes.polars import PolarsFrame``
|
|
18
|
-
|
|
19
15
|
Usage:
|
|
20
16
|
from typing import Annotated
|
|
21
17
|
import pandas as pd
|
|
@@ -37,7 +33,7 @@ Usage:
|
|
|
37
33
|
df.filter(UserSchema.user_id.col > 10) # ✓ Refactor-safe polars expression
|
|
38
34
|
"""
|
|
39
35
|
|
|
40
|
-
__version__ = "0.
|
|
36
|
+
__version__ = "0.12.0"
|
|
41
37
|
|
|
42
38
|
from .base_schema import BaseSchema as BaseSchema
|
|
43
39
|
from .column import Column as Column
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import re
|
|
6
|
-
from collections import defaultdict
|
|
7
6
|
from typing import TYPE_CHECKING, ClassVar
|
|
8
7
|
|
|
9
8
|
from .column import Column
|
|
10
9
|
from .column_group import ColumnGroup
|
|
11
|
-
from .column_group_error import ColumnGroupError
|
|
12
10
|
from .column_set import ColumnSet
|
|
13
11
|
|
|
14
12
|
if TYPE_CHECKING:
|
|
@@ -72,9 +70,7 @@ class BaseSchema(metaclass=SchemaMeta):
|
|
|
72
70
|
|
|
73
71
|
Class Attributes:
|
|
74
72
|
enforce_columns: If True, validate that all defined columns exist.
|
|
75
|
-
enforce_types: If True, enforce column types during I/O operations.
|
|
76
73
|
allow_extra_columns: If True, allow columns not defined in schema.
|
|
77
|
-
greedy_column_sets: If True, allow columns to match multiple ColumnSets.
|
|
78
74
|
|
|
79
75
|
Example:
|
|
80
76
|
class UserData(BaseSchema):
|
|
@@ -93,9 +89,7 @@ class BaseSchema(metaclass=SchemaMeta):
|
|
|
93
89
|
_column_group_map: ClassVar[dict[str, ColumnGroup] | None] = None
|
|
94
90
|
|
|
95
91
|
enforce_columns: ClassVar[bool] = True
|
|
96
|
-
enforce_types: ClassVar[bool] = True
|
|
97
92
|
allow_extra_columns: ClassVar[bool] = True
|
|
98
|
-
greedy_column_sets: ClassVar[bool] = False
|
|
99
93
|
|
|
100
94
|
@classmethod
|
|
101
95
|
def columns(cls) -> dict[str, Column]:
|
|
@@ -129,82 +123,6 @@ class BaseSchema(metaclass=SchemaMeta):
|
|
|
129
123
|
|
|
130
124
|
return names
|
|
131
125
|
|
|
132
|
-
@classmethod
|
|
133
|
-
def _build_key_column_map(cls) -> dict[str, Column]:
|
|
134
|
-
"""Build mapping of column keys to Column objects."""
|
|
135
|
-
key_column_map: dict[str, Column] = {}
|
|
136
|
-
for col in cls.columns().values():
|
|
137
|
-
key_column_map[col.column_name] = col
|
|
138
|
-
return key_column_map
|
|
139
|
-
|
|
140
|
-
@classmethod
|
|
141
|
-
def _match_column_to_set(
|
|
142
|
-
cls,
|
|
143
|
-
col_name: str,
|
|
144
|
-
cs: ColumnSet,
|
|
145
|
-
*,
|
|
146
|
-
consumed: bool,
|
|
147
|
-
greedy: bool,
|
|
148
|
-
current_match: Column | ColumnSet | None,
|
|
149
|
-
) -> bool:
|
|
150
|
-
"""Check if column matches a ColumnSet. Returns True if matched."""
|
|
151
|
-
matches = any(re.match(pattern, col_name) for pattern in cs.members) if cs.regex else col_name in cs.members
|
|
152
|
-
|
|
153
|
-
if matches and consumed and not greedy:
|
|
154
|
-
raise ColumnGroupError(col_name, current_match, cs)
|
|
155
|
-
|
|
156
|
-
return matches and not consumed
|
|
157
|
-
|
|
158
|
-
@classmethod
|
|
159
|
-
def compute_column_map(
|
|
160
|
-
cls,
|
|
161
|
-
dataframe_columns: list[str],
|
|
162
|
-
*,
|
|
163
|
-
greedy: bool | None = None,
|
|
164
|
-
) -> tuple[dict[str, type], dict[str, list[str]]]:
|
|
165
|
-
"""
|
|
166
|
-
Compute column type map and ColumnSet consumption from actual DataFrame columns.
|
|
167
|
-
|
|
168
|
-
Args:
|
|
169
|
-
dataframe_columns: List of column names from the DataFrame.
|
|
170
|
-
greedy: Override greedy_column_sets setting.
|
|
171
|
-
|
|
172
|
-
Returns:
|
|
173
|
-
Tuple of (column_type_map, column_consumed_map) where:
|
|
174
|
-
- column_type_map: Dict mapping column name to its type
|
|
175
|
-
- column_consumed_map: Dict mapping ColumnSet name to list of matched columns
|
|
176
|
-
|
|
177
|
-
Raises:
|
|
178
|
-
ColumnGroupError: If a column matches multiple ColumnSets (when not greedy).
|
|
179
|
-
|
|
180
|
-
"""
|
|
181
|
-
greedy = greedy if greedy is not None else cls.greedy_column_sets
|
|
182
|
-
column_consumed_map: dict[str, list[str]] = defaultdict(list)
|
|
183
|
-
key_column_map = cls._build_key_column_map()
|
|
184
|
-
|
|
185
|
-
if not cls.column_sets():
|
|
186
|
-
return {k: v.type for k, v in key_column_map.items()}, dict(column_consumed_map)
|
|
187
|
-
|
|
188
|
-
column_bag: list[Column | ColumnSet | None] = [key_column_map.get(c) for c in dataframe_columns]
|
|
189
|
-
consumed: list[bool] = [col is not None for col in column_bag]
|
|
190
|
-
|
|
191
|
-
column_sets_list = list(cls.column_sets().values())
|
|
192
|
-
for i, col_name in enumerate(dataframe_columns):
|
|
193
|
-
for cs in column_sets_list:
|
|
194
|
-
if cls._match_column_to_set(
|
|
195
|
-
col_name, cs, consumed=consumed[i], greedy=greedy, current_match=column_bag[i]
|
|
196
|
-
):
|
|
197
|
-
consumed[i] = True
|
|
198
|
-
column_bag[i] = cs
|
|
199
|
-
column_consumed_map[cs.name].append(col_name)
|
|
200
|
-
|
|
201
|
-
result: dict[str, type] = {}
|
|
202
|
-
for i, col_or_set in enumerate(column_bag):
|
|
203
|
-
if col_or_set is not None:
|
|
204
|
-
result[dataframe_columns[i]] = col_or_set.type
|
|
205
|
-
|
|
206
|
-
return result, dict(column_consumed_map)
|
|
207
|
-
|
|
208
126
|
@classmethod
|
|
209
127
|
def validate_columns(cls, df_columns: list[str]) -> list[str]:
|
|
210
128
|
"""
|