Skip to content

Commit fe2085a

Browse files
committed
Merge branch 'master' of github.com:fluentpython/protocol_examples into master
2 parents 2e65cf5 + c3952d4 commit fe2085a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

less_than/max_overload/mymax.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# tag::MYMAX_TYPES[]
22
from typing import Protocol, Any, TypeVar, overload, Callable, Iterable, Union
33

4+
MISSING = object()
5+
EMPTY_MSG = 'max() arg is an empty sequence'
6+
47
class _SupportsLessThan(Protocol):
58
def __lt__(self, other: Any) -> bool: ...
69

710
_T = TypeVar('_T')
811
_LT = TypeVar('_LT', bound=_SupportsLessThan)
912
_DT = TypeVar('_DT')
1013

11-
MISSING = object()
12-
EMPTY_MSG = 'max() arg is an empty sequence'
13-
1414
@overload
1515
def max(__arg1: _LT, __arg2: _LT, *_args: _LT, key: None = ...) -> _LT:
1616
...
@@ -29,8 +29,6 @@ def max(__iterable: Iterable[_LT], *, key: None = ..., default: _DT) -> Union[_L
2929
@overload
3030
def max(__iterable: Iterable[_T], *, key: Callable[[_T], _LT], default: _DT) -> Union[_T, _DT]:
3131
...
32-
# end::MYMAX_TYPES[]
33-
# tag::MYMAX[]
3432
def max(first, *args, key=None, default=MISSING):
3533
if args:
3634
series = args
@@ -55,7 +53,6 @@ def max(first, *args, key=None, default=MISSING):
5553
candidate = current
5654
candidate_key = current_key
5755
return candidate
58-
# end::MYMAX[]
5956

6057
@overload
6158
def min(__arg1: _LT, __arg2: _LT, *_args: _LT, key: None = ...) -> _LT:

0 commit comments

Comments
 (0)