-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
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.
In stubs the usual PEP 8 rule about blank lines between functions does not apply (not even one blank line is required). |
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. |
Nobody was claiming otherwise. :-) |
This should be merged along with python/mypy#2607, not sooner. |
@sixolet Could you rebase this one? |
@sixolet Can you rebase this too? I'm optimistically removing the "blocked" label, and the "feature" label because we don't really use that. |
Yep, will do. |
|
||
_T = TypeVar('_T') | ||
|
||
|
||
def Arg(typ: _T = ..., name: Optional[str] = ...) -> _T: ... |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') | |||
|
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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: ... | ||
|
||
|
There was a problem hiding this comment.
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: ... | ||
|
There was a problem hiding this comment.
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).
…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
@sixolet Ping -- this still needs to get in before we can advertise the new callable syntax. |
Cool. Making sure all the needful is done is on the docket for this afternoon.
… On May 2, 2017, at 9:06 AM, Jukka Lehtosalo ***@***.***> wrote:
@sixolet Ping -- this still needs to get in before we can advertise the new callable syntax.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I think ready now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
…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
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.