Skip to content

Export CountryTaxBenefitSystem so the Core CLI can load the NZ model - #36

Draft
MaxGhenis wants to merge 1 commit into
mainfrom
nzhub/issue-15
Draft

MaxGhenis wants to merge 1 commit into
mainfrom
nzhub/issue-15

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Agent-written for Max, by Claude Code for Max Ghenis.

Fixes #15.

What changes

policyengine_nz/system.py defines CountryTaxBenefitSystem as an alias of NewZealandTaxBenefitSystem, but the package never exported it. policyengine-core's CLI looks for that attribute on the package: build_tax_benefit_system raises ImportError without it, and detect_country_package skips the package (policyengine_core/scripts/__init__.py:53–61 and line 81, in Core 3.20.0 and 3.38.0). This PR imports the alias in policyengine_nz/__init__.py, lists it in __all__, and adds policyengine_nz/tests/test_package_exports.py, which checks the attribute, the __all__ entry and that build_tax_benefit_system("policyengine_nz", None, None) returns a NewZealandTaxBenefitSystem. No parameter or variable changes, so no computed value moves.

Tests

  • The three new tests pass on Core 3.20.0 (main's pin) and on Core 3.38.0 (Require policyengine-core 3.38.0 #35's pin), and all three fail with main's __init__.py.
  • policyengine-core test policyengine_nz/tests/policy -c policyengine_nz, run in-process through Core's own parser and handler, raised ImportError with no items collected on both Cores before the change. After it, the run collected and passed 361 items, and 223 with PYTEST_ADDOPTS=--noconftest, on both Cores. The repo's conftest.py registers a second plugin, so the default run collects each of the 138 YAML cases twice.
  • The full suite on Core 3.20.0 gives 1,796 passed and 1 skipped. On Core 3.38.0, 24 tests fail with or without this change; Require policyengine-core 3.38.0 #35 adapts them to that version.
  • ruff format --check . with ruff 0.15.5 passes.

Follow-ups

  • A CI step could run the Core CLI with PYTEST_ADDOPTS=--noconftest, so each YAML case runs once on that path.
  • The household API and the API v2 simulation executor also read package.Simulation, which the package does not export.

axiom: no RuleSpec change (package export and test)

🤖 Generated with Claude Code

policyengine-core's CLI loads a country through
`package.CountryTaxBenefitSystem`, which policyengine_nz defined in
system.py but never exported. Export it, list it in __all__, and test
that Core's build_tax_benefit_system loads the NZ system.

Fixes #15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Missing package-level CountryTaxBenefitSystem breaks the policyengine-core CLI

1 participant