1515import sys
1616import logging
1717from concurrent import futures
18- from typing import Any , Dict , List , Optional , NamedTuple , Tuple
18+ from typing import Any , Optional , NamedTuple
1919import diskcache
2020
2121from dateutil import tz
@@ -60,7 +60,7 @@ class DatedPrice(NamedTuple):
6060 base : Optional [str ]
6161 quote : Optional [str ]
6262 date : Optional [datetime .date ]
63- sources : List [PriceSource ]
63+ sources : list [PriceSource ]
6464
6565
6666# The Python package where the default sources are found.
@@ -102,7 +102,7 @@ def format_dated_price_str(dprice: DatedPrice) -> str:
102102 )
103103
104104
105- def parse_source_map (source_map_spec : str ) -> Dict [str , List [PriceSource ]]:
105+ def parse_source_map (source_map_spec : str ) -> dict [str , list [PriceSource ]]:
106106 """Parse a source map specification string.
107107
108108 Source map specifications allow the specification of multiple sources for
@@ -134,7 +134,7 @@ def parse_source_map(source_map_spec: str) -> Dict[str, List[PriceSource]]:
134134 Raises:
135135 ValueError: If an invalid pattern has been specified.
136136 """
137- source_map : Dict [str , List [PriceSource ]] = collections .defaultdict (list )
137+ source_map : dict [str , list [PriceSource ]] = collections .defaultdict (list )
138138 for source_list_spec in re .split ("[ ;]" , source_map_spec ):
139139 match = re .match ("({}):(.*)$" .format (amount .CURRENCY_RE ), source_list_spec )
140140 if not match :
@@ -202,7 +202,7 @@ def import_source(module_name: str):
202202def find_currencies_declared (
203203 entries : data .Entries ,
204204 date : Optional [datetime .date ] = None ,
205- ) -> List [ Tuple [str , str , List [PriceSource ]]]:
205+ ) -> list [ tuple [str , str , list [PriceSource ]]]:
206206 """Return currencies declared in Commodity directives.
207207
208208 If a 'price' metadata field is provided, include all the quote currencies
@@ -639,8 +639,8 @@ def fetch_price(dprice: DatedPrice, swap_inverted: bool = False) -> Optional[dat
639639
640640
641641def filter_redundant_prices (
642- price_entries : List [data .Price ], existing_entries : List [data .Price ], diffs : bool = False
643- ) -> Tuple [ List [data .Price ], List [data .Price ]]:
642+ price_entries : list [data .Price ], existing_entries : list [data .Price ], diffs : bool = False
643+ ) -> tuple [ list [data .Price ], list [data .Price ]]:
644644 """Filter out new entries that are redundant from an existing set.
645645
646646 If the price differs, we override it with the new entry only on demand. This
@@ -663,8 +663,8 @@ def filter_redundant_prices(
663663 for entry in existing_entries
664664 if isinstance (entry , data .Price )
665665 }
666- filtered_prices : List [data .Price ] = []
667- ignored_prices : List [data .Price ] = []
666+ filtered_prices : list [data .Price ] = []
667+ ignored_prices : list [data .Price ] = []
668668 for entry in price_entries :
669669 key = (entry .date , entry .currency )
670670 if key in existing_prices :
@@ -680,9 +680,9 @@ def filter_redundant_prices(
680680 return filtered_prices , ignored_prices
681681
682682
683- def process_args () -> Tuple [
683+ def process_args () -> tuple [
684684 argparse .Namespace ,
685- List [DatedPrice ],
685+ list [DatedPrice ],
686686 data .Directives ,
687687 Optional [Any ],
688688]:
@@ -887,7 +887,7 @@ def process_args() -> Tuple[
887887 if args .expressions :
888888 # Interpret the arguments as price sources.
889889 for source_str in args .sources :
890- psources : List [PriceSource ] = []
890+ psources : list [PriceSource ] = []
891891 try :
892892 psource_map = parse_source_map (source_str )
893893 except ValueError :
@@ -940,7 +940,7 @@ def process_args() -> Tuple[
940940 )
941941 continue
942942 logging .info ('Loading "%s"' , filename )
943- entries , errors , options_map = loader .load_file (filename , log_errors = sys .stderr )
943+ entries , _errors , options_map = loader .load_file (filename , log_errors = sys .stderr )
944944 if dcontext is None :
945945 dcontext = options_map ["dcontext" ]
946946 for date in dates :
0 commit comments