From 48ac7f8c0f393cb1bc29b8729d1e034ea419f886 Mon Sep 17 00:00:00 2001 From: Alexander Shorin Date: Fri, 4 Jan 2019 20:31:46 +0300 Subject: [PATCH] Change type of Payload.size from Optional[float] to Optional[int] --- CHANGES/3484.bugfix | 1 + aiohttp/payload.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 CHANGES/3484.bugfix diff --git a/CHANGES/3484.bugfix b/CHANGES/3484.bugfix new file mode 100644 index 00000000000..b0276934890 --- /dev/null +++ b/CHANGES/3484.bugfix @@ -0,0 +1 @@ +``Payload.size`` type annotation changesd from `Optional[float]` to `Optional[int]`. diff --git a/aiohttp/payload.py b/aiohttp/payload.py index a002d1288d1..05fc8fa5c1b 100644 --- a/aiohttp/payload.py +++ b/aiohttp/payload.py @@ -120,7 +120,7 @@ def register(self, class Payload(ABC): - _size = None # type: Optional[float] + _size = None # type: Optional[int] _headers = None # type: Optional[_CIMultiDict] _content_type = 'application/octet-stream' # type: Optional[str] @@ -151,7 +151,7 @@ def __init__(self, self._content_type = content_type @property - def size(self) -> Optional[float]: + def size(self) -> Optional[int]: """Size of the payload.""" return self._size @@ -338,7 +338,7 @@ def __init__(self, ) @property - def size(self) -> Optional[float]: + def size(self) -> Optional[int]: try: return os.fstat(self._value.fileno()).st_size - self._value.tell() except OSError: @@ -362,7 +362,7 @@ async def write(self, writer: AbstractStreamWriter) -> None: class BytesIOPayload(IOBasePayload): @property - def size(self) -> float: + def size(self) -> int: position = self._value.tell() end = self._value.seek(0, os.SEEK_END) self._value.seek(position) @@ -372,7 +372,7 @@ def size(self) -> float: class BufferedReaderPayload(IOBasePayload): @property - def size(self) -> Optional[float]: + def size(self) -> Optional[int]: try: return os.fstat(self._value.fileno()).st_size - self._value.tell() except OSError: