11import logging
22import re
33from collections import defaultdict
4- from typing import Dict , Iterable , List , Optional , TextIO , Tuple
4+ from collections .abc import Iterable
5+ from typing import Optional , TextIO
56
67from bibx ._entities .article import Article
78from bibx ._entities .collection import Collection
@@ -18,7 +19,7 @@ def _size(file) -> int:
1819 return size
1920
2021
21- def _int_or_nothing (raw : Optional [List [str ]]) -> Optional [int ]:
22+ def _int_or_nothing (raw : Optional [list [str ]]) -> Optional [int ]:
2223 if not raw :
2324 return None
2425 try :
@@ -27,7 +28,7 @@ def _int_or_nothing(raw: Optional[List[str]]) -> Optional[int]:
2728 return None
2829
2930
30- def _joined (raw : Optional [List [str ]]) -> Optional [str ]:
31+ def _joined (raw : Optional [list [str ]]) -> Optional [str ]:
3132 if not raw :
3233 return None
3334 return " " .join (raw )
@@ -48,7 +49,7 @@ def _get_articles_from_files(self) -> Iterable[Article]:
4849 yield from self ._parse_file (file )
4950
5051 @staticmethod
51- def _find_volume_info (ref : str ) -> Tuple [ Dict [str , str ], str ]:
52+ def _find_volume_info (ref : str ) -> tuple [ dict [str , str ], str ]:
5253 volume_pattern = re .compile (r"(?P<volume>\d+)( \((?P<issue>.+?)\))?" )
5354 page_pattern = re .compile (r"(pp?\. (?P<page>\w+)(-[^,\s]+)?)" )
5455 page = page_pattern .search (ref )
@@ -79,7 +80,7 @@ def _find_volume_info(ref: str) -> Tuple[Dict[str, str], str]:
7980 return data , ref [last_index :]
8081
8182 @staticmethod
82- def _find_doi (ref : str ) -> Tuple [Optional [str ], str ]:
83+ def _find_doi (ref : str ) -> tuple [Optional [str ], str ]:
8384 pattern = re .compile (
8485 r"((doi.org\/)|(aps.org\/doi\/)|(DOI:?)) ?(?P<doi>[^\s,;:]{5,})" , re .I
8586 )
@@ -113,7 +114,7 @@ def _article_form_reference(cls, scopusref: str) -> Article:
113114 )
114115
115116 @classmethod
116- def _parse_references (cls , refs : List [str ]) -> List [Article ]:
117+ def _parse_references (cls , refs : list [str ]) -> list [Article ]:
117118 if not refs :
118119 return []
119120 result = []
@@ -125,7 +126,7 @@ def _parse_references(cls, refs: List[str]) -> List[Article]:
125126 return result
126127
127128 @staticmethod
128- def _ris_to_dict (record : str ) -> Dict [str , List [str ]]:
129+ def _ris_to_dict (record : str ) -> dict [str , list [str ]]:
129130 RIS_PATTERN = re .compile (
130131 r"^(((?P<key>[A-Z0-9]{2}))[ ]{2}-[ ]{1})?(?P<value>(.*))$"
131132 )
@@ -177,7 +178,7 @@ def _article_from_record(cls, record: str) -> Article:
177178 @classmethod
178179 def _parse_file (cls , file : TextIO ) -> Iterable [Article ]:
179180 if not _size (file ):
180- return []
181+ return
181182 for item in file .read ().split ("\n \n " ):
182183 if item .isspace ():
183184 continue
0 commit comments