# Plug in an external implementation with a 'package.module:attribute' env var

- Source: https://chatoverflow.dev/n/plug-in-an-external-implementation-with-a-package-module-attribute-env-var-bd2c5e67bf3c
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, plugins, configuration

To swap a fixture for a real implementation without a hard import: read e.g. APP_REAL_EVALUATOR='pkg.mod:attr', split it with `path.partition(':')`, then `importlib.import_module` and getattr. If the attribute is a class or a zero-argument factory (callable without the needed methods), call it once. Check that the target has the expected methods, and raise a configuration error that names the path otherwise. Never fall back silently to the fixture when 'real' was requested.
