Skip to content

Commit

Permalink
Drop support for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-E-Rose committed Nov 14, 2024
1 parent 675afeb commit 9cfdac3
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 97 deletions.
6 changes: 3 additions & 3 deletions pybliometrics/sciencedirect/article_metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
from typing import List, NamedTuple, Optional, Tuple, Union
from typing import Optional, Union

from pybliometrics.superclasses import Search
from pybliometrics.utils import check_field_consistency, chained_get, \
Expand All @@ -9,7 +9,7 @@

class ArticleMetadata(Search):
@property
def results(self) -> Optional[List[NamedTuple]]:
def results(self) -> Optional[list[namedtuple]]:
"""A list of namedtuples in the form `(authorKeywords authors available_online_date
first_author abstract_text doi title eid link openArchiveArticle openaccess_status
openaccessArticle openaccessUserLicense pii aggregationType copyright coverDate
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(self,
view: str = None,
verbose: bool = False,
download: bool = True,
integrity_fields: Union[List[str], Tuple[str, ...]] = None,
integrity_fields: Union[list[str], tuple[str, ...]] = None,
integrity_action: str = "raise",
subscriber: bool = True,
**kwds: str
Expand Down
6 changes: 3 additions & 3 deletions pybliometrics/sciencedirect/sciencedirect_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
from typing import List, NamedTuple, Optional, Tuple, Union
from typing import Optional, Union

from pybliometrics.superclasses import Search
from pybliometrics.utils import check_field_consistency, chained_get, \
Expand All @@ -9,7 +9,7 @@

class ScienceDirectSearch(Search):
@property
def results(self) -> Optional[List[NamedTuple]]:
def results(self) -> Optional[list[namedtuple]]:
"""A list of namedtuples in the form `(authors first_author doi title link
load_date openaccess_status pii coverDate endingPage publicationName startingPage
api_link volume)`.
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self,
view: Optional[str] = None,
verbose: bool = False,
download: bool = True,
integrity_fields: Optional[Union[List[str], Tuple[str, ...]]] = None,
integrity_fields: Optional[Union[list[str], tuple[str, ...]]] = None,
integrity_action: str = "raise",
subscriber: bool = True,
**kwds: str
Expand Down
42 changes: 21 additions & 21 deletions pybliometrics/scopus/abstract_citation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import namedtuple
from datetime import datetime
from hashlib import md5
from typing import List, NamedTuple, Optional, Tuple, Union
from typing import Optional, Union
from warnings import warn

from pybliometrics.superclasses import Retrieval
Expand All @@ -10,7 +10,7 @@

class CitationOverview(Retrieval):
@property
def authors(self) -> Optional[List[Optional[NamedTuple]]]:
def authors(self) -> Optional[list[Optional[namedtuple]]]:
"""A list of lists of namedtuples storing author information,
where each namedtuple corresponds to one author and each sub-list to
one document.
Expand All @@ -34,7 +34,7 @@ def authors(self) -> Optional[List[Optional[NamedTuple]]]:
return _maybe_return_list(outer)

@property
def cc(self) -> List[List[Tuple[int, int]]]:
def cc(self) -> list[list[tuple[int, int]]]:
"""List of lists of tuples of yearly number of citations for specified
years, where each sub-list corresponds to one document.
"""
Expand All @@ -54,32 +54,32 @@ def cc(self) -> List[List[Tuple[int, int]]]:
return _maybe_return_list(outer)

@property
def citationType_long(self) -> Optional[List[str]]:
def citationType_long(self) -> Optional[list[str]]:
"""Type (long version) of the documents (e.g. article, review)."""
path = ["citationType", "$"]
out = [chained_get(e, path) for e in self._citeInfoMatrix]
return _maybe_return_list(out)

@property
def citationType_short(self) -> Optional[List[str]]:
def citationType_short(self) -> Optional[list[str]]:
"""Type (short version) of the documents (e.g. ar, re)."""
path = ["citationType", "@code"]
out = [chained_get(e, path) for e in self._citeInfoMatrix]
return _maybe_return_list(out)

@property
def columnTotal(self) -> int:
def columnTotal(self) -> list[int]:
"""The yearly number of citations for all documents combined."""
return [int(d["$"]) for d in self._citeCountHeader["columnTotal"]]

@property
def doi(self) -> Optional[List[str]]:
def doi(self) -> Optional[list[str]]:
"""Document Object Identifier (DOI) of the documents."""
out = [e.get('doi') for e in self._identifierlegend]
return _maybe_return_list(out)

@property
def endingPage(self) -> Optional[List[str]]:
def endingPage(self) -> Optional[list[str]]:
"""Ending pages of the documents."""
out = [e.get('endingPage') for e in self._citeInfoMatrix]
return _maybe_return_list(out)
Expand All @@ -95,7 +95,7 @@ def h_index(self) -> int:
return int(self._data['h-index'])

@property
def issn(self) -> Optional[List[Optional[Union[str, Tuple[str, str]]]]]:
def issn(self) -> Optional[list[Optional[Union[str, tuple[str, str]]]]]:
"""ISSN of the publishers of the documents.
Note: If E-ISSN is known to Scopus, this returns both
ISSN and E-ISSN in random order separated by blank space.
Expand All @@ -104,7 +104,7 @@ def issn(self) -> Optional[List[Optional[Union[str, Tuple[str, str]]]]]:
return _maybe_return_list(out)

@property
def issueIdentifier(self) -> Optional[List[Optional[str]]]:
def issueIdentifier(self) -> Optional[list[Optional[str]]]:
"""Issue numbers of the documents."""
out = [e.get('issueIdentifier') for e in self._citeInfoMatrix]
return _maybe_return_list(out)
Expand All @@ -117,17 +117,17 @@ def laterColumnTotal(self) -> int:
return int(self._citeCountHeader["laterColumnTotal"])

@property
def lcc(self) -> List[int]:
def lcc(self) -> list[int]:
"""Number of citations after the end year of each document."""
return [int(m['lcc']) for m in self._citeInfoMatrix]

@property
def pcc(self) -> int:
def pcc(self) -> list[int]:
"""Number of citations before the start year."""
return [int(m['pcc']) for m in self._citeInfoMatrix]

@property
def pii(self) -> Optional[List[Optional[str]]]:
def pii(self) -> Optional[list[Optional[str]]]:
"""The Publication Item Identifier (PII) of the documents."""
out = [e.get('pii') for e in self._identifierlegend]
return _maybe_return_list(out)
Expand All @@ -147,45 +147,45 @@ def rangeColumnTotal(self) -> int:
return int(self._citeCountHeader["rangeColumnTotal"])

@property
def rangeCount(self) -> List[int]:
def rangeCount(self) -> list[int]:
"""Total citation count over the specified year range for
each document.
"""
return [int(e['rangeCount']) for e in self._citeInfoMatrix]

@property
def rowTotal(self) -> List[int]:
def rowTotal(self) -> list[int]:
"""Total number of citations (specified and omitted years) for each
document.
"""
return [int(e['rowTotal']) for e in self._citeInfoMatrix]

@property
def scopus_id(self) -> List[int]:
def scopus_id(self) -> list[int]:
"""The Scopus ID(s) of the documents. Might differ from the
ones provided.
"""
return [int(e['scopus_id']) for e in self._identifierlegend]

@property
def sortTitle(self) -> Optional[List[Optional[str]]]:
def sortTitle(self) -> Optional[list[Optional[str]]]:
"""Name of source the documents are published in (e.g. the Journal)."""
out = [e.get('sortTitle') for e in self._citeInfoMatrix]
return _maybe_return_list(out)

@property
def startingPage(self) -> Optional[List[Optional[str]]]:
def startingPage(self) -> Optional[list[Optional[str]]]:
"""Starting page."""
out = [e.get('startingPage') for e in self._citeInfoMatrix]
return _maybe_return_list(out)

@property
def title(self) -> List[str]:
def title(self) -> list[str]:
"""Titles of each document."""
return [e["title"] for e in self._citeInfoMatrix]

@property
def url(self) -> List[str]:
def url(self) -> list[str]:
"""URL(s) to Citation Overview API view of each document."""
return [e["url"] for e in self._citeInfoMatrix]

Expand All @@ -196,7 +196,7 @@ def volume(self) -> Optional[str]:
return _maybe_return_list(out)

def __init__(self,
identifier: List[Union[int, str]],
identifier: list[Union[int, str]],
date: Optional[str] = None,
start: Optional[Union[int, str]] = None,
end: Optional[Union[int, str]] = None,
Expand Down
36 changes: 18 additions & 18 deletions pybliometrics/scopus/abstract_retrieval.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import defaultdict, namedtuple
from typing import List, NamedTuple, Optional, Tuple, Union
from typing import Optional, Union

from pybliometrics.superclasses import Retrieval
from pybliometrics.utils import chained_get, check_parameter_value, \
Expand All @@ -16,7 +16,7 @@ def abstract(self) -> Optional[str]:
return self._head.get('abstracts')

@property
def affiliation(self) -> Optional[List[NamedTuple]]:
def affiliation(self) -> Optional[list[namedtuple]]:
"""A list of namedtuples representing listed affiliations in
the form `(id, name, city, country)`.
"""
Expand All @@ -36,7 +36,7 @@ def aggregationType(self) -> str:
return chained_get(self._json, ['coredata', 'prism:aggregationType'])

@property
def authkeywords(self) -> Optional[List[str]]:
def authkeywords(self) -> Optional[list[str]]:
"""List of author-provided keywords of the document."""
keywords = self._json.get('authkeywords')
if not keywords:
Expand All @@ -48,7 +48,7 @@ def authkeywords(self) -> Optional[List[str]]:
return [keywords['author-keyword']['$']]

@property
def authorgroup(self) -> Optional[List[NamedTuple]]:
def authorgroup(self) -> Optional[list[namedtuple]]:
"""A list of namedtuples representing the article's authors and collaborations
organized by affiliation, in the form `(affiliation_id, collaboration_id, dptid,
organization, city, postalcode, addresspart, country, auid, orcid,
Expand Down Expand Up @@ -102,7 +102,7 @@ def authorgroup(self) -> Optional[List[NamedTuple]]:
return out or None

@property
def authors(self) -> Optional[List[NamedTuple]]:
def authors(self) -> Optional[list[namedtuple]]:
"""A list of namedtuples representing the article's authors, in the
form `(auid, indexed_name, surname, given_name, affiliation)`. In case
multiple affiliation IDs are given, they are joined on `";"`.
Expand Down Expand Up @@ -137,7 +137,7 @@ def citedby_link(self) -> str:
return get_link(self._json, 2)

@property
def chemicals(self) -> Optional[List[NamedTuple]]:
def chemicals(self) -> Optional[list[namedtuple]]:
"""List of namedtuples representing chemical entities in the form
`(source, chemical_name, cas_registry_number)`. In case multiple
numbers given, they are joined on `";"`.
Expand Down Expand Up @@ -165,7 +165,7 @@ def confcode(self) -> Optional[int]:
return make_int_if_possible(self._confevent.get('confcode'))

@property
def confdate(self) -> Optional[Tuple[Tuple[int, int], Tuple[int, int]]]:
def confdate(self) -> Optional[tuple[int, int], tuple[int, int]]:
"""Date range of the conference the document belongs to represented
by two tuples in the form (YYYY, MM, DD).
"""
Expand All @@ -189,7 +189,7 @@ def confname(self) -> Optional[str]:
return self._confevent.get('confname')

@property
def confsponsor(self) -> Optional[Union[List[str], str]]:
def confsponsor(self) -> Optional[Union[list[str], str]]:
"""Sponsor(s) of the conference the document belongs to."""
path = ['confsponsors', 'confsponsor']
sponsors = chained_get(self._confevent, path, [])
Expand All @@ -200,7 +200,7 @@ def confsponsor(self) -> Optional[Union[List[str], str]]:
return sponsors

@property
def contributor_group(self) -> Optional[List[NamedTuple]]:
def contributor_group(self) -> Optional[list[namedtuple]]:
"""List of namedtuples representing contributors compiled by Scopus,
in the form `(given_name, initials, surname, indexed_name, role)`.
"""
Expand Down Expand Up @@ -231,7 +231,7 @@ def copyright_type(self) -> str:
return chained_get(self._json, path)

@property
def correspondence(self) -> Optional[List[NamedTuple]]:
def correspondence(self) -> Optional[list[namedtuple]]:
"""List of namedtuples representing the authors to whom correspondence
should be addressed, in the form ´(surname, initials, organization,
country, city_group)´. Multiple organziations are joined on semicolon.
Expand Down Expand Up @@ -263,7 +263,7 @@ def coverDate(self) -> str:
return chained_get(self._json, ['coredata', 'prism:coverDate'])

@property
def date_created(self) -> Optional[Tuple[int, int, int]]:
def date_created(self) -> Optional[tuple[int, int, int]]:
"""Return the `date_created` of a record.
"""
path = ["item", "bibrecord", "item-info", "history"]
Expand Down Expand Up @@ -309,7 +309,7 @@ def endingPage(self) -> Optional[str]:
return ending

@property
def funding(self) -> Optional[List[NamedTuple]]:
def funding(self) -> Optional[list[namedtuple]]:
"""List of namedtuples parsed funding information in the form
`(agency, agency_id, string, funding_id, acronym, country)`.
"""
Expand Down Expand Up @@ -343,7 +343,7 @@ def funding_text(self) -> Optional[str]:
return chained_get(self._json, path)

@property
def isbn(self) -> Optional[Tuple[str, ...]]:
def isbn(self) -> Optional[tuple[str, ...]]:
"""ISBNs `Optional[str]` to publicationName as tuple of variying length,
(e.g. ISBN-10 or ISBN-13)."""
isbns = listify(chained_get(self._head, ['source', 'isbn'], []))
Expand All @@ -353,7 +353,7 @@ def isbn(self) -> Optional[Tuple[str, ...]]:
return tuple((i['$'] for i in isbns))

@property
def issn(self) -> Optional[NamedTuple]:
def issn(self) -> Optional[namedtuple]:
"""Namedtuple in the form `(print electronic)`.
Note: If the source has an E-ISSN, the META view will return None.
Use FULL view instead.
Expand Down Expand Up @@ -393,7 +393,7 @@ def identifier(self) -> int:
return get_id(self._json)

@property
def idxterms(self) -> Optional[List[str]]:
def idxterms(self) -> Optional[list[str]]:
"""List of index terms (these are just one category of those
Scopus provides in the web version)
."""
Expand Down Expand Up @@ -494,7 +494,7 @@ def refcount(self) -> Optional[int]:
return None

@property
def references(self) -> Optional[List[NamedTuple]]:
def references(self) -> Optional[list[namedtuple]]:
"""List of namedtuples representing references listed in the document,
in the form `(position, id, doi, title, authors, authors_auid,
authors_affiliationid, sourcetitle, publicationyear, coverDate, volume,
Expand Down Expand Up @@ -589,7 +589,7 @@ def self_link(self) -> str:
return get_link(self._json, 0)

@property
def sequencebank(self) -> Optional[List[NamedTuple]]:
def sequencebank(self) -> Optional[list[namedtuple]]:
"""List of namedtuples representing biological entities defined or
mentioned in the text, in the form `(name, sequence_number, type)`.
"""
Expand Down Expand Up @@ -636,7 +636,7 @@ def startingPage(self) -> Optional[str]:
return starting

@property
def subject_areas(self) -> Optional[List[NamedTuple]]:
def subject_areas(self) -> Optional[list[namedtuple]]:
"""List of namedtuples containing subject areas of the article
in the form `(area abbreviation code)`.
Note: Requires the FULL view of the article.
Expand Down
Loading

0 comments on commit 9cfdac3

Please sign in to comment.