pandera-mypy 0.0.1__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.
- pandera_mypy-0.0.1/.github/workflows/ci.yml +120 -0
- pandera_mypy-0.0.1/.github/workflows/publish.yml +151 -0
- pandera_mypy-0.0.1/.gitignore +216 -0
- pandera_mypy-0.0.1/LICENSE +21 -0
- pandera_mypy-0.0.1/PKG-INFO +177 -0
- pandera_mypy-0.0.1/README.md +148 -0
- pandera_mypy-0.0.1/pyproject.toml +88 -0
- pandera_mypy-0.0.1/src/pandera_mypy/__init__.py +21 -0
- pandera_mypy-0.0.1/src/pandera_mypy/plugin.py +269 -0
- pandera_mypy-0.0.1/tests/__init__.py +1 -0
- pandera_mypy-0.0.1/tests/sources/plugin/bare_type_column_resolves_to_str.txt +8 -0
- pandera_mypy-0.0.1/tests/sources/plugin/classvar_unaffected.txt +9 -0
- pandera_mypy-0.0.1/tests/sources/plugin/dataframemodel_method_unaffected.txt +11 -0
- pandera_mypy-0.0.1/tests/sources/plugin/field_with_constraints_resolves_to_str.txt +9 -0
- pandera_mypy-0.0.1/tests/sources/plugin/inherited_column_resolves_to_str.txt +11 -0
- pandera_mypy-0.0.1/tests/sources/plugin/instance_access_resolves_to_str.txt +10 -0
- pandera_mypy-0.0.1/tests/sources/plugin/multiple_inheritance_resolves_to_str.txt +14 -0
- pandera_mypy-0.0.1/tests/sources/plugin/plain_class_unaffected.txt +8 -0
- pandera_mypy-0.0.1/tests/sources/plugin/series_column_resolves_to_str.txt +11 -0
- pandera_mypy-0.0.1/tests/support.py +46 -0
- pandera_mypy-0.0.1/tests/test_plugin.py +37 -0
- pandera_mypy-0.0.1/tests/test_problem_statement.py +47 -0
- pandera_mypy-0.0.1/uv.lock +778 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
lint:
|
|
15
|
+
name: ruff
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
19
|
+
|
|
20
|
+
- name: Set up uv
|
|
21
|
+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
enable-cache: true
|
|
25
|
+
cache-dependency-glob: "uv.lock"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --group dev
|
|
29
|
+
|
|
30
|
+
- name: Check lockfile is up to date
|
|
31
|
+
run: uv lock --check
|
|
32
|
+
|
|
33
|
+
- name: Ruff format check
|
|
34
|
+
run: uv run ruff format --check .
|
|
35
|
+
|
|
36
|
+
- name: Ruff lint check
|
|
37
|
+
run: uv run ruff check .
|
|
38
|
+
|
|
39
|
+
build:
|
|
40
|
+
name: build wheel + sdist
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
44
|
+
|
|
45
|
+
- name: Set up uv
|
|
46
|
+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
|
|
47
|
+
with:
|
|
48
|
+
python-version: "3.12"
|
|
49
|
+
enable-cache: true
|
|
50
|
+
cache-dependency-glob: "uv.lock"
|
|
51
|
+
|
|
52
|
+
- name: Build
|
|
53
|
+
run: uv build
|
|
54
|
+
|
|
55
|
+
typecheck:
|
|
56
|
+
name: mypy
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
60
|
+
|
|
61
|
+
- name: Set up uv
|
|
62
|
+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
|
|
63
|
+
with:
|
|
64
|
+
python-version: "3.12"
|
|
65
|
+
enable-cache: true
|
|
66
|
+
cache-dependency-glob: "uv.lock"
|
|
67
|
+
|
|
68
|
+
- name: Install dependencies
|
|
69
|
+
run: uv sync --group dev
|
|
70
|
+
|
|
71
|
+
- name: Run mypy
|
|
72
|
+
run: uv run mypy src
|
|
73
|
+
|
|
74
|
+
pytest:
|
|
75
|
+
name: >-
|
|
76
|
+
pytest (pandera ${{ matrix.pandera-version }},
|
|
77
|
+
Python ${{ matrix.python-version }}, ${{ matrix.os-name }})
|
|
78
|
+
runs-on: ${{ matrix.os }}
|
|
79
|
+
strategy:
|
|
80
|
+
fail-fast: false
|
|
81
|
+
matrix:
|
|
82
|
+
# latest patch of every minor release from the minimum supported
|
|
83
|
+
# version (0.21) through the current latest (0.31); note that there
|
|
84
|
+
# is no stable 0.24 release (only 0.24.0rc0 was published).
|
|
85
|
+
pandera-version:
|
|
86
|
+
- "0.21.1"
|
|
87
|
+
- "0.22.1"
|
|
88
|
+
- "0.23.1"
|
|
89
|
+
- "0.25.0"
|
|
90
|
+
- "0.26.1"
|
|
91
|
+
- "0.27.1"
|
|
92
|
+
- "0.28.1"
|
|
93
|
+
- "0.29.0"
|
|
94
|
+
- "0.30.1"
|
|
95
|
+
- "0.31.1"
|
|
96
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
97
|
+
os: [ubuntu-latest, windows-latest]
|
|
98
|
+
include:
|
|
99
|
+
- os: ubuntu-latest
|
|
100
|
+
os-name: Linux
|
|
101
|
+
- os: windows-latest
|
|
102
|
+
os-name: Windows
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
105
|
+
|
|
106
|
+
- name: Set up uv
|
|
107
|
+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
|
|
108
|
+
with:
|
|
109
|
+
python-version: ${{ matrix.python-version }}
|
|
110
|
+
enable-cache: true
|
|
111
|
+
cache-dependency-glob: "uv.lock"
|
|
112
|
+
|
|
113
|
+
- name: Install dependencies
|
|
114
|
+
run: uv sync --group dev
|
|
115
|
+
|
|
116
|
+
- name: Override pandera version
|
|
117
|
+
run: uv pip install "pandera[polars]==${{ matrix.pandera-version }}"
|
|
118
|
+
|
|
119
|
+
- name: Run pytest
|
|
120
|
+
run: uv run pytest
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Triggers on pushes to main that modify pyproject.toml, plus manual dispatch.
|
|
4
|
+
# The workflow publishes only when project.version actually changed compared
|
|
5
|
+
# with the previous state of main.
|
|
6
|
+
#
|
|
7
|
+
# Setup (one-time, before first publish):
|
|
8
|
+
# 1. Create the GitHub Actions environment named "pypi" in this repo.
|
|
9
|
+
# 2. On PyPI, add a pending Trusted Publisher for project "pandera-mypy":
|
|
10
|
+
# https://pypi.org/manage/account/publishing/
|
|
11
|
+
# 3. Configure it with:
|
|
12
|
+
# - Owner: TymoteuszChatys
|
|
13
|
+
# - Repo: pandera-mypy
|
|
14
|
+
# - Workflow: publish.yml
|
|
15
|
+
# - Environment: pypi
|
|
16
|
+
# - Project name: pandera-mypy
|
|
17
|
+
# 4. Ensure the pypi environment has no required reviewers; otherwise
|
|
18
|
+
# publishing will pause for manual approval.
|
|
19
|
+
on:
|
|
20
|
+
workflow_dispatch:
|
|
21
|
+
push:
|
|
22
|
+
branches: [main]
|
|
23
|
+
paths:
|
|
24
|
+
- pyproject.toml
|
|
25
|
+
|
|
26
|
+
permissions:
|
|
27
|
+
contents: read
|
|
28
|
+
|
|
29
|
+
jobs:
|
|
30
|
+
publish:
|
|
31
|
+
name: Build and publish to PyPI
|
|
32
|
+
if: github.ref == 'refs/heads/main'
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
environment: pypi
|
|
35
|
+
permissions:
|
|
36
|
+
contents: read
|
|
37
|
+
id-token: write # required for OIDC Trusted Publishing
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0
|
|
43
|
+
|
|
44
|
+
- name: Set up uv
|
|
45
|
+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
|
|
46
|
+
with:
|
|
47
|
+
python-version: "3.12"
|
|
48
|
+
enable-cache: true
|
|
49
|
+
cache-dependency-glob: "uv.lock"
|
|
50
|
+
|
|
51
|
+
- name: Detect version bump
|
|
52
|
+
id: version_check
|
|
53
|
+
run: |
|
|
54
|
+
CURRENT_VERSION=$(python - <<'PY'
|
|
55
|
+
from pathlib import Path
|
|
56
|
+
import tomllib
|
|
57
|
+
|
|
58
|
+
print(tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"])
|
|
59
|
+
PY
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
PREVIOUS_VERSION=$(python - <<'PY'
|
|
63
|
+
import os
|
|
64
|
+
import subprocess
|
|
65
|
+
import tomllib
|
|
66
|
+
|
|
67
|
+
before = os.environ.get("GITHUB_EVENT_BEFORE", "")
|
|
68
|
+
if not before or set(before) == {"0"}:
|
|
69
|
+
print("")
|
|
70
|
+
else:
|
|
71
|
+
result = subprocess.run(
|
|
72
|
+
["git", "show", f"{before}:pyproject.toml"],
|
|
73
|
+
check=False,
|
|
74
|
+
capture_output=True,
|
|
75
|
+
text=True,
|
|
76
|
+
)
|
|
77
|
+
if result.returncode != 0:
|
|
78
|
+
print("")
|
|
79
|
+
else:
|
|
80
|
+
print(tomllib.loads(result.stdout)["project"]["version"])
|
|
81
|
+
PY
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
{
|
|
85
|
+
echo "current_version=$CURRENT_VERSION"
|
|
86
|
+
echo "previous_version=$PREVIOUS_VERSION"
|
|
87
|
+
} >> "$GITHUB_OUTPUT"
|
|
88
|
+
|
|
89
|
+
if [ -z "$PREVIOUS_VERSION" ]; then
|
|
90
|
+
echo "Previous version unavailable; publishing $CURRENT_VERSION."
|
|
91
|
+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
|
92
|
+
exit 0
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
if [ "$CURRENT_VERSION" = "$PREVIOUS_VERSION" ]; then
|
|
96
|
+
echo "Version unchanged ($CURRENT_VERSION); skipping publish."
|
|
97
|
+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
|
|
98
|
+
exit 0
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
echo "Version changed: $PREVIOUS_VERSION -> $CURRENT_VERSION"
|
|
102
|
+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
|
103
|
+
|
|
104
|
+
- name: Check whether version already exists on PyPI
|
|
105
|
+
id: pypi_check
|
|
106
|
+
if: steps.version_check.outputs.should_publish == 'true'
|
|
107
|
+
env:
|
|
108
|
+
PACKAGE_VERSION: ${{ steps.version_check.outputs.current_version }}
|
|
109
|
+
run: |
|
|
110
|
+
python - <<'PY'
|
|
111
|
+
import json
|
|
112
|
+
import os
|
|
113
|
+
import urllib.error
|
|
114
|
+
import urllib.request
|
|
115
|
+
|
|
116
|
+
version = os.environ["PACKAGE_VERSION"]
|
|
117
|
+
url = "https://pypi.org/pypi/pandera-mypy/json"
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
with urllib.request.urlopen(url, timeout=30) as response:
|
|
121
|
+
releases = json.load(response)["releases"]
|
|
122
|
+
except urllib.error.HTTPError as error:
|
|
123
|
+
if error.code == 404:
|
|
124
|
+
releases = {}
|
|
125
|
+
else:
|
|
126
|
+
raise
|
|
127
|
+
|
|
128
|
+
already_published = version in releases and bool(releases[version])
|
|
129
|
+
if already_published:
|
|
130
|
+
print(f"Version {version} already exists on PyPI.")
|
|
131
|
+
else:
|
|
132
|
+
print(f"Version {version} is not on PyPI yet.")
|
|
133
|
+
|
|
134
|
+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
|
|
135
|
+
output.write(
|
|
136
|
+
"already_published="
|
|
137
|
+
f"{str(already_published).lower()}\n"
|
|
138
|
+
)
|
|
139
|
+
PY
|
|
140
|
+
|
|
141
|
+
- name: Build wheel and sdist
|
|
142
|
+
if: |
|
|
143
|
+
steps.version_check.outputs.should_publish == 'true' &&
|
|
144
|
+
steps.pypi_check.outputs.already_published != 'true'
|
|
145
|
+
run: uv build
|
|
146
|
+
|
|
147
|
+
- name: Publish to PyPI
|
|
148
|
+
if: |
|
|
149
|
+
steps.version_check.outputs.should_publish == 'true' &&
|
|
150
|
+
steps.pypi_check.outputs.already_published != 'true'
|
|
151
|
+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 (v1.14.0)
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# Sandbox-generated Excel files
|
|
210
|
+
*.xlsx
|
|
211
|
+
|
|
212
|
+
# Benchmark cache
|
|
213
|
+
.benchmark_cache/
|
|
214
|
+
|
|
215
|
+
# Benchmark results
|
|
216
|
+
benchmark_results/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tymoteusz Chatys
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pandera-mypy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Mypy plugin that resolves Pandera DataFrameModel column attributes as str
|
|
5
|
+
Project-URL: Homepage, https://github.com/TymoteuszChatys/pandera-mypy
|
|
6
|
+
Project-URL: Repository, https://github.com/TymoteuszChatys/pandera-mypy
|
|
7
|
+
Project-URL: Issues, https://github.com/TymoteuszChatys/pandera-mypy/issues
|
|
8
|
+
Author-email: Tymoteusz Chatys <tymoteuszchatys@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: mypy,pandera,plugin,polars,type-checking
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: <3.15,>=3.10
|
|
27
|
+
Requires-Dist: mypy>=1.0.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# pandera-mypy
|
|
31
|
+
|
|
32
|
+
> A mypy plugin that resolves [Pandera](https://pandera.readthedocs.io/) `DataFrameModel` column attributes as `str`, eliminating false type errors when passing column names to `polars.col()` or any other `str`-expecting API.
|
|
33
|
+
|
|
34
|
+
## The Problem
|
|
35
|
+
|
|
36
|
+
Pandera's `DataFrameModel` supports a convenient **bare-type** shorthand for
|
|
37
|
+
column annotations, where a plain Python type is used instead of the full
|
|
38
|
+
`Series[T]` form:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import pandera.polars as pa
|
|
42
|
+
|
|
43
|
+
class MySchema(pa.DataFrameModel):
|
|
44
|
+
quantity: int # shorthand for Series[int]
|
|
45
|
+
label: str # shorthand for Series[str]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
At **runtime**, accessing a column attribute always returns its *name* as a
|
|
49
|
+
plain `str`:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
>>> MySchema.quantity
|
|
53
|
+
'quantity'
|
|
54
|
+
>>> MySchema.label
|
|
55
|
+
'label'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Without the plugin, mypy infers the **declared type** (`int`, `str`, …) rather
|
|
59
|
+
than `str`, causing spurious errors when column names are passed to
|
|
60
|
+
`polars.col()` or any other `str`-expecting API:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import polars as pl
|
|
64
|
+
|
|
65
|
+
pl.col(MySchema.quantity)
|
|
66
|
+
# ^ error: Argument 1 to "col" has incompatible type "int"; expected "str"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> **`Series[T]` annotations**: Pandera's bundled stubs already type
|
|
70
|
+
> class-level attribute access as `str` for `Series[T]`-annotated columns
|
|
71
|
+
> across all supported versions (0.21.1-0.31.1). The plugin ensures uniform
|
|
72
|
+
> `str` inference when schemas mix `Series[T]` and bare-type annotations.
|
|
73
|
+
|
|
74
|
+
## The Solution
|
|
75
|
+
|
|
76
|
+
This plugin overrides the inferred type of every column-annotated attribute on
|
|
77
|
+
a `DataFrameModel` subclass to `str`, matching the actual runtime behaviour —
|
|
78
|
+
no changes to your Pandera models required.
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# With the plugin enabled:
|
|
82
|
+
pl.col(MySchema.quantity) # ✅ no error
|
|
83
|
+
col_name: str = MySchema.quantity # ✅ no error
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install pandera-mypy
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# or with uv:
|
|
94
|
+
uv add pandera-mypy
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
Add the plugin to your mypy configuration and that's it:
|
|
100
|
+
|
|
101
|
+
**`mypy.ini`**
|
|
102
|
+
```ini
|
|
103
|
+
[mypy]
|
|
104
|
+
plugins = pandera_mypy.plugin
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**`pyproject.toml`**
|
|
108
|
+
```toml
|
|
109
|
+
[tool.mypy]
|
|
110
|
+
plugins = ["pandera_mypy.plugin"]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**`setup.cfg`**
|
|
114
|
+
```ini
|
|
115
|
+
[mypy]
|
|
116
|
+
plugins = pandera_mypy.plugin
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Compatibility
|
|
120
|
+
|
|
121
|
+
| Python | Supported |
|
|
122
|
+
|--------|-----------|
|
|
123
|
+
| 3.10 | ✅ |
|
|
124
|
+
| 3.11 | ✅ |
|
|
125
|
+
| 3.12 | ✅ |
|
|
126
|
+
| 3.13 | ✅ |
|
|
127
|
+
| 3.14 | ✅ |
|
|
128
|
+
|
|
129
|
+
Requires `mypy >= 1.0.0` and works with both the **Polars** and **Pandas** backends of Pandera.
|
|
130
|
+
|
|
131
|
+
## How It Works
|
|
132
|
+
|
|
133
|
+
The plugin implements mypy's `get_class_attribute_hook` (for `MySchema.price` style class-level access) and `get_attribute_hook` (for instance-level access).
|
|
134
|
+
|
|
135
|
+
For every attribute access, it checks whether:
|
|
136
|
+
|
|
137
|
+
1. The owning class inherits from a Pandera `DataFrameModel` (detected via the MRO, so indirect subclasses work too).
|
|
138
|
+
2. The attribute is annotated with a Pandera column type — either `Series[T]` or a bare type such as `int`.
|
|
139
|
+
|
|
140
|
+
When both conditions hold, the plugin replaces the inferred type with `builtins.str`.
|
|
141
|
+
|
|
142
|
+
> **Why `get_class_attribute_hook`?**
|
|
143
|
+
> Mypy routes class-level attribute access (e.g. `MySchema.price`) through
|
|
144
|
+
> `get_class_attribute_hook` in `mypy.checkmember`, **not** through
|
|
145
|
+
> `get_attribute_hook`. Using only `get_attribute_hook` would leave the common
|
|
146
|
+
> `pl.col(MySchema.price)` pattern uncorrected.
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Install all dependencies including the dev group
|
|
152
|
+
uv sync --group dev
|
|
153
|
+
|
|
154
|
+
# Run the test suite with coverage
|
|
155
|
+
uv run pytest
|
|
156
|
+
|
|
157
|
+
# Type-check the plugin
|
|
158
|
+
uv run mypy src
|
|
159
|
+
|
|
160
|
+
# Lint (report only)
|
|
161
|
+
uv run ruff check .
|
|
162
|
+
|
|
163
|
+
# Lint and auto-fix
|
|
164
|
+
uv run ruff check --fix .
|
|
165
|
+
|
|
166
|
+
# Format
|
|
167
|
+
uv run ruff format .
|
|
168
|
+
|
|
169
|
+
# Check formatting without changing files
|
|
170
|
+
uv run ruff format --check .
|
|
171
|
+
|
|
172
|
+
# Verify the lockfile is up to date with pyproject.toml
|
|
173
|
+
uv lock --check
|
|
174
|
+
|
|
175
|
+
# Build the wheel and sdist
|
|
176
|
+
uv build
|
|
177
|
+
```
|