{"id":8339,"library":"mypy-zope","title":"Mypy Zope Plugin","description":"mypy-zope is a plugin for Mypy that provides type checking support for projects utilizing Zope interfaces (`zope.interface`). It allows Mypy to correctly understand and validate code that implements or interacts with Zope interfaces. The current version is 1.0.14, with releases occurring periodically to support newer Mypy versions and address issues.","status":"active","version":"1.0.14","language":"en","source_language":"en","source_url":"https://github.com/Shoobx/mypy-zope","tags":["mypy","zope","type checking","plugin","zope.interface"],"install":[{"cmd":"pip install mypy-zope","lang":"bash","label":"Install Mypy Zope Plugin"}],"dependencies":[{"reason":"This library is a plugin for Mypy and requires Mypy to be installed and available in the environment to function.","package":"mypy","optional":false}],"imports":[{"note":"mypy-zope is a Mypy plugin, not a standard Python library to be imported directly into Python code. It is enabled via Mypy's configuration file (e.g., mypy.ini) under the [mypy] section.","wrong":"import mypy_zope.plugin","symbol":"Mypy Plugin Configuration","correct":"plugins = mypy_zope.plugin"}],"quickstart":{"code":"# 1. Create a mypy.ini file in your project root:\n# [mypy]\n# plugins = mypy_zope.plugin\n# python_version = 3.9 # or your project's Python version\n\n# 2. Create a Python file, e.g., my_app.py:\n# from zope.interface import Interface, implementer\n\n# class IGreeter(Interface):\n#     def greet(name: str) -> str:\n#         \"\"\"Greets the given name.\"\"\"\n\n# @implementer(IGreeter)\n# class HelloGreeter:\n#     def greet(self, name: str) -> str:\n#         return f\"Hello, {name}!\"\n\n# def use_greeter(greeter: IGreeter) -> None:\n#     print(greeter.greet(\"World\"))\n\n# use_greeter(HelloGreeter())\n\n# 3. Run mypy from your terminal:\n# mypy my_app.py\n\n# Expected output for the above example (no errors if configured correctly):\n# Success: no issues found in 1 source file","lang":"python","description":"To get started, install `mypy-zope` and ensure `mypy` is also installed. Then, create a `mypy.ini` configuration file in your project root and add `plugins = mypy_zope.plugin` under the `[mypy]` section. Write some Python code that uses `zope.interface`, and then run `mypy` on your files. The plugin will enable Mypy to understand interface implementations and usage."},"warnings":[{"fix":"Ensure you have `mypy>=1.0.0` installed. You can upgrade Mypy using `pip install --upgrade mypy`.","message":"The `mypy-zope` plugin requires Mypy version 1.0.0 or higher. Using it with older Mypy versions may lead to unexpected behavior or errors.","severity":"gotcha","affected_versions":"<1.0.0 of mypy"},{"fix":"Add `plugins = mypy_zope.plugin` under the `[mypy]` section of your Mypy configuration file.","message":"The plugin must be explicitly enabled in your Mypy configuration file (e.g., `mypy.ini`, `pyproject.toml`). It is not automatically discovered or activated upon installation.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `mypy-zope` is installed with `pip install mypy-zope`. Verify the `plugins` line in your `mypy.ini` correctly states `plugins = mypy_zope.plugin`.","cause":"The `mypy-zope` package is either not installed in the environment Mypy is running in, or the specified plugin path in `mypy.ini` is incorrect.","error":"Mypy could not find plugin 'mypy_zope.plugin'"},{"fix":"Confirm that `plugins = mypy_zope.plugin` is correctly configured in your `mypy.ini` file and that Mypy is using that configuration (e.g., by running `mypy --config-file mypy.ini your_file.py`).","cause":"Mypy is reporting type errors related to `zope.interface` even though you expect the plugin to handle them, indicating the plugin is likely not active.","error":"Error: Incompatible types in assignment (expression has type \"Foo\", variable has type \"IBar\")"}]}