Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sergue1 committed Feb 15, 2024
1 parent 62fa0af commit 219faa3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/python-fastui/fastui/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ def deference_json_schema(
if def_schema is None:
raise ValueError(f'Invalid $ref "{ref}", not found in {defs}')
else:
# clone dict to avoid attribute leakage
return def_schema.copy(), required
return def_schema.copy(), required # clone dict to avoid attribute leakage via shared schema

Check warning on line 313 in src/python-fastui/fastui/json_schema.py

View check run for this annotation

Codecov / codecov/patch

src/python-fastui/fastui/json_schema.py#L313

Added line #L313 was not covered by tests
elif any_of := schema.get('anyOf'):
if len(any_of) == 2 and sum(s.get('type') == 'null' for s in any_of) == 1:
# If anyOf is a single type and null, then it is optional
Expand Down
4 changes: 2 additions & 2 deletions src/python-fastui/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,11 @@ class SelectEnum(str, enum.Enum):

class FormSelectMultiple(BaseModel):
select_single: SelectEnum = Field(title='Select Single', description='first field')
select_single_2: SelectEnum = Field(title='Select Single') # unset description
select_single_2: SelectEnum = Field(title='Select Single') # unset description to test leakage from prev. field
select_multiple: List[SelectEnum] = Field(title='Select Multiple', description='third field')


def test_form_select_multiple():
def test_form_description_leakage():
m = components.ModelForm(model=FormSelectMultiple, submit_url='/foobar/')

assert m.model_dump(by_alias=True, exclude_none=True) == {
Expand Down

0 comments on commit 219faa3

Please sign in to comment.