Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repos:
- id: flake8
additional_dependencies:
- flake8-tidy-imports
- flake8-bugbear
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.20.0
hooks:
Expand Down
8 changes: 6 additions & 2 deletions rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ def get_default_ordering(self, view):
return (ordering,)
return ordering

def get_default_valid_fields(self, queryset, view, context={}):
def get_default_valid_fields(self, queryset, view, context=None):
if context is None:
context = {}
# If `ordering_fields` is not specified, then we determine a default
# based on the serializer class, if one exists on the view.
if hasattr(view, 'get_serializer_class'):
Expand Down Expand Up @@ -286,7 +288,9 @@ def get_default_valid_fields(self, queryset, view, context={}):
)
]

def get_valid_fields(self, queryset, view, context={}):
def get_valid_fields(self, queryset, view, context=None):
if context is None:
context = {}
valid_fields = getattr(view, 'ordering_fields', self.ordering_fields)

if valid_fields is None:
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
ignore = E501,W503,W504
extend-ignore = E501,W503,W504,B
extend-select = B006
Comment on lines +2 to +3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Disabled all flake8-bugbear checks except the mutable default arguments for now. We have a number of existing violations, but they feel out of scope of this PR.

banned-modules = json = use from rest_framework.utils import json!