Skip to content

Commit 85779b7

Browse files
authored
Update supported versions (#29)
* Update supported versions * Update minimum required version * Modernize code * Modernize code * Ignore lock * Update ruff and mypy
1 parent fa5f683 commit 85779b7

File tree

17 files changed

+57
-54
lines changed

17 files changed

+57
-54
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: astral-sh/setup-uv@v2
2121
with:
2222
enable-cache: true
23-
version: "0.4.9"
23+
version: "0.5.7"
2424

2525
- name: Install dependencies
2626
run: |

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
name: CI for ${{ matrix.python-version }}
1414
runs-on: ubuntu-latest
1515
env:
16-
USING_COVERAGE: "3.8,3.12"
16+
USING_COVERAGE: "3.9,3.13"
1717

1818
strategy:
1919
matrix:
20-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2121

2222
steps:
2323
- uses: actions/checkout@v4
@@ -30,7 +30,7 @@ jobs:
3030
uses: astral-sh/setup-uv@v2
3131
with:
3232
enable-cache: true
33-
version: "0.4.9"
33+
version: "0.5.7"
3434

3535
- name: Run tests for ${{ matrix.python-version }}
3636
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@ cython_debug/
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
.idea/
161161
*.xlsx
162+
uv.lock

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ repos:
77
- id: check-yaml
88
- repo: https://github.com/astral-sh/ruff-pre-commit
99
# Ruff version.
10-
rev: v0.3.3
10+
rev: v0.8.2
1111
hooks:
1212
# Run the linter.
1313
- id: ruff
1414
args: [ --fix ]
1515
# Run the formatter.
1616
- id: ruff-format
1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: 'v1.9.0'
18+
rev: 'v1.13.0'
1919
hooks:
2020
- id: mypy

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies = [
1818
"typer[all]~=0.9.0",
1919
"xlsxwriter~=3.2.0",
2020
]
21-
requires-python = ">=3.8"
21+
requires-python = ">=3.9"
2222

2323

2424
[project.optional-dependencies]
@@ -33,7 +33,7 @@ dev = [
3333
bibx = "bibx.cli:app"
3434

3535
[tool.ruff.lint]
36-
select = ["I", "E", "F", "W"]
36+
select = ["I", "E", "F", "UP", "W"]
3737
ignore = ["E501"]
3838

3939
[tool.mypy]

src/bibx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"read_any",
2222
]
2323

24-
__version__ = "0.1.1"
24+
__version__ = "0.2.0"
2525

2626

2727
def read_scopus_bib(*files: TextIO) -> Collection:

src/bibx/_entities/article.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from collections.abc import Mapping
12
from dataclasses import dataclass, field
2-
from typing import List, Mapping, Optional, Set
3+
from typing import Optional
34

45

56
@dataclass
67
class Article:
7-
authors: List[str] = field(default_factory=list)
8+
authors: list[str] = field(default_factory=list)
89
year: Optional[int] = None
910
title: Optional[str] = None
1011
journal: Optional[str] = None
@@ -14,9 +15,9 @@ class Article:
1415
doi: Optional[str] = None
1516
_label: Optional[str] = None
1617
times_cited: Optional[int] = None
17-
references: List["Article"] = field(default_factory=list)
18-
keywords: List[str] = field(default_factory=list)
19-
sources: Set[str] = field(default_factory=set)
18+
references: list["Article"] = field(default_factory=list)
19+
keywords: list[str] = field(default_factory=list)
20+
sources: set[str] = field(default_factory=set)
2021
extra: Mapping = field(default_factory=dict)
2122

2223
@property

src/bibx/_entities/collection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
import logging
3+
from collections.abc import Iterable
34
from dataclasses import dataclass
4-
from typing import Dict, Iterable, List, Tuple
55

66
from bibx._entities.article import Article
77

@@ -10,7 +10,7 @@
1010

1111
@dataclass
1212
class Collection:
13-
articles: List[Article]
13+
articles: list[Article]
1414

1515
def merge(self, other: "Collection") -> "Collection":
1616
"""
@@ -38,7 +38,7 @@ def all_articles(self) -> Iterable[Article]:
3838
yield from cache.values()
3939

4040
@property
41-
def citation_pairs(self) -> Iterable[Tuple[Article, Article]]:
41+
def citation_pairs(self) -> Iterable[tuple[Article, Article]]:
4242
cache = {article.key: article for article in self.articles}
4343
for article in self.articles:
4444
if not article.references:
@@ -62,7 +62,7 @@ def _first_year(self) -> int:
6262
[article.year for article in self.articles if article.year is not None]
6363
)
6464

65-
def published_by_year(self) -> Dict[int, int]:
65+
def published_by_year(self) -> dict[int, int]:
6666
"""
6767
Returns a dictionary where the key is the year of publication and the value is the number of articles
6868
published that year. The dictionary starts from the oldest article to the current year consecutively.
@@ -84,7 +84,7 @@ def published_by_year(self) -> Dict[int, int]:
8484
years[article.year] = 1
8585
return years
8686

87-
def cited_by_year(self) -> Dict[int, int]:
87+
def cited_by_year(self) -> dict[int, int]:
8888
"""
8989
Returns a dictionary where the key is the year of publication and the value is the number of
9090
citations in that year. The dictionary starts from the oldest article to the current year consecutively.

src/bibx/_entities/collection_builders/scopus_bib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import json
22
import re
3+
from collections.abc import Iterable
34
from contextlib import suppress
4-
from typing import Iterable, Optional, TextIO
5+
from typing import Optional, TextIO
56

67
import bibtexparser
78

src/bibx/_entities/collection_builders/scopus_ris.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
22
import re
33
from 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

67
from bibx._entities.article import Article
78
from 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

Comments
 (0)