graphene-stubs
raw JSON → 0.16 verified Fri May 01 auth: no python
graphene-stubs provides type stubs and a mypy plugin for Graphene (the GraphQL framework for Python). Version 0.16 adds comprehensive stubs for graphene objects and enhances mypy integration. Releases are infrequent.
pip install graphene-stubs Common errors
error error: Library 'graphene' has no stubs or type hints ↓
cause graphene-stubs not installed or mypy plugin not configured.
fix
Install graphene-stubs and add 'plugins = graphene_stubs.mypy_plugin' to mypy.ini.
error mypy: Cannot find implementation or library stub for module 'graphene' ↓
cause graphene itself has no type stubs; graphene-stubs is required.
fix
Install graphene-stubs. If already installed, check mypy configuration for plugin path.
error ModuleNotFoundError: No module named 'graphene_stubs' ↓
cause graphene-stubs package not installed.
fix
Run: pip install graphene-stubs
Warnings
gotcha The mypy plugin must be enabled explicitly via mypy config; it is not activated by installing the package. ↓
fix Add 'plugins = graphene_stubs.mypy_plugin' to your mypy configuration file.
gotcha Type stubs are not automatically installed for graphene itself. Ensure graphene is installed as a dependency. ↓
fix Install graphene alongside graphene-stubs: pip install graphene graphene-stubs
deprecated The package may not see frequent updates; consider using graphene built-in types or other stubs if support lags behind graphene releases. ↓
fix Monitor the repository for updates; if stubs become outdated, temporarily use # type: ignore or custom stubs.
Imports
- mypy plugin wrong
plugins = graphene_stubs.plugincorrectplugins = graphene_stubs.mypy_plugin - Type stubs wrong
import graphene_stubscorrectfrom graphene_stubs import ...
Quickstart
# In mypy configuration file (e.g., mypy.ini):
[mypy]
plugins = graphene_stubs.mypy_plugin
# Example graphene code the stubs will type-check:
import graphene
class Query(graphene.ObjectType):
hello = graphene.String()
def resolve_hello(self, info):
return "world"
schema = graphene.Schema(query=Query)