Skip to content

Commit

Permalink
Use a better name for the output field annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
j4mie committed Apr 16, 2024
1 parent c5b7832 commit 14149f5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions django_readers/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def visit_str(self, item):
def visit_dict_item_str(self, key, value):
# This is a model field name. First, check if the
# field has been explicitly overridden
if out := get_annotation(value, "out"):
if out := get_annotation(value, "field"):
field = self._prepare_field(out, kwargs=get_annotation(value, "kwargs"))

else:
Expand Down Expand Up @@ -184,7 +184,7 @@ def visit_dict_item_dict(self, key, value):

def visit_dict_item_tuple(self, key, value):
# This is a producer pair.
out = get_annotation(value, "out")
out = get_annotation(value, "field")
kwargs = get_annotation(value, "kwargs") or {}
if out:
field = self._prepare_field(out, kwargs)
Expand All @@ -198,7 +198,7 @@ def visit_dict_item_tuple(self, key, value):

def visit_tuple(self, item):
# This is a projector pair.
out = get_annotation(item, "out")
out = get_annotation(item, "field")
kwargs = get_annotation(item, "kwargs") or {}
if out:
# `out` is a dictionary mapping field names to Fields
Expand Down Expand Up @@ -276,17 +276,17 @@ def wrapper(*args, **kwargs):
result = item(*args, **kwargs)
return self(result)

add_annotation(wrapper, "out", field_or_dict)
add_annotation(wrapper, "field", field_or_dict)
add_annotation(wrapper, "kwargs", kwargs)
return wrapper
else:
if isinstance(item, str):
item = StringWithAnnotation(item)
add_annotation(item, "out", field_or_dict)
add_annotation(item, "field", field_or_dict)
add_annotation(item, "kwargs", kwargs)
if isinstance(item, tuple):
item = PairWithAnnotation(item)
add_annotation(item, "out", field_or_dict)
add_annotation(item, "field", field_or_dict)
add_annotation(item, "kwargs", kwargs)
return item

Expand Down

0 comments on commit 14149f5

Please sign in to comment.