From 83f5914e594775480983c46bbab48a3006504edf Mon Sep 17 00:00:00 2001 From: eltbus <33374178+eltbus@users.noreply.github.com> Date: Sun, 21 Jan 2024 17:25:43 +0100 Subject: [PATCH] Use "cls". Assume name can be string or bytestring in type-hints --- multipart/multipart.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multipart/multipart.py b/multipart/multipart.py index d09e65c..b13b809 100644 --- a/multipart/multipart.py +++ b/multipart/multipart.py @@ -9,7 +9,7 @@ import tempfile from io import BytesIO from numbers import Number -from typing import overload, Dict, Tuple +from typing import overload, Dict, List, Optional, Tuple, Union # Unique missing object. _missing = object() @@ -139,15 +139,15 @@ class Field: :param name: the name of the form field """ - def __init__(self, name): + def __init__(self, name: Union[bytes, str]): self._name = name - self._value = [] + self._value: List[bytes] = [] # We cache the joined version of _value for speed. self._cache = _missing @classmethod - def from_value(klass, name, value): + def from_value(cls, name: Union[bytes, str], value: Optional[bytes]): """Create an instance of a :class:`Field`, and set the corresponding value - either None or an actual value. This method will also finalize the Field itself. @@ -157,7 +157,7 @@ def from_value(klass, name, value): None """ - f = klass(name) + f = cls(name) if value is None: f.set_none() else: