skillfed

mypy-zope

Plugin for mypy to support zope interfaces

mypy-zope v1.0.16 132.5K downloads/30d#11,548 on PyPI40
Permissive license Active released

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-zope

uv

uv add mypy-zope

poetry

poetry add mypy-zope

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development

Tags

mypy plugin zope interfacezope interface type checkingmypy zope supportinterface type annotationszope schema field typesmypy plugin frameworkzope implementer decorator typing
mypy-pluginzope-ecosystemtype-checking

More Software Development packages