Skip to content

Commit

Permalink
Fix generic types.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkrupinski committed Aug 25, 2024
1 parent 68e04f3 commit 84c500d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mimeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__license__ = 'MIT License'
__credits__ = ''

from collections.abc import Generator, Iterable
from typing import Dict, Generator, Iterable, Tuple


class MimeTypeParseException(ValueError):
Expand All @@ -28,7 +28,7 @@ def _parseparam(s: str) -> Generator[str, None, None]:

# Vendored version of cgi.parse_header from Python 3.11 (deprecated and slated
# for removal in 3.13)
def _parse_header(line: str) -> tuple[str, dict[str, str]]:
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 All @@ -49,7 +49,7 @@ def _parse_header(line: str) -> tuple[str, dict[str, str]]:
return key, pdict


def parse_mime_type(mime_type: str) -> tuple[str, str, dict[str, str]]:
def parse_mime_type(mime_type: str) -> Tuple[str, str, Dict[str, str]]:
"""Parses a mime-type into its component parts.
Carves up a mime-type and returns a tuple of the (type, subtype, params)
Expand All @@ -75,7 +75,7 @@ def parse_mime_type(mime_type: str) -> tuple[str, str, dict[str, str]]:
return (type.strip(), subtype.strip(), params)


def parse_media_range(range: str) -> tuple[str, str, dict[str, str]]:
def parse_media_range(range: str) -> Tuple[str, str, Dict[str, str]]:
"""Parse a media-range into its component parts.
Carves up a media range and returns a tuple of the (type, subtype,
Expand All @@ -102,8 +102,8 @@ def parse_media_range(range: str) -> tuple[str, str, dict[str, str]]:

def quality_and_fitness_parsed(
mime_type: str,
parsed_ranges: Iterable[tuple[str, str, dict[str, str]]],
) -> tuple[float, float]:
parsed_ranges: Iterable[Tuple[str, str, Dict[str, str]]],
) -> Tuple[float, float]:
"""Find the best match for a mime-type amongst parsed media-ranges.
Find the best match for a given mime-type against a list of media_ranges
Expand Down Expand Up @@ -150,7 +150,7 @@ def quality_and_fitness_parsed(
return float(best_fit_q), best_fitness


def quality_parsed(mime_type: str, parsed_ranges: Iterable[tuple[str, str, dict[str, str]]]) -> float:
def quality_parsed(mime_type: str, parsed_ranges: Iterable[Tuple[str, str, Dict[str, str]]]) -> float:
"""Find the best match for a mime-type amongst parsed media-ranges.
Find the best match for a given mime-type against a list of media_ranges
Expand Down

0 comments on commit 84c500d

Please sign in to comment.