44__license__ = 'MIT License'
55__credits__ = ''
66
7- from typing import Dict , Generator , Iterable , Tuple
7+ from typing import Dict , Generator , Iterable , Tuple , Union
88
99
1010class MimeTypeParseException (ValueError ):
@@ -90,7 +90,7 @@ def parse_media_range(range: str) -> Tuple[str, str, Dict[str, str]]:
9090 necessary.
9191 """
9292 (type , subtype , params ) = parse_mime_type (range )
93- params .setdefault ('q' , params .pop ('Q' , None )) # q is case insensitive
93+ params .setdefault ('q' , params .pop ('Q' , '1' )) # q is case insensitive
9494 try :
9595 if not params ['q' ] or not 0 <= float (params ['q' ]) <= 1 :
9696 params ['q' ] = '1'
@@ -112,8 +112,8 @@ def quality_and_fitness_parsed(
112112 match, or (-1, 0) if no match was found. Just as for quality_parsed(),
113113 'parsed_ranges' must be a list of parsed media ranges.
114114 """
115- best_fitness = - 1
116- best_fit_q = 0
115+ best_fitness = - 1.
116+ best_fit_q : Union [ float , str ] = 0.
117117 (target_type , target_subtype , target_params ) = \
118118 parse_media_range (mime_type )
119119
@@ -128,10 +128,10 @@ def quality_and_fitness_parsed(
128128 if type_match and subtype_match :
129129
130130 # 100 points if the type matches w/o a wildcard
131- fitness = type == target_type and 100 or 0
131+ fitness = type == target_type and 100. or 0.
132132
133133 # 10 points if the subtype matches w/o a wildcard
134- fitness += subtype == target_subtype and 10 or 0
134+ fitness += subtype == target_subtype and 10. or 0.
135135
136136 # 1 bonus point for each matching param besides "q"
137137 param_matches = sum ([
0 commit comments