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

Avoid a TypeError when ChoiceFilter choices are a callable #689

Merged
merged 2 commits into from
Mar 23, 2022

Conversation

glennmatthews
Copy link
Contributor

Fixes #688.

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.

many thanks... just one minor comment and a suggestion.

I also added this to test_django_filters_requests to make sure this behaves as expected

+    response = APIClient().get('/api/products/?choice_func=C')                                                                                                                                                      
+    assert response.status_code == 200                                                                                                                                                                              
+    assert len(response.json()) == 0  

drf_spectacular/contrib/django_filters.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 23, 2022

Codecov Report

Merging #689 (acf26a4) into master (fdf07fe) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #689   +/-   ##
=======================================
  Coverage   98.86%   98.87%           
=======================================
  Files          64       64           
  Lines        7167     7175    +8     
=======================================
+ Hits         7086     7094    +8     
  Misses         81       81           
Impacted Files Coverage Δ
drf_spectacular/contrib/django_filters.py 92.45% <100.00%> (+0.14%) ⬆️
tests/contrib/test_django_filters.py 100.00% <100.00%> (ø)

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 fdf07fe...acf26a4. Read the comment docs.

@tfranzel tfranzel merged commit 8ff0d6b into tfranzel:master Mar 23, 2022
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.

TypeError in schema generation when using a django_filters.ChoiceFilter with a callable "choices"
2 participants