Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move counter below Dict
  • Loading branch information
JelleZijlstra committed Jan 31, 2017
commit c0f748a1dcf5258badd3efabd93d53dc5fa3b1ea
22 changes: 11 additions & 11 deletions python2/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,17 +1719,6 @@ def __new__(cls, *args, **kwds):
return _generic_new(collections.deque, cls, *args, **kwds)


class Counter(collections.Counter, Dict[T, int]):
__slots__ = ()
__extra__ = collections.Counter

def __new__(cls, *args, **kwds):
if _geqv(cls, Counter):
raise TypeError("Type Counter cannot be instantiated; "
"use Counter() instead")
return _generic_new(collections.Counter, cls, *args, **kwds)


class Set(set, MutableSet[T]):
__slots__ = ()
__extra__ = set
Expand Down Expand Up @@ -1795,6 +1784,17 @@ def __new__(cls, *args, **kwds):
return _generic_new(collections.defaultdict, cls, *args, **kwds)


class Counter(collections.Counter, Dict[T, int]):
__slots__ = ()
__extra__ = collections.Counter

def __new__(cls, *args, **kwds):
if _geqv(cls, Counter):
raise TypeError("Type Counter cannot be instantiated; "
"use Counter() instead")
Copy link
Member

Choose a reason for hiding this comment

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

I would use full name collections.Counter() in the second line, otherwise this error message reads unclear.
(The same applies to Python 3 version).

return _generic_new(collections.Counter, cls, *args, **kwds)


# Determine what base class to use for Generator.
if hasattr(collections_abc, 'Generator'):
# Sufficiently recent versions of 3.5 have a Generator ABC.
Expand Down
22 changes: 11 additions & 11 deletions src/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1830,17 +1830,6 @@ def __new__(cls, *args, **kwds):
return _generic_new(collections.deque, cls, *args, **kwds)


class Counter(collections.Counter, Dict[T, int], extra=collections.Counter):

__slots__ = ()

def __new__(cls, *args, **kwds):
if _geqv(cls, Counter):
raise TypeError("Type Counter cannot be instantiated; "
"use Counter() instead")
return _generic_new(collections.Counter, cls, *args, **kwds)


class Set(set, MutableSet[T], extra=set):

__slots__ = ()
Expand Down Expand Up @@ -1910,6 +1899,17 @@ def __new__(cls, *args, **kwds):
return _generic_new(collections.defaultdict, cls, *args, **kwds)


class Counter(collections.Counter, Dict[T, int], extra=collections.Counter):

__slots__ = ()

def __new__(cls, *args, **kwds):
if _geqv(cls, Counter):
raise TypeError("Type Counter cannot be instantiated; "
"use Counter() instead")
return _generic_new(collections.Counter, cls, *args, **kwds)


if hasattr(collections, 'ChainMap'):
# ChainMap only exists in 3.3+
__all__.append('ChainMap')
Expand Down