|
15 | 15 | from .exceptions import FileError, FormParserError, MultipartParseError, QuerystringParseError |
16 | 16 |
|
17 | 17 | if TYPE_CHECKING: # pragma: no cover |
18 | | - from typing import Any, Callable, Literal, Protocol, TypedDict |
19 | | - |
20 | | - from typing_extensions import TypeAlias |
| 18 | + from collections.abc import Callable |
| 19 | + from typing import Any, Literal, Protocol, TypeAlias, TypedDict |
21 | 20 |
|
22 | 21 | class SupportsRead(Protocol): |
23 | 22 | def read(self, __n: int) -> bytes: ... |
@@ -332,7 +331,7 @@ def __repr__(self) -> str: |
332 | 331 | else: |
333 | 332 | v = repr(self.value) |
334 | 333 |
|
335 | | - return "{}(field_name={!r}, value={})".format(self.__class__.__name__, self.field_name, v) |
| 334 | + return f"{self.__class__.__name__}(field_name={self.field_name!r}, value={v})" |
336 | 335 |
|
337 | 336 |
|
338 | 337 | class File: |
@@ -570,7 +569,7 @@ def close(self) -> None: |
570 | 569 | self._fileobj.close() |
571 | 570 |
|
572 | 571 | def __repr__(self) -> str: |
573 | | - return "{}(file_name={!r}, field_name={!r})".format(self.__class__.__name__, self.file_name, self.field_name) |
| 572 | + return f"{self.__class__.__name__}(file_name={self.file_name!r}, field_name={self.field_name!r})" |
574 | 573 |
|
575 | 574 |
|
576 | 575 | class BaseParser: |
@@ -1241,7 +1240,7 @@ def data_callback(name: CallbackName, end_i: int, remaining: bool = False) -> No |
1241 | 1240 | elif state == MultipartState.HEADER_VALUE_ALMOST_DONE: |
1242 | 1241 | # The last character should be a LF. If not, it's an error. |
1243 | 1242 | if c != LF: |
1244 | | - msg = "Did not find LF character at end of header (found %r)" % (c,) |
| 1243 | + msg = f"Did not find LF character at end of header (found {c!r})" |
1245 | 1244 | self.logger.warning(msg) |
1246 | 1245 | e = MultipartParseError(msg) |
1247 | 1246 | e.offset = i |
@@ -1715,7 +1714,7 @@ def on_headers_finished() -> None: |
1715 | 1714 | else: |
1716 | 1715 | self.logger.warning("Unknown Content-Transfer-Encoding: %r", transfer_encoding) |
1717 | 1716 | if self.config["UPLOAD_ERROR_ON_BAD_CTE"]: |
1718 | | - raise FormParserError('Unknown Content-Transfer-Encoding "{!r}"'.format(transfer_encoding)) |
| 1717 | + raise FormParserError(f'Unknown Content-Transfer-Encoding "{transfer_encoding!r}"') |
1719 | 1718 | else: |
1720 | 1719 | # If we aren't erroring, then we just treat this as an |
1721 | 1720 | # unencoded Content-Transfer-Encoding. |
@@ -1746,7 +1745,7 @@ def _on_end() -> None: |
1746 | 1745 |
|
1747 | 1746 | else: |
1748 | 1747 | self.logger.warning("Unknown Content-Type: %r", content_type) |
1749 | | - raise FormParserError("Unknown Content-Type: {}".format(content_type)) |
| 1748 | + raise FormParserError(f"Unknown Content-Type: {content_type}") |
1750 | 1749 |
|
1751 | 1750 | self.parser = parser |
1752 | 1751 |
|
@@ -1776,7 +1775,7 @@ def close(self) -> None: |
1776 | 1775 | self.parser.close() |
1777 | 1776 |
|
1778 | 1777 | def __repr__(self) -> str: |
1779 | | - return "{}(content_type={!r}, parser={!r})".format(self.__class__.__name__, self.content_type, self.parser) |
| 1778 | + return f"{self.__class__.__name__}(content_type={self.content_type!r}, parser={self.parser!r})" |
1780 | 1779 |
|
1781 | 1780 |
|
1782 | 1781 | def create_form_parser( |
|
0 commit comments