[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread miss-islington


miss-islington  added the comment:


New changeset 6cb0486ce861903448bd6ba1095685b6cd48e3bd by Miss Islington (bot) 
in branch '3.7':
bpo-35341: Add generic version of OrderedDict to typing (GH-10850)
https://github.com/python/cpython/commit/6cb0486ce861903448bd6ba1095685b6cd48e3bd


--
nosy: +miss-islington

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10086

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:


New changeset 68b56d02ef20479b87c65e523cf3dec1b7b77d40 by Ivan Levkivskyi (Ismo 
Toijala) in branch 'master':
bpo-35341: Add generic version of OrderedDict to typing (GH-10850)
https://github.com/python/cpython/commit/68b56d02ef20479b87c65e523cf3dec1b7b77d40


--

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

> Shall I open a new issue for this?

@itoijala Please see https://bugs.python.org/issue33462. It's on master.

--
nosy: +xtreak

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread Ismo Toijala


Change by Ismo Toijala :


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

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-02 Thread Ismo Toijala


Ismo Toijala  added the comment:

My reason for using OrderedDict was that the normal dict is not reversible. I 
needed to get the last element added, so I ended up doing something like 
next(reversed(ordered_dict)).

Perhaps this would be something to add to the normal dict (for 3.8?). Then I 
could migrate away from OrderedDict.

Shall I open a new issue for this?

--

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-12-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Now that regular dicts are ordered, my expectation is that OrderedDict() is 
going to mostly fall into disuse (much like UserDict, UserList, UserString).

That said, it would be nice if all of the collections classes had generic 
counterparts in the typing module.

--
nosy: +rhettinger

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-29 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Also typing is technically still provisional, we can backport this to previous 
versions (at least to 3.7).

--

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-29 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Yes, since we already have `DefaultDict`, `Counter`, and `ChainMap` from 
collections, we can also add `OrderedDict`.

--

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

Given that this is in collections, I don't object. Ivan, what do you say?

--

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-28 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-28 Thread Ismo Toijala


New submission from Ismo Toijala :

The other collections from the collections module (namedtuple, deque, ChainMap, 
Counter, defaultdict) have generic versions in the typing module for use in 
type annotations.

The problem is currently the following:

from __future__ import annotations
import typing
from collections import OrderedDict
# Understood by mypy
def f(d: OrderedDict[str, str]) -> None:
pass
typing.get_type_hints(f)

gives:

Traceback (most recent call last):
  File "foo.py", line 9, in 
typing.get_type_hints(f)
  File "/usr/lib/python3.7/typing.py", line 1001, in get_type_hints
value = _eval_type(value, globalns, localns)
  File "/usr/lib/python3.7/typing.py", line 260, in _eval_type
return t._evaluate(globalns, localns)
  File "/usr/lib/python3.7/typing.py", line 464, in _evaluate
eval(self.__forward_code__, globalns, localns),
  File "", line 1, in 
TypeError: 'type' object is not subscriptable

To fix this, a line like the following could be added to Lib/typing.py near 
line 1250:

OrderedDict = _alias(collections.OrderedDict, (KT, VT))

There might be a reasoning for why this has not been done yet, but I have not 
been able to find any.

If this is acceptable, I could prepare a PR.
I suppose there is no hope of a backport to 3.7, since this is a new feature 
(though very minor).

--
components: Library (Lib)
messages: 330616
nosy: itoijala
priority: normal
severity: normal
status: open
title: Add generic version of OrderedDict to typing module
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

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