Let's say I have a function that has type annotations and then a variable (pointer) to that function:
def some_func(arg1: str, arg2: int = 0, arg3: str | None = None) -> List[Any]:
# do something and return
another_func = some_func
Because py.typed packages should have all variables type-annotated than another_func
should be as well, otherwise Pylance will complain and not provide autocomplete if the function is imported from an installed package.
How to deal with this? Is there an easy way to also keep the argument names? Or do I need to use Callable? And in that case, how do you handle default arguments? Because when I do something like this:
another_func: Callable[[str, int, str | None], List[Any]] = some_func
another_func("Hello")
Then I get more linting about positional arguments missing. How to deal with keyword arguments? Or to copy the function signature as type along with argument names?