Skip to content

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

Merged
JukkaL merged 9 commits into
python:masterfrom
sixolet:args-for-callable
May 2, 2017
Merged

Args for "flexible callable" experimental mypy feature.#793
JukkaL merged 9 commits into
python:masterfrom
sixolet:args-for-callable

Conversation

@sixolet

@sixolet sixolet commented Dec 25, 2016

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@ambv

ambv commented Jan 4, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

Nobody was claiming otherwise. :-)

@ambv

ambv commented Jan 12, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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

sixolet commented Apr 19, 2017

Copy link
Copy Markdown
Contributor Author

Yep, will do.

Comment thread third_party/2and3/mypy_extensions.pyi Outdated
_T = TypeVar('_T')


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

Copy link
Copy Markdown
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.

@JelleZijlstra JelleZijlstra Apr 25, 2017

Copy link
Copy Markdown
Member

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.

from typing import Dict, Type, TypeVar, Optional, Union

_T = TypeVar('_T')

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread third_party/2and3/mypy_extensions.pyi Outdated

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


Copy link
Copy Markdown
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.

Comment thread third_party/2and3/mypy_extensions.pyi Outdated
def Arg(typ: _T = ..., name: Optional[str] = ...) -> _T: ...

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

Copy link
Copy Markdown
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

JukkaL commented May 2, 2017

Copy link
Copy Markdown
Contributor

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

@sixolet

sixolet commented May 2, 2017 via email

Copy link
Copy Markdown
Contributor Author

@sixolet

sixolet commented May 2, 2017

Copy link
Copy Markdown
Contributor Author

I think ready now.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Contributor

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