Column-aware pandas typing via a mypy plugin
Project description
FrameFlow
FrameFlow brings TypeScript-style, column-aware type checking to pandas via a mypy plugin. If you reference a missing column (like df["age"] when no "age" exists), you get a squiggle during type check — not at runtime.
Install (pick one)
- Recommended (pandas users)
pip install "frameflow[pandas]"
# uv: uv add "frameflow[pandas]"
- Pandera users
pip install "frameflow[pandera]"
# uv: uv add "frameflow[pandera]"
- Already have pandas and pandas-stubs installed
pip install frameflow
# uv: uv add frameflow
- Both integrations
pip install "frameflow[all]"
# uv: uv add "frameflow[all]"
Enable the plugin
In mypy.ini (or pyproject.toml under [tool.mypy]):
[mypy]
plugins = frameflow
python_version = 3.12
strict = True
[mypy-pandas.*]
ignore_missing_imports = True
[mypy-pandera.*]
ignore_missing_imports = True
You can also use the module path:
plugins = mypy_frameflow.plugin
Quick start
import pandas as pd
df = pd.DataFrame({"id": [1, 2], "name": ["a", "b"]})
_ = df["id"] # OK
_ = df["age"] # error: column not found: 'age'
It understands a few operations and updates the known column set:
pd.DataFrame({...})with a dict literal → seeds columns from keysdf.assign(x=...)→ adds columnsdf.drop(columns=[...])→ removes columns (when literals flow)df[["a","b"]]with literal strings → narrows to those columnsdf.rename(columns={"old": "new"})with a literal dict → renames- Pandera bridge:
pandera.typing.DataFrame[YourSchema]seeds from schema fields
IDE setup
VS Code
- Install the Mypy Type Checker extension (Pylance/Pyright do not run mypy plugins).
- Select your interpreter: Command Palette → “Python: Select Interpreter” → choose your project
.venv. - Install the package and extras into that env (using uv):
uv sync --extra pandas --extra pandera --extra dev
- Optional settings in
.vscode/settings.json(keeps the extension using your env + config):{ "mypy-type-checker.importStrategy": "fromEnvironment", "mypy-type-checker.args": ["--config-file", "mypy.ini"] }
- Reload the window. Open a file and you should see live mypy squiggles from FrameFlow.
PyCharm
- Install mypy into your project env:
uv sync --extra dev
- Configure mypy as an External Tool (or install a mypy plugin):
- Program:
./.venv/bin/mypy - Arguments:
--config-file mypy.ini - Working directory:
$ProjectFileDir$
- Program:
- Enable it to run on save/change if available.
CLI
uv run mypy path/to/your/code
Troubleshooting
- No squiggles in VS Code: ensure the Mypy extension is installed, the selected interpreter is your project
.venv, andplugins = frameflowis inmypy.ini. mypynot found: runuv sync --extra devor useuv run mypy ....- Pandas/Pandera types missing: install extras:
uv sync --extra pandas --extra pandera.
Notes and limitations
- Only string Literal information is tracked precisely; dynamic
strvariables are treated conservatively. - Some pandas operations are modeled best-effort; prefer literal forms when you want precise effects on the column set.
- VS Code's Pylance won't display mypy plugin errors; use the Mypy extension for live squiggles.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frameflow-0.1.0.tar.gz.
File metadata
- Download URL: frameflow-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d3703998307e074cde39a4f76328818fa693e3b968bc209c9b13ef5e2e530b
|
|
| MD5 |
44dd2e266f9338b3e9d802c0da2cac54
|
|
| BLAKE2b-256 |
0becebe915db5d3267622ccc66837780901802a2e96d60b96d998b559f277451
|
File details
Details for the file frameflow-0.1.0-py3-none-any.whl.
File metadata
- Download URL: frameflow-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e86c6dba6c35b6b6b2632530370b7661169f124db7ef77c99bffbc236db452f8
|
|
| MD5 |
23e8d3ea330870fa046cbed7240d3092
|
|
| BLAKE2b-256 |
d0fed374e1035bfae9f97f33260cea3d8022d57308eb14c7d629746619826722
|