Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ author_email: oliver.borchert@quantco.com
author_name: Oliver Borchert
github_url: https://github.com/quantco/dataframely
github_user: borchero
minimal_python_version: py310
minimal_python_version: py311
project_short_description: A declarative, polars-native data frame validation library
project_slug: dataframely
use_devcontainer: false
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 # zizmor: ignore[cache-poisoning]
with:
command: build
args: --out dist --release -i python3.10
args: --out dist --release -i python3.11
manylinux: auto
# NOTE: We also need to set up cargo-auditable inside the docker container
# where the linux build is performed.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up pixi
uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
with:
environments: default default-py310
environments: default default-py311
- name: Install Rust
run: rustup show
- name: Cache Rust dependencies
Expand All @@ -44,7 +44,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
environment: [py310, py311, py312, py313, py314]
environment: [py311, py312, py313, py314]
with_optionals: [false]
include:
# Test with optional dependencies across OSes
Expand Down
4 changes: 2 additions & 2 deletions .lefthook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pre-commit:
- assets/**/*
jobs:
- name: pixi-install
run: pixi install
run: pixi install -e default -e default-py311
- group:
parallel: true
jobs:
Expand All @@ -21,7 +21,7 @@ pre-commit:
run: pixi {run} ruff format --force-exclude
- name: mypy
glob: "*.py"
run: pixi {run} -e default-py310 mypy {staged_files}
run: pixi {run} -e default-py311 mypy {staged_files}
- name: prettier
glob: "*.{md,yml,yaml}"
run: pixi {run} prettier --write --no-error-on-unmatched-pattern --list-different --ignore-unknown {staged_files}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ polars = { version = ">=0.50", default-features = false, features = [
] }
polars-arrow = ">=0.50"
polars-core = ">=0.50"
pyo3 = { version = ">=0.25", features = ["abi3-py310", "extension-module"] }
pyo3 = { version = ">=0.25", features = ["abi3-py311", "extension-module"] }
pyo3-polars = { version = ">=0.23.1", features = ["derive", "dtype-full"] }
rand = { version = "0.9", features = ["std_rng"] }
rayon = "*"
Expand Down
8 changes: 1 addition & 7 deletions dataframely/_base_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

from __future__ import annotations

import sys
import textwrap
from abc import ABCMeta
from collections.abc import Mapping
from copy import copy
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Self

import polars as pl

Expand All @@ -18,11 +17,6 @@
from .columns import Column
from .exc import ImplementationError

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

_COLUMN_ATTR = "__dataframely_columns__"
_RULE_ATTR = "__dataframely_rules__"

Expand Down
27 changes: 12 additions & 15 deletions dataframely/_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,19 @@ def issue_deprecation_warning(message: str, *, version: str = "") -> None:
if sys.version_info >= (3, 13):
from warnings import deprecated
else:
try:
from typing_extensions import deprecated
except ImportError: # pragma: no cover

def deprecated( # type: ignore[no-redef]
message: str,
) -> Callable[[Callable[P, T]], Callable[P, T]]:
"""Fallback for :func:`warnings.deprecated` without :pep:`702` support."""
def deprecated(
message: str,
) -> Callable[[Callable[P, T]], Callable[P, T]]:
"""Fallback for :func:`warnings.deprecated` without :pep:`702` support."""

def decorate(function: Callable[P, T]) -> Callable[P, T]:
@wraps(function)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
issue_deprecation_warning(message)
return function(*args, **kwargs)
def decorate(function: Callable[P, T]) -> Callable[P, T]:
@wraps(function)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
issue_deprecation_warning(message)
return function(*args, **kwargs)

wrapper.__deprecated__ = message # type: ignore[attr-defined]
return wrapper
wrapper.__deprecated__ = message # type: ignore[attr-defined]
return wrapper

return decorate
return decorate
8 changes: 1 addition & 7 deletions dataframely/_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@

from __future__ import annotations

import sys
from collections.abc import Callable
from typing import Any
from typing import Any, Self

import polars as pl

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

ValidationFunction = Callable[[Any], pl.Expr]


Expand Down
7 changes: 1 addition & 6 deletions dataframely/collection/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from abc import ABCMeta
from collections.abc import Iterable, Mapping
from dataclasses import dataclass, field
from typing import Annotated, Any, cast, get_args, get_origin
from typing import Annotated, Any, Self, cast, get_args, get_origin

import polars as pl

Expand All @@ -20,11 +20,6 @@
from dataframely.exc import AnnotationImplementationError, ImplementationError
from dataframely.schema import Schema

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

if sys.version_info >= (3, 14):
from annotationlib import Format

Expand Down
8 changes: 1 addition & 7 deletions dataframely/collection/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
from __future__ import annotations

import os
import sys
import textwrap
from abc import ABC
from collections.abc import Callable, Mapping, Sequence
from dataclasses import asdict
from pathlib import Path
from typing import Any, Concatenate, Literal, ParamSpec, TypeVar, cast
from typing import Any, Concatenate, Literal, ParamSpec, Self, TypeVar, cast

import polars as pl

Expand All @@ -25,11 +24,6 @@
from ._base import BaseCollection
from .filter_result import CollectionFilterResult

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

_FILTER_COLUMN_PREFIX = "__DATAFRAMELY_FILTER_COLUMN__"

P = ParamSpec("P")
Expand Down
8 changes: 1 addition & 7 deletions dataframely/collection/filter_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
from __future__ import annotations

import itertools
import sys
from typing import Any, Generic, TypeVar
from typing import Any, Generic, NamedTuple, TypeVar

import polars as pl

from dataframely.filter_result import FailureInfo

from ._base import BaseCollection

if sys.version_info >= (3, 11):
from typing import NamedTuple
else:
from typing_extensions import NamedTuple

C = TypeVar("C", bound=BaseCollection)


Expand Down
8 changes: 1 addition & 7 deletions dataframely/columns/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@
from __future__ import annotations

import inspect
import sys
import warnings
from abc import ABC, abstractmethod
from collections import Counter
from collections.abc import Callable, Mapping, Sequence
from typing import Annotated, Any, TypeAlias
from typing import Annotated, Any, Self, TypeAlias

import polars as pl

from dataframely._compat import pydantic, sa, sa_TypeEngine
from dataframely._polars import PolarsDataType
from dataframely.random import Generator

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

Check: TypeAlias = (
Callable[[pl.Expr], pl.Expr]
| Sequence[Callable[[pl.Expr], pl.Expr]]
Expand Down
7 changes: 1 addition & 6 deletions dataframely/columns/_mixins.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Copyright (c) QuantCo 2025-2026
# SPDX-License-Identifier: BSD-3-Clause

import sys
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Generic, Protocol, TypeVar
from typing import TYPE_CHECKING, Any, Generic, Protocol, Self, TypeVar

import polars as pl

Expand All @@ -14,10 +13,6 @@
else:
Base = object

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

# ----------------------------------- ORDINAL MIXIN ---------------------------------- #

Expand Down
8 changes: 1 addition & 7 deletions dataframely/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@

import contextlib
import os
import sys
from types import TracebackType
from typing import Any, TypedDict, cast, get_type_hints

if sys.version_info >= (3, 11):
from typing import Unpack
else:
from typing_extensions import Unpack
from typing import Any, TypedDict, Unpack, cast, get_type_hints


class Options(TypedDict, total=False):
Expand Down
8 changes: 1 addition & 7 deletions dataframely/filter_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
from __future__ import annotations

import json
import sys
from functools import cached_property
from pathlib import Path
from typing import IO, TYPE_CHECKING, Any, Generic, TypeVar
from typing import IO, TYPE_CHECKING, Any, Generic, NamedTuple, TypeVar

import polars as pl

from dataframely._base_schema import BaseSchema

from ._typing import DataFrame, LazyFrame

if sys.version_info >= (3, 11):
from typing import NamedTuple
else:
from typing_extensions import NamedTuple

if TYPE_CHECKING: # pragma: no cover
from .schema import Schema

Expand Down
2 changes: 1 addition & 1 deletion dataframely/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def sample_choice(
norm_weights = norm_weights / norm_weights.sum()

samples = self.numpy_generator.choice(
choices, # type: ignore
choices, # type: ignore[arg-type]
size=n,
replace=True,
p=norm_weights,
Expand Down
8 changes: 1 addition & 7 deletions dataframely/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

from __future__ import annotations

import sys
import warnings
from abc import ABC
from collections.abc import Mapping, Sequence
from typing import Any, Literal, overload
from typing import Any, Literal, Self, overload

import polars as pl

Expand All @@ -28,11 +27,6 @@
from .filter_result import FailureInfo, FilterResult, LazyFilterResult
from .random import Generator

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

_COLUMN_VALID = "__DATAFRAMELY_VALID__"


Expand Down
Loading
Loading