fix(web): restore legacy environment exports #2954
Merged
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.
Greptile Overview
Updated On: 2025-11-03 08:54:39 UTC
Greptile Summary
This PR restores backward compatibility for legacy environment exports from
tidy3d.web.core.environment. Users who previously accessed environment instances likedev,uat,prod,pre, andnexusdirectly from this module will now have those exports available again, with appropriate deprecation warnings pointing them to the new config system.Key changes:
__getattr__and__dir__totidy3d.web.core.environmentto dynamically provide legacy environment instancesDeprecationWarningwith clear migration path totidy3d.config.Env.{name}ortidy3d.config.config.switch_profile(...)web.core.environmentsubmodule explicitly available viatidy3d.web.core.__init__.pyConfidence Score: 5/5
__getattr__patterns, includes proper deprecation warnings, has comprehensive test coverage, and doesn't modify any core logic. All changes are additive and well-documented with clear deprecation timelines.Important Files Changed
File Analysis
__getattr__and__dir__to dynamically export legacy environment instances (dev,uat, etc.) with deprecation warningsenvironmentsubmodule import to expose legacy environment exportsSequence Diagram
sequenceDiagram participant User participant web.core.environment participant __getattr__ participant tidy3d.config.Env participant LegacyEnvironment participant warnings User->>web.core.environment: import tidy3d.web.core.environment Note over web.core.environment: Module loads with Env, Environment, EnvironmentConfig User->>web.core.environment: access environment.dev web.core.environment->>__getattr__: __getattr__("dev") __getattr__->>__getattr__: check if "dev" in _LEGACY_ENV_NAMES __getattr__->>warnings: warn deprecation message __getattr__->>tidy3d.config.Env: getattr(Env, "dev") tidy3d.config.Env->>LegacyEnvironment: __getattr__("dev") LegacyEnvironment-->>tidy3d.config.Env: return LegacyEnvironmentConfig("dev") tidy3d.config.Env-->>__getattr__: return dev config __getattr__-->>User: return dev environment config User->>web.core.environment: access environment.uat web.core.environment->>__getattr__: __getattr__("uat") __getattr__->>warnings: warn deprecation message __getattr__->>tidy3d.config.Env: getattr(Env, "uat") tidy3d.config.Env->>LegacyEnvironment: __getattr__("uat") LegacyEnvironment-->>User: return uat environment config