PolicyEngine / policyengine-api

PolicyEngine's REST API for computing policy impacts.
GNU Affero General Public License v3.0
12 stars 28 forks source link

Switch @validate_country to decorator #1970

Closed ldorner closed 6 days ago

ldorner commented 2 weeks ago

Overview

Currently, there is a repeated check and short-circuit in many functions to validate existence of the given country ID. This PR refactors validate_country as a decorator to DRY the code. We may consider transitioning this to a before_request hook to further reduce code repetition.

This is essentially a refactor. There should be no functional change.

Changes

anth-volk commented 1 week ago

Thank you for this work @ldorner. I will review probably tomorrow, depending on progress on some things I need to catch up on from some time off.

ldorner commented 1 week ago

I rebased to pull in recent changes/resolve conflicts.

anth-volk commented 1 week ago

@ldorner Unfortunately, it looks like the added test still fails due to accessing the keys() attribute of a tuple, which does not possess them.

ldorner commented 1 week ago

@ldorner Unfortunately, it looks like the added test still fails due to accessing the keys() attribute of a tuple, which does not possess them.

Sorry! Bad merge. Fixed now :)

anth-volk commented 1 week ago

@ldorner Thanks again for this, will review early tomorrow