Repository navigation
Make BaseBootstrapper generic over its config - #376
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #317.
BaseBootstrapperis now generic over its config as well as its application:BaseBootstrapper[ApplicationT, ConfigT], withbootstrap_config: ConfigTand__init__(self, bootstrap_config: ConfigT). It reusesConfigTfromlite_bootstrap/instruments/base.py, the TypeVar bound toBaseConfigthat the instruments got in #285.BaseBootstrapper["fastapi.FastAPI", FastAPIConfig]. Theirbootstrap_configre-declarations are deleted, and with them the fivety: ignore[invalid-mutable-override]comments. None are left inlite_bootstrap/bootstrappers/.test_logging_record_filters.py, now writesBaseBootstrapper[typing.Any, typing.Any].I didn't use a TypeVar default to keep one-argument subscriptions working. It would need
typing-extensionsuntil 3.13 is the floor, and #272 dropstyping-extensionsonce 3.11 goes.Tests
Nothing changes at runtime, so there was no failing test to write first.
ty checkis the gate, and it passes without the ignores. The full suite passes, 591 tests at 100% coverage (just test-ci).just lint,just adr-checkandjust docs-buildpass too. No floor changes.No docs page covers custom bootstrappers, so no docs changed.
Breaking changes
If you subclass
BaseBootstrapperwith one type argument, the import now fails withTypeError: Too few arguments for <class '...BaseBootstrapper'>; actual 1, expected at least 2. Add your config class as the second argument, for exampleBaseBootstrapper[MyApp, MyConfig].