diff --git a/multipart/multipart.py b/multipart/multipart.py index 9f61eb8..ea8ccca 100644 --- a/multipart/multipart.py +++ b/multipart/multipart.py @@ -141,15 +141,15 @@ class MultipartState(IntEnum): # str on Py2, and bytes on Py3. Same with getting the ordinal value of a byte, # and joining a list of bytes together. # These functions abstract that. -def lower_char(c): +def lower_char(c: int) -> int: return c | 0x20 -def ord_char(c): +def ord_char(c: int) -> int: return c -def join_bytes(b): +def join_bytes(b: bytes) -> bytes: return bytes(list(b)) @@ -290,7 +290,7 @@ def field_name(self) -> bytes: return self._name @property - def value(self): + def value(self) -> bytes | None: """This property returns the value of the form field.""" if self._cache is _missing: self._cache = b"".join(self._value) @@ -424,7 +424,7 @@ def file_object(self): return self._fileobj @property - def size(self): + def size(self) -> int: """The total size of this file, counted as the number of bytes that currently have been written to the file. """ @@ -1142,7 +1142,7 @@ def set_mark(name: str): self.marks[name] = i # Remove a mark. - def delete_mark(name: str, reset: bool = False): + def delete_mark(name: str, reset: bool = False) -> None: self.marks.pop(name, None) # Helper function that makes calling a callback with data easier. The @@ -1150,7 +1150,7 @@ def delete_mark(name: str, reset: bool = False): # end of the buffer, and reset the mark, instead of deleting it. This # is used at the end of the function to call our callbacks with any # remaining data in this chunk. - def data_callback(name: str, remaining: bool = False): + def data_callback(name: str, remaining: bool = False) -> None: marked_index = self.marks.get(name) if marked_index is None: return @@ -1531,7 +1531,7 @@ def finalize(self) -> None: # error or otherwise state that we're not finished parsing. pass - def __repr__(self): + def __repr__(self) -> str: return f"{self.__class__.__name__}(boundary={self.boundary!r})"