Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of Payload.size from Optional[float] to Optional[int] #3484

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGES/3484.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``Payload.size`` type annotation changesd from `Optional[float]` to `Optional[int]`.
10 changes: 5 additions & 5 deletions aiohttp/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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:
Expand Down