$npx skillfedfor your agent

classes

Smart, pythonic, ad-hoc, typed polymorphism for Python

With conditionsPyPI Python ModulesReleased Apr 2022135.2K downloads / moBSD-2-ClausePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — classes-0.4.1-py3-none-any.whl
v0.4.1 · released 2022-04-11 · Python >=3.7,<4.0 · 1 runtime deps: typing_extensions

Yes, with conditions. Install if you need ad-hoc polymorphism without inheritance and are comfortable with dormant maintenance (last release 2022-04-11). The package is stable, has no known vulnerabilities, and low install friction. Not recommended if you require active upstream support or need assurance of mypy plugin compatibility with the latest type-checker versions.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires mypy plugin configuration in setup.cfg or mypy.ini under [mypy] with 'plugins = classes.contrib.mypy.classes_plugin' for full type safety; without it, type violations will be reported.
  • Low friction install with a single runtime dependency (typing_extensions).
  • Maintenance is dormant—last release was 2022-04-11, over 1586 days ago, though the repository remains active with a recent commit on 2024-12-17.

License · maintenance · safety

BSD-2-Clause (permissive) — BSD-2-Clause is permissive and imposes minimal restrictions. You can use, modify, and distribute this package freely in commercial and private projects provided you include the license notice.

last release 2022-04-11 (1586 days) · last repo commit 2024-12-17 · 731 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 135,192 downloads/mo, #11,450 on PyPI

Verify before relying

pip install classes

from classes import typeclass

@typeclass
def to_json(instance) -> str:
    """Convert things to json."""

@to_json.instance(int)
def _to_json_int(instance: int) -> str:
    return str(instance)

result = to_json(value)
  • Whether the mypy plugin remains compatible with recent mypy versions given the package's dormant status since 2022.
  • Real-world performance characteristics when dispatching on complex type hierarchies or with many registered instances.
Same gist for agents: .md · .json

What it is and what it does

Classes provides a typeclass system for Python—a way to bind behavior to types without creating class hierarchies or interfaces. Instead of writing many subclasses (like IntField, BoolField, etc.), you define a typeclass as a function and register implementations for specific types using decorators. This approach reduces boilerplate, improves type safety through mypy integration, and makes it easier to extend behavior for new types without modifying existing code.

The package is designed for declarative, functional-style business logic where different data types need different handling. A common use case is serialization (converting objects to JSON based on their type), but it applies anywhere you'd otherwise use a type-based dispatch pattern. It requires mypy plugin configuration to achieve full type safety; without it, the type checker will report violations.

Use it for

  • Implement serialization/deserialization logic that varies by type (e.g., custom JSON converters for int, bool, datetime).
  • Build validation rules that apply different checks to different data types without inheritance chains.
  • Create extensible handler registries where third-party code can add support for custom types.
  • Write functional-style data transformation pipelines where operations dispatch based on input type.
  • Reduce boilerplate in libraries that need type-specific behavior (like ORMs or REST frameworks).

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, with conditions.

Install if you need ad-hoc polymorphism without inheritance and are comfortable with dormant maintenance (last release 2022-04-11). The package is stable, has no known vulnerabilities, and low install friction. Not recommended if you require active upstream support or need assurance of mypy plugin compatibility with the latest type-checker versions.

Install

classes on PyPI

Before you install

Low friction install with a single runtime dependency (typing_extensions). Maintenance is dormant—last release was 2022-04-11, over 1586 days ago, though the repository remains active with a recent commit on 2024-12-17. Suitable for stable, mature use cases but not for projects requiring active upstream support.

Requires mypy plugin configuration in setup.cfg or mypy.ini under [mypy] with 'plugins = classes.contrib.mypy.classes_plugin' for full type safety; without it, type violations will be reported.

License in practice

BSD-2-Clause is permissive and imposes minimal restrictions. You can use, modify, and distribute this package freely in commercial and private projects provided you include the license notice.

Quickstart

pip install classes

from classes import typeclass

@typeclass
def to_json(instance) -> str:
    """Convert things to json."""

@to_json.instance(int)
def _to_json_int(instance: int) -> str:
    return str(instance)

result = to_json(value)

Verify before relying

  • Whether the mypy plugin remains compatible with recent mypy versions given the package's dormant status since 2022.
  • Real-world performance characteristics when dispatching on complex type hierarchies or with many registered instances.

Package facts

LicenseBSD-2-Clause permissive
Python supportSupports the current Python release >=3.7,<4.0
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
typing_extensions
MaintenanceDormant 1,586 days since the last release
Last repo commit
First released
Downloads135,192 / month, #11,450 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities

Evidence: classes-0.4.1-py3-none-any.whl

Tags

Capabilities
typeclass polymorphism pythonad-hoc type dispatchfunctional programming type safetymypy plugin type classestype-based method dispatchpythonic polymorphism without inheritancetyped function overloading
Topics
functional-programmingtype-dispatchmypy-plugin
PyPI keywords
functional programmingfptype classtypeclasstypeclassesad-hoccompositiontype-safetymypystubs

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 › “typeclass polymorphism python”

  • classesImplements typeclasses for Python, enabling type-based dispatch and…
  • marshmallow-polyfieldExtends Marshmallow with a PolyField class that handles serialization…
  • marshmallow-oneofschemaExtends marshmallow to handle polymorphic serialization and…

Give your agent the search over MCP, or paste the wish link into any chat.

More Python Modules packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
PyYAML Worth it
PyPI · Python Modules · released Sep 2025

PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.

MITcompiled wheel · 3.8+
1.2Bdownloads / mo
pydantic Worth it
PyPI · Python Modules · released May 2026

Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.

MITpure Python · 3.9+
1.1Bdownloads / mo
annotated-types Worth it
PyPI · Python Modules · released Jul 2026

Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.

Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…

MITpure Python · 3.10+
871.3Mdownloads / mo
typing-inspection Worth it
PyPI · Python Modules · released Aug 2026

Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.

MITpure Python · 3.10+
783.0Mdownloads / mo

See also fasttransform · overloading · multipledispatch · visitor · simplegeneric · methoddispatch · plum-dispatch · singledispatch · returns · mypy-zope