Micro-optimization
This commit is contained in:
parent
3b1d534f6d
commit
a4daa49f70
@ -12,10 +12,6 @@ from typing import (
|
|||||||
from .utils import Choice, to_bool
|
from .utils import Choice, to_bool
|
||||||
|
|
||||||
|
|
||||||
def to_string(x: str) -> str:
|
|
||||||
return x
|
|
||||||
|
|
||||||
|
|
||||||
class Group:
|
class Group:
|
||||||
|
|
||||||
__slots__ = 'name', 'short_text', 'start_text', 'end_text'
|
__slots__ = 'name', 'short_text', 'start_text', 'end_text'
|
||||||
@ -104,7 +100,7 @@ def option(
|
|||||||
name: str,
|
name: str,
|
||||||
defval: Any,
|
defval: Any,
|
||||||
long_text: str = '',
|
long_text: str = '',
|
||||||
option_type: Callable[[str], Any] = to_string,
|
option_type: Callable[[str], Any] = str,
|
||||||
add_to_default: bool = True,
|
add_to_default: bool = True,
|
||||||
add_to_docs: bool = True
|
add_to_docs: bool = True
|
||||||
) -> Option:
|
) -> Option:
|
||||||
@ -113,7 +109,7 @@ def option(
|
|||||||
name = name[1:]
|
name = name[1:]
|
||||||
defval_type = type(defval)
|
defval_type = type(defval)
|
||||||
if defval_type is not str:
|
if defval_type is not str:
|
||||||
if option_type is to_string:
|
if option_type is str:
|
||||||
if defval_type is bool:
|
if defval_type is bool:
|
||||||
option_type = to_bool
|
option_type = to_bool
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user