Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rgimen3z committed Jun 1, 2024
1 parent 8e13ef1 commit d61c076
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python-fastui/fastui/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def json_schema_field_to_field(
initial=schema.get('default'),
autocomplete=schema.get('autocomplete'),
description=schema.get('description'),
step=schema.get('step', get_default_step(schema)),
placeholder=schema.get('placeholder'),
step=schema.get('step', _get_default_step(schema)),
)


Expand Down Expand Up @@ -374,7 +374,7 @@ def input_html_type(schema: JsonSchemaField) -> InputHtmlType:
raise ValueError(f'Unknown schema: {schema}') from e


def get_default_step(schema: JsonSchemaField) -> _t.Union[_t.Literal['any'], None]:
def _get_default_step(schema: JsonSchemaField) -> _t.Union[_t.Literal['any'], None]:
key = schema['type']
if key == 'integer':
return None
Expand Down
10 changes: 10 additions & 0 deletions src/python-fastui/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def test_form_fields():
class FormNumbersDefaultStep(BaseModel):
size: int
cost: float
fees: float = Field(json_schema_extra={'step': '0.01'})


def test_form_numbers_default_step():
Expand Down Expand Up @@ -579,5 +580,14 @@ def test_form_numbers_default_step():
'step': 'any',
'type': 'FormFieldInput',
},
{
'name': 'fees',
'title': ['Fees'],
'required': True,
'locked': False,
'htmlType': 'number',
'step': '0.01',
'type': 'FormFieldInput',
},
],
}

0 comments on commit d61c076

Please sign in to comment.