Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def get_current_version(pyproject_path: Path) -> str:

def infer_bump(changelog_dir: Path) -> str:
fragments = [
f
for f in changelog_dir.iterdir()
if f.is_file() and f.name != ".gitkeep"
f for f in changelog_dir.iterdir() if f.is_file() and f.name != ".gitkeep"
]
if not fragments:
print("No changelog fragments found", file=sys.stderr)
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ jobs:

- name: Install dependencies
run: |
uv pip install --system black linecheck

- name: Check formatting with Black
run: |
black . -l 79 --check

- name: Run linecheck
uv pip install --system ruff

- name: Check formatting with ruff
run: |
linecheck . --check
ruff format --check .

test:
name: Test
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:

- name: Check formatting
run: |
black . -l 79 --check
linecheck . --check
ruff format --check .

- name: Run tests
run: |
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ documentation:
myst build docs -o docs/_build

format:
black . -l 79
linecheck . --fix
ruff format .

install:
uv pip install --system -e .[dev]
Expand Down
1 change: 1 addition & 0 deletions changelog.d/switch-to-ruff.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch from black to ruff format.
12 changes: 6 additions & 6 deletions policyengine_au/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ def runtest(self):

# Allow small tolerance for floating point comparisons
if isinstance(expected_value, (int, float)):
assert (
abs(calculated - expected_value) < 0.01
), f"{variable_name}: expected {expected_value}, got {calculated}"
assert abs(calculated - expected_value) < 0.01, (
f"{variable_name}: expected {expected_value}, got {calculated}"
)
else:
assert (
calculated == expected_value
), f"{variable_name}: expected {expected_value}, got {calculated}"
assert calculated == expected_value, (
f"{variable_name}: expected {expected_value}, got {calculated}"
)

def reportinfo(self):
"""Report test location."""
Expand Down
11 changes: 4 additions & 7 deletions policyengine_au/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def test_entities_loaded():
entity_keys = {entity.key for entity in system.entities}

for entity_name in expected_entities:
assert (
entity_name in entity_keys
), f"Entity {entity_name} not found in {entity_keys}"
assert entity_name in entity_keys, (
f"Entity {entity_name} not found in {entity_keys}"
)

# Check that person_entity is accessible (main entity)
assert system.person_entity is not None
Expand All @@ -52,10 +52,7 @@ def test_parameters_loaded():
p_2024 = parameters(period)

# Test income tax parameters
assert (
p_2024.gov.ato.income_tax.thresholds.thresholds.tax_free_threshold
== 18_200
)
assert p_2024.gov.ato.income_tax.thresholds.thresholds.tax_free_threshold == 18_200
assert p_2024.gov.ato.income_tax.rates.rates.bracket_2 == 0.19

# Test Medicare levy
Expand Down
4 changes: 1 addition & 3 deletions policyengine_au/variables/gov/ato/medicare/medicare_levy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class medicare_levy(Variable):
entity = Person
definition_period = YEAR
label = "Medicare levy"
documentation = (
"Medicare levy based on taxable income and family circumstances"
)
documentation = "Medicare levy based on taxable income and family circumstances"
reference = "https://www.ato.gov.au/individuals-and-families/medicare-and-private-health-insurance/medicare-levy"
unit = AUD

Expand Down
4 changes: 3 additions & 1 deletion policyengine_au/variables/gov/states/nsw/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class nsw_payroll_tax(Variable):
label = "NSW payroll tax"
definition_period = YEAR
unit = "AUD"
reference = "https://www.legislation.nsw.gov.au/view/html/inforce/current/act-2007-021"
reference = (
"https://www.legislation.nsw.gov.au/view/html/inforce/current/act-2007-021"
)

def formula(household, period, parameters):
# Get NSW payroll tax parameters
Expand Down
4 changes: 1 addition & 3 deletions policyengine_au/variables/gov/states/nt/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class nt_payroll_tax(Variable):
label = "NT payroll tax"
definition_period = YEAR
unit = "AUD"
reference = (
"https://legislation.nt.gov.au/en/Legislation/PAYROLL-TAX-ACT-2009"
)
reference = "https://legislation.nt.gov.au/en/Legislation/PAYROLL-TAX-ACT-2009"

def formula(household, period, parameters):
# Get NT payroll tax parameters
Expand Down
4 changes: 3 additions & 1 deletion policyengine_au/variables/gov/states/qld/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class qld_payroll_tax(Variable):
label = "QLD payroll tax"
definition_period = YEAR
unit = "AUD"
reference = "https://www.legislation.qld.gov.au/view/html/inforce/current/act-1971-062"
reference = (
"https://www.legislation.qld.gov.au/view/html/inforce/current/act-1971-062"
)

def formula(household, period, parameters):
# Get QLD payroll tax parameters
Expand Down
4 changes: 3 additions & 1 deletion policyengine_au/variables/gov/states/sa/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class sa_payroll_tax(Variable):
label = "SA payroll tax"
definition_period = YEAR
unit = "AUD"
reference = "https://www.legislation.sa.gov.au/LZ/C/A/Payroll%20Tax%20Act%202009.aspx"
reference = (
"https://www.legislation.sa.gov.au/LZ/C/A/Payroll%20Tax%20Act%202009.aspx"
)

def formula(household, period, parameters):
# Get SA payroll tax parameters
Expand Down
4 changes: 3 additions & 1 deletion policyengine_au/variables/gov/states/tas/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class tas_payroll_tax(Variable):
label = "TAS payroll tax"
definition_period = YEAR
unit = "AUD"
reference = "https://www.legislation.tas.gov.au/view/html/inforce/current/act-2008-016"
reference = (
"https://www.legislation.tas.gov.au/view/html/inforce/current/act-2008-016"
)

def formula(household, period, parameters):
# Get TAS payroll tax parameters
Expand Down
4 changes: 1 addition & 3 deletions policyengine_au/variables/gov/states/vic/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class vic_payroll_tax(Variable):
label = "VIC payroll tax"
definition_period = YEAR
unit = "AUD"
reference = (
"https://www.legislation.vic.gov.au/in-force/acts/payroll-tax-act-2007"
)
reference = "https://www.legislation.vic.gov.au/in-force/acts/payroll-tax-act-2007"

def formula(household, period, parameters):
# Get VIC payroll tax parameters
Expand Down
3 changes: 1 addition & 2 deletions policyengine_au/variables/gov/states/wa/payroll_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def formula(household, period, parameters):

# Vectorized threshold calculation
reduction = (
clip(wages - lower_limit, 0, upper_limit - lower_limit)
* reduction_rate
clip(wages - lower_limit, 0, upper_limit - lower_limit) * reduction_rate
)
effective_threshold = select(
[wages <= lower_limit, wages <= upper_limit],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ class household_state(Variable):

def formula(household, period, parameters):
# Use the state of the household head (first person)
return household.value_from_first_person(
household.members("state", period)
)
return household.value_from_first_person(household.members("state", period))
4 changes: 1 addition & 3 deletions policyengine_au/variables/input/demographics/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ class state(Variable):
entity = Person
definition_period = YEAR
label = "State or territory of residence"
documentation = (
"The Australian state or territory where the person resides"
)
documentation = "The Australian state or territory where the person resides"
reference = "https://www.abs.gov.au/statistics/standards/australian-statistical-geography-standard-asgs-edition-3"
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ dependencies = [
dev = [
"pytest>=8.3.4",
"pytest-cov>=6.0.0",
"black>=24.8.0",
"linecheck>=0.1.0",
"ruff>=0.9.0",
"jupyter-book>=1.0.4",
"mystmd>=1.3.17",
"wheel>=0.38.4",
Expand All @@ -64,10 +63,6 @@ Repository = "https://github.com/PolicyEngine/policyengine-au"
Documentation = "https://policyengine.org/au/api"
Tracker = "https://github.com/PolicyEngine/policyengine-au/issues"

[tool.black]
line-length = 79
target-version = ["py310", "py311", "py312", "py313"]

[tool.pytest.ini_options]
testpaths = ["policyengine_au/tests"]
python_files = ["*.py"]
Expand Down
Loading