Skip to content

Commit

Permalink
Enforce positional-only parameters for public functions
Browse files Browse the repository at this point in the history
Resolves #18
  • Loading branch information
davidfstr committed Dec 23, 2023
1 parent 7343b04 commit ddc3e72
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions trycast.py
Expand Up @@ -280,19 +280,25 @@ def trycast(

@overload
def trycast(
tp: Type[_T], value: object, failure: _F, *, strict: bool = True, eval: bool = True
tp: Type[_T],
value: object,
/,
failure: _F,
*,
strict: bool = True,
eval: bool = True,
) -> Union[_T, _F]:
... # pragma: no cover


@overload
def trycast(
tp: object, value: object, failure: _F, *, strict: bool = True, eval: bool = True
tp: object, value: object, /, failure: _F, *, strict: bool = True, eval: bool = True
) -> Union[object, _F]:
... # pragma: no cover


def trycast(tp, value, failure=None, *, strict=True, eval=True):
def trycast(tp, value, /, failure=None, *, strict=True, eval=True):
"""
If `value` is in the shape of `tp` (as accepted by a Python typechecker
conforming to PEP 484 "Type Hints") then returns it, otherwise returns
Expand Down

0 comments on commit ddc3e72

Please sign in to comment.