Repository navigation
Description
Problem
Python plugins treat __all__ in __init__.py as their public surface, but most ship internal code in modules without a leading underscore. Every plugin ships py.typed, so by the typing spec's library-interface rules those names are public. Pyright and Pylance accept the import without warning, and IDE auto-import offers it.
# Not in genkit_google_genai.__all__, but public by the spec and offered by auto-import
from genkit_google_genai.models.gemini import KnownGemini, GeminiModel, SUPPORTED_MODELSThis came up on genkit-ai/genkit#6506. Removing the model-id enums from genkit_google_genai.__all__ left them importable from genkit_google_genai.models.gemini, so dropping a root export didn't make anything internal. genkit-ai/genkit#6506 deleted the enums outright, but the Known* Literals have to stay because the gemini_model(name: KnownGemini | str) signatures need them. They're still reachable through models.*.
Mechanism
Core genkit already follows the convention: internals live in genkit._core and genkit._ai, and genkit-ai/genkit#6508 adds a ruff rule that blocks other packages from importing them. genkit-a2ui, genkit-middleware, and genkit-otel already keep every internal module underscored. The rest don't:
- genkit-google-genai:
constants.py,evaluators/,google.py,models/ - genkit-openai:
models/,openai_plugin.py,typing.py - genkit-anthropic:
config.py,model_info.py,models.py,plugin.py,utils.py - genkit-amazon-bedrock:
config.py,converters.py,embedders.py,image.py,model_info.py,models.py,plugin.py,rerank.py,stream.py,transport.py - genkit-ollama:
constants.py,embedders.py,models.py,plugin_api.py - genkit-vertexai:
constants.py,model_garden/ - genkit-evaluators:
plugin.py - genkit-django / fastapi / flask:
handler.py - genkit-google-cloud:
exp/,session_store/,telemetry/. These may be intentional public subpackages; decide per subpackage.
Proposal
- Underscore-prefix internal modules in each plugin (e.g.
genkit_google_genai/models/→_models/), so__all__is the whole public surface. - Before renaming, re-export from the package root anything users legitimately reach through a submodule today. Grep samples, docsite, and skills for
from genkit_<plugin>.<module> import. - Extend the chore(py): plugins and samples import genkit only through public modules genkit#6508 ruff rule so samples and other packages can't import
genkit_<plugin>._*. - Land one PR per plugin. Each is breaking only for direct submodule imports.
Open questions
- Is
genkit-google-cloud'sexp/,session_store/, andtelemetry/meant to be public? If so, those stay and get their own__all__. - Should
genkit_ollama.plugin_apibe public? Its name suggests it was meant to be.
Activity
MichaelDoyle commentedon Nov 18, 2026
It looks like plugin internals across
py/packages/genkit-*/src/*/have now been made private with underscore-prefixed modules (via PRs genkit-ai/genkit#6506, genkit-ai/genkit#6586, genkit-ai/genkit#6710, etc.). Is this ready to close?