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 __parameters__ access in gen._generate_mapping #221

Conversation

raabf
Copy link
Contributor

@raabf raabf commented Feb 3, 2022

There are Generic types in the typing modules
from which you can inherit in your own classes
which do not have an parameters attribute,
such classes are now ignored making
gen._generate_mapping effectively a no-op
in case the class do not have an parameters
attribute.

As https://github.com/ilevkivskyi/typing_inspect/blob/8f6aa2075ba448ab322def454137e7c59b9b302d/typing_inspect.py#L405
is showing there are also cases where parameters
could be None, so I test for both cases, that it
is None or that it does not exist.

See Also:
#217

@Tinche
Copy link
Member

Tinche commented Feb 3, 2022

Alright, nice and easy. Add a changelog entry, make sure tests pass and in it goes ;)

@Tinche
Copy link
Member

Tinche commented Feb 4, 2022

Looks good. There's a conflict since I merged something else in prior so please resolve that and I'll merge. I'll probably edit your changelog entry for brevity.

Thanks!

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2022

Codecov Report

Merging #221 (b62813c) into main (9dd127a) will decrease coverage by 10.59%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #221       +/-   ##
===========================================
- Coverage   98.34%   87.74%   -10.60%     
===========================================
  Files          16       16               
  Lines         723      718        -5     
===========================================
- Hits          711      630       -81     
- Misses         12       88       +76     
Impacted Files Coverage Δ
src/cattr/_compat.py 58.16% <100.00%> (-36.77%) ⬇️
src/cattr/_generics.py 80.00% <0.00%> (-20.00%) ⬇️
src/cattr/converters.py 93.31% <0.00%> (-5.74%) ⬇️

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 93dcd98...b62813c. Read the comment docs.

@raabf raabf force-pushed the gen_generate_mapping_attribute_error_parameters branch from 32bcb3c to f24f946 Compare February 5, 2022 00:40
There are Generic types in the typing modules
from which you can inherit in your own classes
which do not have an __parameters__ attribute,
such classes are now ignored making
gen._generate_mapping effectively a no-op
in case the class do not have an __parameters__
attribute.

As https://github.com/ilevkivskyi/typing_inspect/blob/8f6aa2075ba448ab322def454137e7c59b9b302d/typing_inspect.py#L405
is showing there are also cases where __parameters__
could be None, so I test for both cases, that it
is None or that it does not exist.

See Also:
python-attrs#217
@raabf raabf force-pushed the gen_generate_mapping_attribute_error_parameters branch from f24f946 to b62813c Compare February 5, 2022 00:47
@raabf
Copy link
Contributor Author

raabf commented Feb 5, 2022

Cool!
I have shortened the history entry a bit, feel free to edit further.
I have rebased the branch on current main.

@Tinche
Copy link
Member

Tinche commented Feb 7, 2022

Test failures I believe are unrelated, and I fixed them yesterday. Merging this in, thanks!

@Tinche Tinche merged commit 3ee4b40 into python-attrs:main Feb 7, 2022
@raabf raabf deleted the gen_generate_mapping_attribute_error_parameters branch June 19, 2023 14:34
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.

3 participants