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

Fixed bug with cached_property non-Model objects not being traversed #329

Merged

Conversation

spookylukey
Copy link
Contributor

Without this patch, paths like source="sub_object.part" were not being traversed to find type annotations for part if sub_object was a non-Model class defined using cached_property instead of property.

Tests are added for both the property and cached_property cases, and some further recursive possibilities. e.g. going back to a Model class.

Without this patch, paths like source="sub_object.part" were not being traversed
to find type annotations for `part` if `sub_object` was a non-Model class
defined using `cached_property` instead of `property`.

Tests are added for both the `property` and `cached_property` cases, and some
further recursive possibilities. e.g. going back to a Model class.
@codecov
Copy link

codecov bot commented Mar 9, 2021

Codecov Report

Merging #329 (ccaf02c) into master (02fcef2) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #329      +/-   ##
==========================================
- Coverage   98.22%   98.15%   -0.08%     
==========================================
  Files          53       54       +1     
  Lines        4729     4925     +196     
==========================================
+ Hits         4645     4834     +189     
- Misses         84       91       +7     
Impacted Files Coverage Δ
drf_spectacular/plumbing.py 96.82% <100.00%> (+0.09%) ⬆️
tests/test_fields.py 100.00% <100.00%> (ø)
drf_spectacular/contrib/django_filters.py 87.23% <0.00%> (-2.18%) ⬇️
drf_spectacular/openapi.py 95.31% <0.00%> (-0.54%) ⬇️
tests/test_polymorphic.py 100.00% <0.00%> (ø)
tests/contrib/test_django_filters.py 100.00% <0.00%> (ø)
tests/test_split.py 100.00% <0.00%> (ø)
tests/test_regressions.py 99.90% <0.00%> (+<0.01%) ⬆️
drf_spectacular/generators.py 96.69% <0.00%> (+0.02%) ⬆️
... and 1 more

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 02fcef2...ccaf02c. Read the comment docs.

Copy link
Owner

@tfranzel tfranzel left a comment

Choose a reason for hiding this comment

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

thanks @spookylukey, another awesome change! i just had to sit back a second and appreciate that this actually supports recursion for arbitrary hinted objects.

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