Skip to content

Commit

Permalink
🐛 Do not mark blank=True strings as polymorphic
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Jan 23, 2025
1 parent 272f95a commit cf0aefb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _process_field_type(
primary_type, *other_types = union_types

data = _process_field_type(primary_type, field_info, field_name, depth)
if other_types == [NoneType]:
if all(union_type in (NoneType, Literal[""]) for union_type in other_types):
return data

commented_out_examples = [
Expand Down
5 changes: 5 additions & 0 deletions tests/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Meta:
"int_with_choices_and_blank_and_non_choice_default",
"str_with_localized_default",
"int_with_lazy_default",
"blank_str",
)
}
extra_kwargs = {
Expand Down Expand Up @@ -269,6 +270,10 @@ def test_directive_output(register_directive, docutils_document):
# DEFAULT VALUE: 42
# REQUIRED: false
int_with_lazy_default: 42
# DEFAULT VALUE: ""
# REQUIRED: false
blank_str: example_string
"""
)

Expand Down

0 comments on commit cf0aefb

Please sign in to comment.