updated from Atlas
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import collections
|
||||
from collections import namedtuple, abc
|
||||
|
||||
Card = collections.namedtuple('Card', ['rank', 'suit'])
|
||||
Card = namedtuple('Card', ['rank', 'suit'])
|
||||
|
||||
class FrenchDeck2(collections.MutableSequence):
|
||||
class FrenchDeck2(abc.MutableSequence):
|
||||
ranks = [str(n) for n in range(2, 11)] + list('JQKA')
|
||||
suits = 'spades diamonds clubs hearts'.split()
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ class SimplePicker: # <2>
|
||||
return self._items.pop()
|
||||
|
||||
def test_isinstance() -> None: # <4>
|
||||
popper = SimplePicker([1])
|
||||
assert isinstance(popper, RandomPicker)
|
||||
popper: RandomPicker = SimplePicker([1]) # <5>
|
||||
assert isinstance(popper, RandomPicker) # <6>
|
||||
|
||||
def test_item_type() -> None: # <5>
|
||||
def test_item_type() -> None: # <7>
|
||||
items = [1, 2]
|
||||
popper = SimplePicker(items)
|
||||
item = popper.pick()
|
||||
assert item in items
|
||||
if TYPE_CHECKING:
|
||||
reveal_type(item) # <6>
|
||||
reveal_type(item) # <8>
|
||||
assert isinstance(item, int)
|
||||
|
||||
@@ -168,5 +168,5 @@ class Vector2d:
|
||||
|
||||
@classmethod
|
||||
def fromcomplex(cls, datum):
|
||||
return Vector2d(datum.real, datum.imag) # <1>
|
||||
return cls(datum.real, datum.imag) # <1>
|
||||
# end::VECTOR2D_V4_COMPLEX[]
|
||||
|
||||
@@ -170,5 +170,5 @@ class Vector2d:
|
||||
@classmethod
|
||||
def fromcomplex(cls, datum: SupportsComplex) -> Vector2d: # <3>
|
||||
c = complex(datum) # <4>
|
||||
return Vector2d(c.real, c.imag)
|
||||
return cls(c.real, c.imag)
|
||||
# end::VECTOR2D_V5_COMPLEX[]
|
||||
|
||||
Reference in New Issue
Block a user