[issue32227] singledispatch support for type annotations

2018-03-14 Thread Łukasz Langa

Change by Łukasz Langa :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2018-03-14 Thread Xiang Zhang

Change by Xiang Zhang :


--
pull_requests: +5882
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2018-02-04 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

> Do you think it should be added to the What's New? page for 3.7?

I leave this up to Łukasz.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2018-02-03 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Hello,

I believe this could be closed as resolved?  Do you think it should be added to 
the What's New? page for 3.7?

--
nosy: +csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-11 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset e56975351bc2c574c728f738e88effba7116279f by Łukasz Langa in 
branch 'master':
bpo-32227: functools.singledispatch supports registering via type annotations 
(#4733)
https://github.com/python/cpython/commit/e56975351bc2c574c728f738e88effba7116279f


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Łukasz Langa

Łukasz Langa  added the comment:

> this creates a circular dependency functools <-> typing

Well, it doesn't since I explicitly import typing inside singledispatch. By the 
time this import happens, functools is fully imported. This would only be a 
problem if functools itself tried to use singledispatch with annotations. Not 
impossible but super unlikely.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

Idea looks interesting (like a basic runtime @overload). My expectation is that 
some changes are necessary in mypy for this to work properly.

Another (minor) problem is that this creates a circular dependency functools 
<-> typing.

--
nosy: +levkivskyi -gvanrossum
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

Oops something wrong happened.

--
nosy: +gvanrossum
stage: patch review -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Łukasz Langa

Łukasz Langa  added the comment:

Guido, I know that you have a lot on your plate right now. Adding you because 
of PEP 443 and PEP 484.

--
nosy: +gvanrossum
stage: patch review -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Łukasz Langa

Change by Łukasz Langa :


--
keywords: +patch
pull_requests: +4636
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32227] singledispatch support for type annotations

2017-12-05 Thread Łukasz Langa

New submission from Łukasz Langa :

With the patch attached to this issue, @singledispatch gains support for 
passing the type in @register via annotations.

This looks more natural and enables more thorough type checking without 
repeating yourself:


@singledispatch
def generic(arg): ...

@generic.register
def _(arg: str): ...

@generic.register
def _(arg: int): ...


The previous API is still available for backwards compatibility, as well as 
stacking, and use with classes (sic, I was surprised to learn it's used that 
way, too).

The patch should be uncontroversial, maybe except for the fact that it's 
importing the `typing` module if annotations are used. This is necessary 
because of forward references, usage of None as a type, and so on. More 
importantly, with PEP 563 it's mandatory.

--
assignee: lukasz.langa
components: Library (Lib)
messages: 307686
nosy: lukasz.langa, rhettinger, yselivanov
priority: normal
severity: normal
status: open
title: singledispatch support for type annotations
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com