updated repr

This commit is contained in:
Daniil Fajnberg 2021-12-26 16:10:22 +01:00
parent 7e10668cbc
commit 4b1536c19a

View File

@ -23,10 +23,12 @@ class FormField:
def __repr__(self) -> str:
s = '<InputField' if self.options is None else '<SelectField'
s += f': name="{self.name}"'
if self.required:
s += ', required=True'
if self._default is not None:
s += f', default="{self.default}"'
if self.required:
s += ', required=True'
if self.options is not None:
s += f', options={self.options}'
return s + '>'
def __str__(self) -> str:
@ -75,6 +77,10 @@ class Form:
self.full_payload_always: bool = full_payload
self.url: Optional[str] = url
def __repr__(self) -> str:
fields = ', '.join(f"'{alias}': {field}" for alias, field in self.fields.items())
return f'Form({fields})'
@property
def fields(self) -> Dict[str, FormField]:
return self._fields.copy()