Skip to content

Commit

Permalink
Make MyPy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Jan 2, 2024
1 parent 5cc43b8 commit 852e343
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/treq/_cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@
# [1]: https://github.com/python/cpython/blob/60edc70a9374f1cc6ecff5974e438d58fec29985/Lib/cgi.py
# [2]: https://github.com/python/cpython/blob/60edc70a9374f1cc6ecff5974e438d58fec29985/LICENSE#L73

from typing import Dict, Iterator, Tuple

def _parseparam(s):

def _parseparam(s: str) -> Iterator[str]:
while s[:1] == ';':
s = s[1:]
end = s.find(';')
Expand All @@ -75,7 +77,7 @@ def _parseparam(s):
s = s[end:]


def parse_header(line):
def parse_header(line: str) -> Tuple[str, Dict[str, str]]:
"""Parse a Content-type like header.
Return the main content-type and a dictionary of options.
Expand Down
3 changes: 2 additions & 1 deletion src/treq/test/test_content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest import mock
from typing import Optional

from twisted.python.failure import Failure

Expand Down Expand Up @@ -273,7 +274,7 @@ def error(data):


class EncodingFromHeadersTests(unittest.TestCase):
def _encodingFromContentType(self, content_type: str) -> str | None:
def _encodingFromContentType(self, content_type: str) -> Optional[str]:
"""
Invoke `_encoding_from_headers()` for a header value.
Expand Down
2 changes: 1 addition & 1 deletion src/treq/test/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from io import BytesIO

from multipart import MultipartParser
from multipart import MultipartParser # type: ignore
from twisted.trial import unittest
from zope.interface.verify import verifyObject

Expand Down

0 comments on commit 852e343

Please sign in to comment.