Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
polars-version: ["0.20.0", "1.33.1"]
defaults:
run:
Expand All @@ -51,7 +51,7 @@ jobs:
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install 'uv<0.7.0' nox pre_commit \
python -m pip install 'uv<1.0.0' nox pre_commit \
mypy==0.982 \
types-click \
types-pytz \
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
pydantic-version: ["2.10.6"]
steps:
- uses: actions/checkout@v4
Expand All @@ -103,7 +103,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dev deps
shell: bash
run: pip install 'uv<0.7.0' nox
run: pip install 'uv<1.0.0' nox
- run: |
pip list
printenv | sort
Expand All @@ -126,7 +126,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
pandas-version: ["2.1.1", "2.2.3"]
pydantic-version: ["1.10.11", "2.10.6"]
exclude:
Expand All @@ -140,7 +140,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dev deps
shell: bash
run: pip install 'uv<0.7.0' nox
run: pip install 'uv<1.0.0' nox
- run: |
pip list
printenv | sort
Expand All @@ -163,7 +163,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
pandas-version: ["2.2.3"]
pydantic-version: ["2.10.6"]
extra:
Expand All @@ -184,7 +184,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dev deps
shell: bash
run: pip install 'uv<0.7.0' nox
run: pip install 'uv<1.0.0' nox
- run: |
pip list
printenv | sort
Expand All @@ -209,7 +209,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
extra:
- dask
- polars
Expand Down Expand Up @@ -255,7 +255,7 @@ jobs:

- name: Install dev deps
shell: bash
run: pip install 'uv<0.7.0' nox
run: pip install 'uv<1.0.0' nox

- run: |
pip list
Expand All @@ -278,7 +278,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
defaults:
run:
shell: bash -l {0}
Expand All @@ -302,7 +302,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install 'uv<0.7.0' nox
run: pip install 'uv<1.0.0' nox
- name: Pip info
run: python -m pip list

Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"docs",
)

PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
PANDAS_VERSIONS = ["2.1.1", "2.2.3"]
PYDANTIC_VERSIONS = ["1.10.11", "2.10.6"]
POLARS_VERSIONS = ["0.20.0", "1.33.1"]
Expand Down
12 changes: 5 additions & 7 deletions pandera/api/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from enum import Enum
from functools import partial, wraps
from inspect import signature
from typing import Callable, Optional, Union

import typing_inspect
from typing import Callable, Optional, Union, get_args, get_origin

from pandera.api.checks import Check
from pandera.api.hypotheses import Hypothesis
Expand Down Expand Up @@ -56,11 +54,11 @@ def register_builtin_check(
# object to validate is the first argument.
data_type = [*fn_sig.parameters.values()][0].annotation

if typing_inspect.get_origin(data_type) is tuple:
data_type, *_ = typing_inspect.get_args(data_type)
if get_origin(data_type) is tuple:
data_type, *_ = get_args(data_type)

if typing_inspect.get_origin(data_type) is Union:
data_types = typing_inspect.get_args(data_type)
if get_origin(data_type) is Union:
data_types = get_args(data_type)
else:
data_types = (data_type,)

Expand Down
11 changes: 5 additions & 6 deletions pandera/api/function_dispatch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Multidispatcher implementation."""

from inspect import signature
from typing import Callable, Union
import typing_inspect
from typing import Callable, Union, get_args, get_origin


class Dispatcher:
Expand Down Expand Up @@ -52,11 +51,11 @@ def get_first_arg_type(fn):
# object to validate is the first argument.
data_type = [*fn_sig.parameters.values()][0].annotation

if typing_inspect.get_origin(data_type) in (tuple, tuple):
data_type, *_ = typing_inspect.get_args(data_type)
if get_origin(data_type) in (tuple, tuple):
data_type, *_ = get_args(data_type)

if typing_inspect.get_origin(data_type) is Union:
data_types = typing_inspect.get_args(data_type)
if get_origin(data_type) is Union:
data_types = get_args(data_type)
else:
data_types = (data_type,)

Expand Down
2 changes: 1 addition & 1 deletion pandera/api/ibis/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def validate(
... "probability": [0.1, 0.4, 0.52, 0.23, 0.8, 0.76],
... "category": ["dog", "dog", "cat", "duck", "dog", "dog"],
... })
>>> t = ibis.memtable(df, name="t")
>>> t = ibis.memtable(df)
>>>
>>> schema_withchecks = pa.DataFrameSchema({
... "probability": pa.Column(
Expand Down
8 changes: 5 additions & 3 deletions pandera/engines/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
NamedTuple,
Optional,
TypeVar,
get_args,
get_origin,
get_type_hints,
)

import typing_inspect
from typing import get_type_hints

from pandera.dtypes import DataType

Expand Down Expand Up @@ -139,7 +141,7 @@ def _register_from_parametrized_dtype(
annotations = get_type_hints(func).values()
dtype = next(iter(annotations)) # get 1st annotation
# parse typing.Union
dtypes = typing_inspect.get_args(dtype) or [dtype]
dtypes = get_args(dtype) or [dtype]

def _method(*args, **kwargs):
return func(pandera_dtype_cls, *args, **kwargs)
Expand Down Expand Up @@ -243,7 +245,7 @@ def dtype(cls: "Engine", data_type: Any) -> DataType:
registry = cls._registry[cls]

# handle python generic types, e.g. typing.Dict[str, str]
datatype_origin = typing_inspect.get_origin(data_type)
datatype_origin = get_origin(data_type)
if datatype_origin is not None:
equivalent_data_type = registry.get_equivalent(datatype_origin)
return type(equivalent_data_type)(data_type) # type: ignore
Expand Down
14 changes: 8 additions & 6 deletions pandera/typing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
TypeVar,
Union,
_GenericAlias,
get_args,
get_origin,
)

import typing_inspect
Expand Down Expand Up @@ -217,12 +219,12 @@ def _parse_annotation(self, raw_annotation: type) -> None:
if self.optional and typing_inspect.is_union_type(raw_annotation):
# Annotated with Optional or Union[..., NoneType]
# get_args -> (pandera.typing.Index[str], <class 'NoneType'>)
raw_annotation = typing_inspect.get_args(raw_annotation)[0]
raw_annotation = get_args(raw_annotation)[0]
self.raw_annotation = raw_annotation

self.origin = typing_inspect.get_origin(raw_annotation)
self.origin = get_origin(raw_annotation)
# Replace empty tuple returned from get_args by None
args = typing_inspect.get_args(raw_annotation) or None
args = get_args(raw_annotation) or None
self.args = args
self.arg = args[0] if args else args

Expand All @@ -236,14 +238,14 @@ def _parse_annotation(self, raw_annotation: type) -> None:
metadata = None

elif metadata := getattr(self.arg, "__metadata__", None):
self.arg = typing_inspect.get_args(self.arg)[0]
self.arg = get_args(self.arg)[0]

self.metadata = metadata

self.literal = typing_inspect.get_origin(self.arg) is typing.Literal
self.literal = get_origin(self.arg) is typing.Literal

if self.literal:
self.arg = typing_inspect.get_args(self.arg)[0]
self.arg = get_args(self.arg)[0]
elif self.origin is None and self.metadata is None:
if isinstance(raw_annotation, type) and issubclass(
raw_annotation, SeriesBase
Expand Down
2 changes: 0 additions & 2 deletions tests/ibis/test_ibis_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def t_basic():
"string_col": ["0", "1", "2"],
"int_col": [0, 1, 2],
},
name="t",
)


Expand Down Expand Up @@ -61,7 +60,6 @@ def t_for_regex_match():
"int_col_1": [0, 1, 2],
"int_col_2": [0, 1, 2],
},
name="t",
)


Expand Down
Loading