sumtypes
Algebraic types for Python (notably providing Sum Types, aka Tagged Unions)
Decision gist · record as of 2026-08-14
No. The package is abandoned (last commit 2021-11-30, no activity for 1718 days), and maintenance compatibility with current Python versions is unverified. For new projects, consider whether native language features or actively maintained alternatives better serve your needs.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with a single runtime dependency on attrs.
- However, the package is abandoned as of 2021-11-30 with no commits since then, so maintenance and compatibility with modern Python versions are concerns.
License · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing commercial and private use with minimal restrictions.
last release 2021-11-30 (1718 days) · last repo commit 2021-11-30 · 44 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 187,040 downloads/mo, #9,972 on PyPI
Alternatives
Verify before relying
pip install sumtypes
from sumtypes import sumtype, constructor, match
@sumtype
class Color(object):
Red = constructor()
Green = constructor()
Blue = constructor('intensity')
red = Color.Red()
blue = Color.Blue(42)
@match(Color)
class describe(object):
def Red(): return 'red'
def Green(): return 'green'
def Blue(intensity): return 'blue'- Whether the package works reliably with modern Python versions given its abandoned status since 2021-11-30
- Whether attrs version compatibility has drifted and could cause runtime issues
- Whether pattern matching remains the recommended approach or if newer Python versions offer better alternatives
What it is and what it does
sumtypes brings algebraic data types to Python by implementing sum types (also called tagged unions), which let you define a type with multiple named constructor variants. Each variant can carry its own set of attributes. The package builds on attrs to provide attribute validation, defaults, and other features. You decorate a class with @sumtype, define constructors as class attributes, and then instantiate them by calling those constructors; the resulting objects track which constructor was used and can be pattern-matched over all cases.
The main use case is writing code that handles multiple distinct cases of a logical type in a type-safe, exhaustive way. Instead of using strings or integers to tag variants, sum types make the structure explicit and let the match decorator verify that all cases are handled. This is particularly useful in functional programming styles or when modeling domain logic with multiple states or alternatives.
Use it for
- Model domain types with multiple variants such as Result as Success or Failure, or AST nodes with different expression types
- Write exhaustive pattern-matching functions over all constructor cases without risk of missing a case
- Define state machines or state enums where each state can carry different associated data
- Implement functional-style error handling with explicit Success and Error constructors
- Build parsers or interpreters that need to represent different kinds of syntax tree nodes
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
No.
The package is abandoned (last commit 2021-11-30, no activity for 1718 days), and maintenance compatibility with current Python versions is unverified. For new projects, consider whether native language features or actively maintained alternatives better serve your needs.
Install
sumtypes on PyPI
Before you install
Low install friction with a single runtime dependency on attrs. However, the package is abandoned as of 2021-11-30 with no commits since then, so maintenance and compatibility with modern Python versions are concerns.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions.
Quickstart
pip install sumtypes
from sumtypes import sumtype, constructor, match
@sumtype
class Color(object):
Red = constructor()
Green = constructor()
Blue = constructor('intensity')
red = Color.Red()
blue = Color.Blue(42)
@match(Color)
class describe(object):
def Red(): return 'red'
def Green(): return 'green'
def Blue(intensity): return 'blue'
Verify before relying
- Whether the package works reliably with modern Python versions given its abandoned status since 2021-11-30
- Whether attrs version compatibility has drifted and could cause runtime issues
- Whether pattern matching remains the recommended approach or if newer Python versions offer better alternatives
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageattrs |
| Maintenance | Abandoned 1,718 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 187,040 / month, #9,972 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 3 |
Evidence: sumtypes-0.1a6-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “algebraic data types python”
- sumtypesProvides algebraic data types for Python, specifically sum types…
- ripserRipser computes persistent homology and persistence diagrams for…
- gekkoGEKKO is a Python package for optimization and machine learning that…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also oslash · runtype · numerary · Expression · itypes · amplpy · typing-inspect · pampy · jsons · symengine