mypy-zope
Plugin for mypy to support zope interfaces
What it is and what it does
mypy-zope is a mypy plugin that bridges the gap between zope.interface's runtime interface system and static type checking. It teaches mypy to understand zope interfaces as types, so you can write polymorphic code using zope's interface pattern and have mypy verify type safety across interface boundaries. The plugin infers types from zope.schema field declarations (Int, Text, etc.), handles interface implementation via @implementer decorators or classImplements calls, supports the adaptation pattern where interfaces are called to look up adapters, and enables type narrowing with providedBy() and implementedBy() checks.
The package ships with type stubs for zope.interface and zope.schema, which are automatically enabled when the plugin is active. It supports overloaded methods in interfaces, field properties, and conditional type inference. The plugin is marked production-grade and used in large projects, though the maintainers note that subtle bugs may still exist. Some advanced zope.interface features—like module-level interface declarations, List and Dict field type inference, and full interface compatibility checking—are not yet supported.
Use it for:
- Type-check a zope-based application where interfaces define contracts and implementations are polymorphic.
- Verify that schema field assignments match their declared types (e.g., Int fields reject strings).
- Enable IDE autocomplete and type hints for code using zope.interface.implementer decorators.
- Narrow types in conditional branches using zope's providedBy() and implementedBy() runtime checks.
- Catch adapter lookup errors by treating interface calls as typed function invocations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A mypy plugin that treats zope.interface declarations as types, enabling type checking for zope-based code with interface polymorphism, schema field inference, and adaptation patterns.
Yes, if you use zope.interface in a mypy-checked project. The plugin is active, production-grade, and has no security vulnerabilities. Install friction is low. The main caveat: some advanced zope.interface features remain unsupported, and stub coverage is incomplete—verify that your specific patterns are listed in the documented supported features before committing.
Install
mypy-zope on PyPI
pip
pip install mypy-zopeuv
uv add mypy-zopepoetry
poetry add mypy-zopeInstalling mypy-zope
Before you install
Low friction: pure Python wheel with only three runtime dependencies (mypy, zope.interface, zope.schema). Active maintenance—last commit 2026-07-15, release within 30 days—and marked production-grade despite acknowledging potential subtle bugs.
License in practice
Permissive license (MIT) with no notable restrictions on use or redistribution.
Quickstart
pip install mypy-zope
# Add to mypy.ini:
# [mypy]
# plugins=mypy_zope:plugin
# Then use in code:
import zope.interface
class IAnimal(zope.interface.Interface):
def say() -> None:
pass
@zope.interface.implementer(IAnimal)
class Cow:
def say(self) -> None:
print("Moo")
animal: IAnimal = Cow()
animal.say()
Verify before relying
- Whether stub files for zope.interface and zope.schema are complete enough for real-world projects beyond the documented limitations.
- Performance impact of the plugin on large codebases with many interfaces.
- Whether the 'subtle bugs' acknowledged in production use affect common patterns.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — mypy, zope.interface, zope.schema |
| Maintenance | actively maintained — 30 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 132,498/month — #11,548 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mypy_zope-1.0.16-py3-none-any.whl
Keywords: mypy, zope, interfaces, typing
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
zope.interfaceProvides a Python implementation of object…
unclear · top 1,000 on PyPI
zope.schemaDefines structured data schemas for Python…
unclear · top 5,000 on PyPI
twilio-stubsProvides mypy type stubs for the Twilio Python…
permissive · top 15,000 on PyPI
zope.componentImplements the core Zope Component Architecture…
unclear · top 5,000 on PyPI
sqlalchemy-stubsProvides type stubs and a mypy plugin to enable…
permissive · top 5,000 on PyPI
classesImplements typeclasses for Python, enabling…
permissive · top 15,000 on PyPI
mypy-boto3Provides type stubs and annotations for boto3…
permissive · top 5,000 on PyPI
flake8-annotationsA Flake8 plugin that enforces PEP 3107-style…
permissive · top 15,000 on PyPI
z3c.ptz3c.pt is a fast ZPT (Zope Page Template)…
unclear · top 15,000 on PyPI
types-decoratorProvides type stubs for the `decorator`…
permissive · top 5,000 on PyPI