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

Support dict_items for list like fields #225

Merged
merged 3 commits into from
Aug 12, 2022

Conversation

ytmimi
Copy link
Contributor

@ytmimi ytmimi commented Aug 8, 2022

Closes #211

This is a follow up to PR #208, which added support for dict_keys and dict_values.

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2022

Codecov Report

Merging #225 (1ef2f6d) into main (fdf42b8) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #225   +/-   ##
=======================================
  Coverage   98.66%   98.66%           
=======================================
  Files          48       48           
  Lines        5031     5031           
  Branches       35       35           
=======================================
  Hits         4964     4964           
  Misses         67       67           
Impacted Files Coverage Δ
src/input/input_python.rs 98.67% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdf42b8...1ef2f6d. Read the comment docs.

@ytmimi
Copy link
Contributor Author

ytmimi commented Aug 9, 2022

I wasn't sure how to write a test to validate the key and value for dict.items(), but if someone could help me with that I'm happy to update the PR with a test.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

Otherwise this is looking good.

tests/validators/test_frozenset.py Outdated Show resolved Hide resolved
Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

otherwise LGTM.

@@ -216,3 +217,58 @@ def test_dict_length_constraints(kwargs: Dict[str, Any], input_value, expected):
v.validate_python(input_value)
else:
assert v.validate_python(input_value) == expected


@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='dict views not implemented in pyo3 for pypy')
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but it'll be confusing if a test for list, tuple, set, frozen set is in the file for dict tests.

Please can you copy this to each of those files and simplify the parameterisation accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries. I thought it would be easier to consolidate them all in a single test, but totally happy to make this change.

Copy link
Member

Choose a reason for hiding this comment

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

I understand, but still think better in this case.

@samuelcolvin
Copy link
Member

Sadly lots of conflicts :-(.

Let me know if you want a hand resolving them.

Closes 211

This is a follow up to PR 208, which added support for `dict_keys` and
`dict_values`.
@ytmimi
Copy link
Contributor Author

ytmimi commented Aug 12, 2022

Resolved the merge conflicts!

@ytmimi
Copy link
Contributor Author

ytmimi commented Aug 12, 2022

wait, realizing that I'm missing one test 😅. one sec

@samuelcolvin
Copy link
Member

This is great, thank you so much.

@samuelcolvin samuelcolvin enabled auto-merge (squash) August 12, 2022 14:36
@samuelcolvin samuelcolvin merged commit 6d431dc into pydantic:main Aug 12, 2022
@ytmimi
Copy link
Contributor Author

ytmimi commented Aug 12, 2022

Happy to help😁 I herd about the project from the Talk Python To Me podcast and wanted to check it out!

@samuelcolvin
Copy link
Member

oh great, well we'd love you to contribute more. There will be a lot going on with pydantic and pydantic-core over the next few months, so it should be a fun project be get involved in.

@ytmimi
Copy link
Contributor Author

ytmimi commented Aug 12, 2022

I'm definitely interested in taking on some more issues!

@ytmimi ytmimi deleted the support_dict_items branch August 12, 2022 15:15
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.

Support dict_items as we do dict_keys and dict_values to list like fields
3 participants