Repository navigation
feat: warn on deprecated aliases ahead of their removal in 2.0 - #350
Merged
Merged
Conversation
This was referenced Oct 28, 2026
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.
Part of #314: the 1.x half. The 2.0 half, which deletes the names, stays open on the issue.
Every old name still resolves to the same object, but accessing it now emits a
DeprecationWarningthat names the replacement and says 2.0 removes it:OpentelemetryConfigopentelemetry_instrumentOpenTelemetryConfigFreeBootstrapperConfigfree_bootstrapperandlite_bootstrapFreeConfigIGNORED_STRUCTLOG_ATTRIBUTESsentry_instrumentlogging_factory.STRUCTLOG_META_KEYSAddressProtocol,RequestProtocol,ScopeTypelogging_factoryandlogging_instrumentnot_ready_message,check_dependencieson an instrument subclassnot_configured_reason,dependencies_installedHow it works:
helpers.warn.deprecated_module_getattrbuilds each module's__getattr__. It goes throughwarn_at_caller, so the warning points at the user's import line rather than at lite-bootstrap.typing.TYPE_CHECKINGdefinition. Without it, a type checker would see only the module__getattr__and lose the alias's type, which would be a typing regression in a minor release. I checked that ty still resolves every old name.FreeBootstrapperConfigis gone fromlite_bootstrap.__all__, and the protocols fromlogging_instrument.__all__, sofrom ... import *stays silent. A test covers that.logging_factorythe protocols now live under private names, so they warn there as well and not only through thelogging_instrumentre-export.BaseInstrument.__init_subclass__warns only when it actually forwards a legacy name. With@dataclass(slots=True)the class gets created twice. By the second time the current name is already in the class dict, so the warning fires once.tests/conftest.py:emulate_package_missing_with_module_reloadwiped and restored only non-dunder globals. After a reload it put back the originalOpenTelemetryConfigbut kept the reloaded module's__getattr__, which still held the reloaded class, so the alias stopped being identical to its target. The helper now treats__getattr__as module state.Not in this PR: the AGENTS.md rule "a public rename ships a silent alias" is now out of date, and its worked example (
OpentelemetryConfig) no longer matches. #323 owns that text.Verified: 422 tests pass at 100% coverage,
just lintis clean, and a script outside the package gets each warning on its own import line. No new warnings appear in the suite; the remaining 16 come from Litestar and FastAPI.