Closed tombulled closed 2 years ago
Rename decorator to @fields
or @params
?
E.g:
@params
def say_hello(name: str = Param(default="sam")):
...
Rename repo to param
Wrapper function should return Field[T]
Should expose param.get_params()
E.g:
def get_params(func: Callable, /) -> List[Parameter]:
...
In here, every parameter is converted to a param.Parameter
even if it doesn't have a default of param.Param
.
Example 1:
def say_hello(name: str, message: str = Param(default="hello")):
...
>>> get_params(say_hello)
[
Parameter(
name="name",
annotation=str,
default=Missing,
type=ParamType.POS_OR_KW,
),
Parameter(
name="message",
annotation=str,
default="hello",
type=ParamType.POS_OR_KW,
),
]
Should expose param.get_arguments()
.
def get_arguments(func: Callable, args: Tuple[Any], kwargs: Dict[str, Any]) -> Arguments:
...
Where:
@dataclass
class Arguments:
args: Tuple[Any]
kwargs: Dict[str, Any]
arguments: Dict[str, Any]
Example:
def say_hello(name: str, message: str = Param(default="hello")):
...
>>> get_arguments(say_hello, ("bob",), {})
Arguments(
args=("bob", "hello"),
kwargs={},
arguments={"name": "bob", "message": "hello"},
)
Line 13 of fielded.py currently broken
Add Description: Enhanced function parameters
Should this library use arguments
under the hood?
Make param.get_params
return Parameter
objects containing the Param
instances?
E.g.
@dataclass
class Parameter:
name: str
annotation: Any
kind: ParameterKind
spec: Param
Note: As Param()
is a wrapper, the underlying class could be named different, e.g. ParameterSpecification
Make enrich
and parse
private functions
sentinels
and enums
currently sharing the same NoValue
class
__init__
should expose more:
api.get_params
api.get_arguments
models.Parameter
Rename ParameterKind
to ParameterType
enrich
currently throws an exception without the function name
get_arguments
has wrong type hint for args
, should be Tuple[Any, ...]
Add a better usage example to the README, it currently makes the library seem pointless.
E.g:
from param import Param, params
@params
def get(url: str, params: dict = Param(default_factory=dict)):
...
Instead of:
def get(url: str, params: Optional[dict]):
if params is None:
params = dict()
...
Rename models.Param
to models.ParameterSpecification
(but keep wrappers.Param
as-is)?
Make ParameterSpecification.default
return Missing
instead of throwing an error?
Publish GH release
Release to PyPI
Add project metadata
Add CI/CD
Rename
Field
toParam
? E.g: