Skip to content

Commit

Permalink
Use "cls". Assume name can be string or bytestring in type-hints
Browse files Browse the repository at this point in the history
  • Loading branch information
eltbus committed Jan 21, 2024
1 parent 72238e3 commit 83f5914
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions multipart/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down

0 comments on commit 83f5914

Please sign in to comment.