Skip to content

Make BaseBootstrapper generic over its config - #376

Merged
lesnik512 merged 1 commit into
mainfrom
generic-bootstrapper-config
Oct 29, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
generic-bootstrapper-config

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Closes #317.

BaseBootstrapper is now generic over its config as well as its application: BaseBootstrapper[ApplicationT, ConfigT], with bootstrap_config: ConfigT and __init__(self, bootstrap_config: ConfigT). It reuses ConfigT from lite_bootstrap/instruments/base.py, the TypeVar bound to BaseConfig that the instruments got in #285.

  • Each of the five bootstrappers passes its config type, for example BaseBootstrapper["fastapi.FastAPI", FastAPIConfig]. Their bootstrap_config re-declarations are deleted, and with them the five ty: ignore[invalid-mutable-override] comments. None are left in lite_bootstrap/bootstrappers/.
  • The one test that subscribes the base class, in test_logging_record_filters.py, now writes BaseBootstrapper[typing.Any, typing.Any].

I didn't use a TypeVar default to keep one-argument subscriptions working. It would need typing-extensions until 3.13 is the floor, and #272 drops typing-extensions once 3.11 goes.

Tests

Nothing changes at runtime, so there was no failing test to write first. ty check is the gate, and it passes without the ignores. The full suite passes, 591 tests at 100% coverage (just test-ci). just lint, just adr-check and just docs-build pass too. No floor changes.

No docs page covers custom bootstrappers, so no docs changed.

Breaking changes

If you subclass BaseBootstrapper with one type argument, the import now fails with TypeError: Too few arguments for <class '...BaseBootstrapper'>; actual 1, expected at least 2. Add your config class as the second argument, for example BaseBootstrapper[MyApp, MyConfig].

@lesnik512 lesnik512 added this to the 2.0.0 milestone Oct 29, 2026
@lesnik512
lesnik512 merged commit 6f07863 into main Oct 29, 2026
37 checks passed
@lesnik512
lesnik512 deleted the generic-bootstrapper-config branch October 29, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make BaseBootstrapper generic over its config

1 participant