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

Validation using dataclasses #52

Merged
merged 59 commits into from Jan 12, 2024
Merged

Validation using dataclasses #52

merged 59 commits into from Jan 12, 2024

Conversation

oz123
Copy link
Contributor

@oz123 oz123 commented Dec 10, 2023

This PR replaces the validation with built-in dataclasses validation.
The amount of code is reduced significantly, while mostly preserving the API.

The biggest change for the API is that earlier, you could do:

>>>foo = Foo({"a":1, "b":2})
>>>foo.a 
1

Now, you must use unpacking:

>>>foo = Foo(**{"a":1, "b":2})
>>>foo.a
1

Also, I grouped all the models in just one file, as I don't see the point in breaking a file which is ~350 lines long to multiple lines.

All the previous tests are passing, and some new tests are added.
Docs are updated too.

Using this version of Plette is going to break things for upstream users (e.g. Pipenv). However, I believe that the only change that these upstream users will need to implement is the unpacking. Users who just use the high level APIs as in
plette.pipfiles.Pipfile.load and plette.pipfiles.Pipfile.dump won't see a change.

Signed-off-by: Oz Tiram <oz.tiram@gmail.com>
Validate Packages properly in the default section
These tests are now found in tests/test_models_sources.py
These are now found tests/test_models_meta.py.
Also fixes for the class Meta as required for the tests
to pass.
Fix the Hash class so the tests pass again.
Also fix the class and tests.
These tests are now in tests/test_models_sourcecollection.py
@oz123 oz123 requested a review from matteius December 10, 2023 14:00
Copy link
Contributor

@matteius matteius left a comment

Choose a reason for hiding this comment

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

  • Awesome work Oz!!!

@oz123 oz123 merged commit 4455574 into master Jan 12, 2024
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.

None yet

2 participants