Skip to content

Conversation

@kasium
Copy link
Contributor

@kasium kasium commented Jan 17, 2022

No description provided.

Copy link
Contributor

@arnimarj arnimarj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote stubs for the subset of invoke I've been using. Some if them I put in this comment. I'd be happy to send them all over if you like.

def get_arguments(self): ...

# TODO use the args
def task(*args, **kwargs) -> Task: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps here, I've been using this annotation for task:

FuncType = Callable[..., Any]
_F = TypeVar('_F', bound=FuncType)


def task(
	func: _F,
	*,
	name: str = ...,
) -> _F:
	...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, not sure about this, since it returns a Task object which is not present

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at this, but this sounds like a use case for ParamSpec from PEP 612.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the implementation in a bit more details (https://github.com/pyinvoke/invoke/blob/master/invoke/tasks.py)

The return object is indeed a Task, but the returned type can be controlled via the klass kwarg (currently defaults to Task). The Task object itself implements a __call__ which ends up calling the wrapped method using the given args/kwargs.

My proposed tweak is accurate for the use-cases I have (naked @task wrapping), but the return type is still not accurate.

@kasium
Copy link
Contributor Author

kasium commented Jan 17, 2022

I wrote stubs for the subset of invoke I've been using. Some if them I put in this comment. I'd be happy to send them all over if you like.

Sure, if it's fine for you I would keep this as a first draft. After the merge you can open a new PR and just merge your hints. Feel free to add me for a short review!

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looked over all the stubs, and added some suggestions for obvious types that stubgen didn't catch.

@JelleZijlstra JelleZijlstra merged commit 2bf7458 into python:master Jan 22, 2022
@JelleZijlstra
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants