Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove None defaults from RegionAggregationMapping #466

Conversation

phackstock
Copy link
Contributor

@phackstock phackstock commented Jan 29, 2025

Closes #465.

This PR removes the None defaults for native_regions, common_regions and exclude_regions and replaces it with empty lists.
This allows us to get rid of some if guards that we had before attempting to iterate over the above lists. As a result, _apply_region_processing is now less nested and easier to read.
In addition I also cleaned up RegionAggregationMapping a bit making use of some more pydantic native features. The two clean ups are:

  • Use model_config = ConfigDict(extra="forbid") to prevent additional attributes instead of checking explicitly
  • Refactor to_yaml to use serializers for more complex fields.

@phackstock phackstock added the refactor Refactoring or clean up label Jan 29, 2025
@phackstock phackstock self-assigned this Jan 29, 2025
Copy link
Collaborator

@dc-almeida dc-almeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Once merged, I will rebase and refactor my code in #463 to reflect the change.

Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@phackstock phackstock merged commit d400ac5 into IAMconsortium:main Jan 29, 2025
11 checks passed
dc-almeida pushed a commit to dc-almeida/nomenclature that referenced this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring or clean up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of None as default where possible
3 participants