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

refactor: ♻️ user Properties classes in user facing functions #976

Merged

Conversation

signekb
Copy link
Member

@signekb signekb commented Jan 20, 2025

Description

This PR changes the input type (and output type, when it's relevant) to a Properties class in the user facing functions.

This means that the functions take a Properties class as input, but transforms it to a dict before handling it to the checks. Before returning, the properties object is transformed back to a Properties class using a new method from_dict based on the work by @martonvago. For this method, we needed a new dependency (dacite).

Closes #970

This PR needs an in-depth review.

Checklist

  • Added or updated tests
  • Updated documentation
  • Ran just run-all

@signekb signekb changed the title feat: ✨ add from_dict method to Properties refactor: ♻️ user Properties classes in user facing functions Jan 20, 2025
@signekb signekb marked this pull request as ready for review January 20, 2025 09:29
@signekb signekb requested a review from a team as a code owner January 20, 2025 09:29
lwjohnst86
lwjohnst86 previously approved these changes Jan 20, 2025
Copy link
Member

@lwjohnst86 lwjohnst86 left a comment

Choose a reason for hiding this comment

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

Nice! Looks good ☺️

tests/core/test_edit_package_properties.py Outdated Show resolved Hide resolved
tests/core/test_properties.py Show resolved Hide resolved
Copy link
Contributor

@martonvago martonvago left a comment

Choose a reason for hiding this comment

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

Yay! 🚀

I will use this as a base for #974

tests/core/test_edit_package_properties.py Outdated Show resolved Hide resolved
tests/core/test_properties.py Show resolved Hide resolved
Actually testing the same as `test_throws_error_if_new_properties_are_empty()`, since a custom field is removed anyway.
martonvago
martonvago previously approved these changes Jan 21, 2025
@lwjohnst86 lwjohnst86 merged commit 8c6063f into main Jan 22, 2025
3 checks passed
@lwjohnst86 lwjohnst86 deleted the refactor/use-properties-classes-in-userfacing-functions branch January 22, 2025 08:45
lwjohnst86 added a commit that referenced this pull request Jan 27, 2025
## Description

This PR refactors `edit_package_properties` to use the check functions.

Once #976 is
merged in, I will update this PR with those changes. <-- Done!
:heavy_check_mark:

<!-- Select quick/in-depth as necessary -->
This PR needs an in-depth review.

## Checklist

- [x] Added or updated tests
- [x] Updated documentation
- [x] Ran `just run-all`

---------

Co-authored-by: Luke W. Johnston <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Signe Kirk Brødbæk <[email protected]>
Co-authored-by: Luke W. Johnston <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Use *Properties classes as argument types in Sprout
3 participants