Skip to content

Commit 81f84a4

Browse files
vahid-ahmadiclaude
andcommitted
Add deprecation alias for legacy labor_supply_responses paths
Mirror the two consumed paths (`income_elasticity` and `substitution_elasticity`) under the renamed `labour_supply_responses` tree back to `gov.simulation.labor_supply_responses.*`, so the legacy policyengine-app PolicyRightSidebar (which hard-codes the old paths) keeps working between this PR landing and the matching app PR rebuilding against the new path. Removes the merge-window breakage that would otherwise hit the LSR sliders. Remove this alias in a follow-up release once consumers (the app PR PolicyEngine/policyengine-app#2829) have migrated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3115638 commit 81f84a4

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

changelog.d/853.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Rename `labor` to `labour` in LSR parameter and variable paths, labels, and descriptions to use British English spelling
1+
- Rename `labor` to `labour` in LSR parameter and variable paths, labels, and descriptions to use British English spelling. The two consumed paths (`gov.simulation.labor_supply_responses.income_elasticity` and `.substitution_elasticity`) remain available as deprecation aliases for one release so downstream consumers — particularly the legacy `policyengine-app` PolicyRightSidebar — keep working until they migrate.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Deprecation aliases mirroring the renamed `labour_supply_responses` parameters
2+
under the legacy `labor_supply_responses` path.
3+
4+
`policyengine-app` (legacy) hard-codes
5+
`gov.simulation.labor_supply_responses.{income_elasticity,substitution_elasticity}`
6+
in PolicyRightSidebar.jsx. Without this alias the LSR sliders break the
7+
moment a deployed app rebuilds against this version of policyengine-uk.
8+
The companion app PR (PolicyEngine/policyengine-app#2829) migrates to the
9+
new path; remove this alias once that ships.
10+
"""
11+
12+
from policyengine_core.parameters import Parameter, ParameterNode
13+
14+
15+
_ALIASED_PARAMETERS = ("income_elasticity", "substitution_elasticity")
16+
17+
18+
def add_lsr_deprecation_aliases(parameters: ParameterNode) -> ParameterNode:
19+
simulation = parameters.gov.simulation
20+
canonical = simulation.labour_supply_responses
21+
22+
legacy_node = ParameterNode(
23+
name="gov.simulation.labor_supply_responses",
24+
data={},
25+
)
26+
27+
for child_name in _ALIASED_PARAMETERS:
28+
canonical_child: Parameter = getattr(canonical, child_name)
29+
legacy_child = canonical_child.clone()
30+
legacy_child.name = f"gov.simulation.labor_supply_responses.{child_name}"
31+
legacy_node.add_child(child_name, legacy_child)
32+
33+
simulation.add_child("labor_supply_responses", legacy_node)
34+
return parameters

policyengine_uk/tax_benefit_system.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
from policyengine_uk.parameters.gov.economic_assumptions.lag_cpi import (
3131
add_lagged_cpi,
3232
)
33+
from policyengine_uk.parameters.gov.simulation.labour_supply_responses.aliases import (
34+
add_lsr_deprecation_aliases,
35+
)
3336
from policyengine_uk.utils.parameters import (
3437
backdate_parameters,
3538
convert_to_fiscal_year_parameters,
@@ -93,6 +96,7 @@ def process_parameters(self) -> None:
9396
self.parameters = add_lagged_cpi(self.parameters)
9497
self.parameters = add_triple_lock(self.parameters)
9598
self.parameters = create_economic_assumption_indices(self.parameters)
99+
self.parameters = add_lsr_deprecation_aliases(self.parameters)
96100

97101
# Create baseline parameters for reform comparisons
98102
self.parameters.add_child("baseline", self.parameters.clone())

0 commit comments

Comments
 (0)