Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Args for "flexible callable" experimental mypy feature. #793

Merged
merged 9 commits into from
May 2, 2017

Conversation

sixolet
Copy link
Contributor

@sixolet sixolet commented Dec 25, 2016

This is the typeshed for the constructors for the Arg types that we'll now be able to pass to Callable. They really just return their type arguments.

It's a dependency for python/mypy#2607.

This is the typeshed for the constructors for the Arg types that we'll now be
able to pass to Callable.  They really just return their type arguments.
@gvanrossum
Copy link
Member

In stubs the usual PEP 8 rule about blank lines between functions does not apply (not even one blank line is required).

@ambv
Copy link
Contributor

ambv commented Jan 4, 2017

Flake8 was complaining not about newlines between declarations but about a missing newline at the end of the file. This warning is about detecting truncated content.

@gvanrossum
Copy link
Member

Nobody was claiming otherwise. :-)

@ambv
Copy link
Contributor

ambv commented Jan 12, 2017

This should be merged along with python/mypy#2607, not sooner.

@ambv ambv added stubs: request OUTDATED! Request to add stubs for a new package to typeshed priority-normal labels Jan 12, 2017
@gvanrossum
Copy link
Member

@sixolet Could you rebase this one?

@gvanrossum gvanrossum removed blocked stubs: request OUTDATED! Request to add stubs for a new package to typeshed labels Apr 19, 2017
@gvanrossum
Copy link
Member

@sixolet Can you rebase this too? I'm optimistically removing the "blocked" label, and the "feature" label because we don't really use that.

@sixolet
Copy link
Contributor Author

sixolet commented Apr 19, 2017

Yep, will do.


_T = TypeVar('_T')


def Arg(typ: _T = ..., name: Optional[str] = ...) -> _T: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename typ to type for consistency with python/mypy#2607.

Copy link
Member

@JelleZijlstra JelleZijlstra Apr 25, 2017

Choose a reason for hiding this comment

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

I might prefer typ to avoid shadowing a builtin, although it doesn't matter much here. Either way, obviously the runtime implementation and stub should be consistent.

@@ -1,8 +1,21 @@
from typing import Dict, Type, TypeVar, Union
from typing import Dict, Type, TypeVar, Optional, Union

_T = TypeVar('_T')

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove second empty line (in typeshed we tend to use a single empty line between different sorts of things).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am a smartass and put this as a separate diff because it is unrelated: #1237


def KwArg(typ: _T = ...) -> _T: ...


Copy link
Contributor

Choose a reason for hiding this comment

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

Like above -- remove second empty line.

def Arg(typ: _T = ..., name: Optional[str] = ...) -> _T: ...

def DefaultArg(typ: _T = ..., name: Optional[str] = ...) -> _T: ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Another style nit: remove empty lines between functions (this is a typeshed convention).

JukkaL pushed a commit to python/mypy that referenced this pull request May 2, 2017
…thing you can do (#2607)

Implements an experimental feature to allow Callable to have any kind of signature an actual function definition does.

This should enable better typing of callbacks &c.

Initial discussion: python/typing#239
Proposal, v. similar to this impl: python/typing#264
Relevant typeshed PR: python/typeshed#793
@JukkaL
Copy link
Contributor

JukkaL commented May 2, 2017

@sixolet Ping -- this still needs to get in before we can advertise the new callable syntax.

@sixolet
Copy link
Contributor Author

sixolet commented May 2, 2017 via email

@sixolet
Copy link
Contributor Author

sixolet commented May 2, 2017

I think ready now.

Copy link
Contributor

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

LGTM

@JukkaL JukkaL merged commit 6a9d74d into python:master May 2, 2017
@sixolet sixolet deleted the args-for-callable branch May 2, 2017 20:42
li-dan pushed a commit to li-dan/typeshed that referenced this pull request May 22, 2017
This is the typeshed for the constructors for the Arg types that we'll now be
able to pass to Callable.  They really just return their type arguments.
msullivan pushed a commit to python/mypy_extensions that referenced this pull request Jan 15, 2019
…thing you can do (#2607)

Implements an experimental feature to allow Callable to have any kind of signature an actual function definition does.

This should enable better typing of callbacks &c.

Initial discussion: python/typing#239
Proposal, v. similar to this impl: python/typing#264
Relevant typeshed PR: python/typeshed#793
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.

5 participants