parse the raw parameters that pass to input functions - excludes: the parameters that don't appear in returned spec - remove the parameters whose value is None :return:(spec,valid_func)
(kwargs, excludes=())
| 108 | |
| 109 | |
| 110 | def _parse_args(kwargs, excludes=()): |
| 111 | """parse the raw parameters that pass to input functions |
| 112 | |
| 113 | - excludes: the parameters that don't appear in returned spec |
| 114 | - remove the parameters whose value is None |
| 115 | |
| 116 | :return:(spec,valid_func) |
| 117 | """ |
| 118 | kwargs = {k: v for k, v in kwargs.items() if v is not None and k not in excludes} |
| 119 | check_dom_name_value(kwargs.get('name', ''), '`name`') |
| 120 | |
| 121 | kwargs.update(kwargs.get('other_html_attrs', {})) |
| 122 | kwargs.pop('other_html_attrs', None) |
| 123 | |
| 124 | if kwargs.get('validate'): |
| 125 | kwargs['onblur'] = True |
| 126 | valid_func = kwargs.pop('validate', lambda _: None) |
| 127 | |
| 128 | if kwargs.get('onchange'): |
| 129 | onchange_func = kwargs['onchange'] |
| 130 | kwargs['onchange'] = True |
| 131 | else: |
| 132 | onchange_func = lambda _: None |
| 133 | |
| 134 | return kwargs, valid_func, onchange_func |
| 135 | |
| 136 | |
| 137 | def input(label: str = '', type: str = TEXT, *, validate: Callable[[Any], Optional[str]] = None, name: str = None, |
no test coverage detected
searching dependent graphs…