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

fix: support types without args #108

Merged
merged 9 commits into from
Dec 13, 2023

Conversation

lucasrcezimbra
Copy link
Contributor

Issue number of the reported bug or feature request: no related issue.

Describe your changes
The validator was not supporting types without args. For example:

>>> from unittest.mock import MagicMock
>>> from attrs_strict import type_validator
>>>
>>> attr = MagicMock()
>>> attr.name = "zoo"
>>> attr.type = list
>>>
>>> type_validator()(None, attr, [1, 2, 3])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
...
AttributeError: type object 'list' has no attribute '__args__'

This PR fixes it for lists, dicts, and tuples.

Testing performed
Written tests.

Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

You'll need to fix the CI for 3.8.

Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
gaborbernat
gaborbernat previously approved these changes Dec 13, 2023
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat
Copy link
Contributor

@lucasrcezimbra can you run pre-commit to fix the linting issues?

Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Signed-off-by: Lucas Rangel Cezimbra <[email protected]>
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat merged commit c056f60 into bloomberg:main Dec 13, 2023
15 checks passed
@lucasrcezimbra lucasrcezimbra deleted the types-without-args branch December 13, 2023 20:12
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.

2 participants