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 .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
python-version: ["3.12", "3.13", "3.14", "3.15"]

steps:
- uses: actions/checkout@v7
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ release pull requests. Do not hand-edit generated release entries.

## Coding Style & Naming Conventions

Write Python compatible with 3.11 and follow PEP 8. Ruff enforces a 120-character line
Write Python compatible with 3.12 and follow PEP 8. Ruff enforces a 120-character line
limit, import ordering, Google-style docstrings, and the configured lint rules; Pyright
runs in strict mode. Use four-space indentation, `snake_case` for functions and modules,
`PascalCase` for classes and tagged-union types, and leading underscores for internal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


Expression aims to be a solid, type-safe, pragmatic, and high performance library for
frictionless and practical functional programming in Python 3.11+.
frictionless and practical functional programming in Python 3.12+.

By pragmatic, we mean that the goal of the library is to use simple abstractions to
enable you to do practical and productive functional programming in Python (instead of
Expand Down Expand Up @@ -57,7 +57,7 @@ many ways very similar to Python, but F# can also do a lot of things better than
## Getting Started

You can install the latest `expression` from PyPI by running `pip` (or
`pip3`). Note that `expression` only works for Python 3.11+.
`pip3`). Note that `expression` only works for Python 3.12+.

```console
> pip install expression
Expand Down Expand Up @@ -625,7 +625,7 @@ Each case exposes only its own fields. `Option` and `Result` use this same model

```python
from dataclasses import asdict
from typing import Literal, TypeAlias, assert_never, final
from typing import Literal, assert_never, final

from expression import TaggedUnion, case, tag

Expand All @@ -645,7 +645,7 @@ class Circle:
tag: Literal["circle"] = tag()


Shape: TypeAlias = TaggedUnion[Rectangle | Circle]
type Shape = TaggedUnion[Rectangle | Circle]
```


Expand Down
8 changes: 4 additions & 4 deletions README.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# %% [markdown]
"""
Expression aims to be a solid, type-safe, pragmatic, and high performance library for
frictionless and practical functional programming in Python 3.11+.
frictionless and practical functional programming in Python 3.12+.

By pragmatic, we mean that the goal of the library is to use simple abstractions to
enable you to do practical and productive functional programming in Python (instead of
Expand Down Expand Up @@ -66,7 +66,7 @@
## Getting Started

You can install the latest `expression` from PyPI by running `pip` (or
`pip3`). Note that `expression` only works for Python 3.11+.
`pip3`). Note that `expression` only works for Python 3.12+.

```console
> pip install expression
Expand Down Expand Up @@ -689,7 +689,7 @@ async def outer_option() -> AsyncGenerator[int, int]:

# %%
from dataclasses import asdict
from typing import Literal, TypeAlias, assert_never, final
from typing import Literal, assert_never, final

from expression import TaggedUnion, case, tag

Expand All @@ -709,7 +709,7 @@ class Circle:
tag: Literal["circle"] = tag()


Shape: TypeAlias = TaggedUnion[Rectangle | Circle]
type Shape = TaggedUnion[Rectangle | Circle]


# %% [markdown]
Expand Down
4 changes: 2 additions & 2 deletions TAGGED_UNION_PROPOSAL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tagged unions: implementation and rationale

**Status:** Implemented for the next major version of Expression.
**Minimum Python:** 3.11. **Optional Pydantic:** 2.10 or later, below 3.
**Minimum Python:** 3.12. **Optional Pydantic:** 2.10 or later, below 3.

Expression now represents tagged unions as explicit, frozen, final case classes
combined in public type aliases. Each case declares only its own payload. The
Expand Down Expand Up @@ -362,7 +362,7 @@ namespace. `Option.Some`, `Result.Ok`, direct union-class construction, and old
ordering is also removed. Container awaiting and generator-based Option/Result
computations are preserved. See the [migration guide](docs/guides/migration-major.md) for replacements.

The supported minimum is Python 3.11. The repository pins Pyright **1.1.414** in
The supported minimum is Python 3.12. The repository pins Pyright **1.1.414** in
[pre-commit](.pre-commit-config.yaml); the design relies on explicit unions and
dataclass typing, not on a checker-specific plugin. Versioned dependency
requirements live in [pyproject.toml](pyproject.toml).
Expand Down
19 changes: 15 additions & 4 deletions docs/guides/getting-started.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
# Getting started

Expression works with Python 3.11 and later. Install it from PyPI:
Expression works with Python 3.12 and later. Install it from PyPI:

```console
python -m pip install expression
Expand All @@ -25,10 +25,19 @@

scores = [4, 7, 12, 15]


def qualifies(score: int) -> bool:
return score >= 10


def double(score: int) -> int:
return score * 2


total = pipe(
scores,
seq.filter(lambda score: score >= 10),
seq.map(lambda score: score * 2),
seq.filter(qualifies),
seq.map(double),
seq.sum,
)

Expand All @@ -48,7 +57,9 @@
"""
Both styles use ordinary Python functions, type hints, and values. Choose the style that
your team finds easiest to read; the functional form is often easier to extend one step
per line.
per line. Named functions with parameter annotations let type checkers infer the
functional pipeline's intermediate types; unannotated lambdas inside curried calls
may not receive enough type information from the surrounding `pipe` call.

## Where to go next

Expand Down
15 changes: 14 additions & 1 deletion docs/guides/migration-major.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Migrating to case unions

This major version requires Python 3.11 or later. The optional Pydantic
This major version requires Python 3.12 or later. The optional Pydantic
integration requires Pydantic 2.10 or later to preserve generic payload
validation when caller and library type-variable names overlap.

Expression supports at least the latest three stable Python versions. Minimum
Python versions are raised in major releases; this release supports 3.12–3.15.
Python 3.11 users must remain on the previous major version.

Generic functions and classes now use Python 3.12 type parameters, for example
`def identity[T](value: T) -> T` and `class Seq[T]`. Explicit `TypeVar`
declarations remain where they preserve case covariance or type parameter
defaults, which the new syntax cannot express on Python 3.12. The public
`Option`, `Result`, and `TaggedUnion` aliases remain evaluated aliases for
runtime introspection and Pydantic integration. `Block` and `Map` retain their
legacy class declarations to preserve weak references on early Python 3.12
patch releases; their generic methods use modern type parameters.

Option and Result now use explicit frozen case classes. Their public types are
unions: `Option[T]` consists of `Some[T]` and `Nothing`; `Result[T, E]` consists
of `Ok[T]` and `Error[E]`. Each case has only its own payload. Both static checking
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Expression

Expression is a practical, typed functional-programming library for Python 3.11+.
Expression is a practical, typed functional-programming library for Python 3.12+.
It adds small, composable tools for common Python problems:

- transform data in readable pipelines;
Expand Down
2 changes: 1 addition & 1 deletion expression/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Expression library.

Expression aims to be a solid, type-safe, pragmatic, and high
performance library for practical functional programming in Python 3.11+.
performance library for practical functional programming in Python 3.12+.
By pragmatic we mean that the goal of the library is to use simple
abstractions to enable you to do practical and productive functional
programming in Python.
Expand Down
Loading
Loading