Skip to content

Commit abeade5

Browse files
authored
rename some modules (#47)
* breaking: rename builders to sources * breaking: rename models * prepare release * Update all the things
1 parent 7b39d14 commit abeade5

File tree

21 files changed

+107
-107
lines changed

21 files changed

+107
-107
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.6.0"
23+
version: "0.8.13"
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.9,3.13"
16+
USING_COVERAGE: "3.11,3.13"
1717

1818
strategy:
1919
matrix:
20-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
20+
python-version: ["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.6.0"
33+
version: "0.8.13"
3434

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

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ dependencies = [
1212
"bibtexparser~=1.4.0",
1313
"networkx~=3.0",
1414
"pydantic~=2.11.7",
15-
"requests~=2.32.3",
16-
"typer~=0.16.0",
15+
"requests~=2.32.5",
16+
"typer~=0.17.3",
1717
]
18-
requires-python = ">=3.9"
18+
requires-python = ">=3.11"
1919
classifiers = [
2020
"Development Status :: 3 - Alpha",
2121
"Intended Audience :: Science/Research",
@@ -39,8 +39,8 @@ dev = [
3939
"pre-commit~=4.3.0",
4040
"ruff~=0.12.11",
4141
"mypy~=1.17.1",
42-
"types-requests>=2.32.0.20241016",
43-
"ipython>=8.18.1",
42+
"types-requests~=2.32.4.20250809",
43+
"ipython~=9.5.0",
4444
]
4545

4646
[project.scripts]
@@ -116,7 +116,7 @@ path = "src/bibx/__init__.py"
116116

117117
[tool.tox]
118118
requires = ["tox>=4.24.2"]
119-
env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"]
119+
env_list = ["3.11", "3.12", "3.13"]
120120

121121
[tool.tox.env_run_base]
122122
deps = [

src/bibx/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
from typing import TextIO
55

66
from bibx.algorithms.sap import Sap
7-
from bibx.article import Article
8-
from bibx.builders.openalex import EnrichReferences, OpenAlexCollectionBuilder
9-
from bibx.builders.scopus_bib import ScopusBibCollectionBuilder
10-
from bibx.builders.scopus_csv import ScopusCsvCollectionBuilder
11-
from bibx.builders.scopus_ris import ScopusRisCollectionBuilder
12-
from bibx.builders.wos import WosCollectionBuilder
13-
from bibx.collection import Collection
147
from bibx.exceptions import BibXError
8+
from bibx.models.article import Article
9+
from bibx.models.collection import Collection
10+
from bibx.sources.openalex import EnrichReferences, OpenAlexSource
11+
from bibx.sources.scopus_bib import ScopusBibSource
12+
from bibx.sources.scopus_csv import ScopusCsvSource
13+
from bibx.sources.scopus_ris import ScopusRisSource
14+
from bibx.sources.wos import WosSource
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -28,7 +28,7 @@
2828
"read_wos",
2929
]
3030

31-
__version__ = "0.7.2"
31+
__version__ = "0.8.0"
3232

3333

3434
def query_openalex(
@@ -37,7 +37,7 @@ def query_openalex(
3737
enrich: EnrichReferences = EnrichReferences.BASIC,
3838
) -> Collection:
3939
"""Query OpenAlex and return a collection."""
40-
return OpenAlexCollectionBuilder(query, limit, enrich=enrich).build()
40+
return OpenAlexSource(query, limit, enrich=enrich).build()
4141

4242

4343
def read_scopus_bib(*files: TextIO) -> Collection:
@@ -46,7 +46,7 @@ def read_scopus_bib(*files: TextIO) -> Collection:
4646
:param files: Scopus bib files open.
4747
:return: the collection
4848
"""
49-
return ScopusBibCollectionBuilder(*files).build()
49+
return ScopusBibSource(*files).build()
5050

5151

5252
def read_scopus_ris(*files: TextIO) -> Collection:
@@ -55,7 +55,7 @@ def read_scopus_ris(*files: TextIO) -> Collection:
5555
:param files: Scopus bib files open.
5656
:return: the collection
5757
"""
58-
return ScopusRisCollectionBuilder(*files).build()
58+
return ScopusRisSource(*files).build()
5959

6060

6161
def read_scopus_csv(*files: TextIO) -> Collection:
@@ -64,7 +64,7 @@ def read_scopus_csv(*files: TextIO) -> Collection:
6464
:param files: Scopus csv files open.
6565
:return: the collection
6666
"""
67-
return ScopusCsvCollectionBuilder(*files).build()
67+
return ScopusCsvSource(*files).build()
6868

6969

7070
def read_wos(*files: TextIO) -> Collection:
@@ -73,7 +73,7 @@ def read_wos(*files: TextIO) -> Collection:
7373
:param files: WoS files open.
7474
:return: the collection
7575
"""
76-
return WosCollectionBuilder(*files).build()
76+
return WosSource(*files).build()
7777

7878

7979
def read_any(file: TextIO) -> Collection:

src/bibx/algorithms/sap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import networkx as nx
55
from networkx.algorithms.community.louvain import louvain_communities
66

7-
from bibx.article import Article
8-
from bibx.collection import Collection
7+
from bibx.models.article import Article
8+
from bibx.models.collection import Collection
99

1010
YEAR = "year"
1111
LEAF = "leaf"

src/bibx/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
read_wos,
1616
)
1717
from bibx.algorithms.sap import Sap
18-
from bibx.builders.openalex import EnrichReferences
18+
from bibx.sources.openalex import EnrichReferences
1919

2020
app = typer.Typer()
2121

src/bibx/clients/openalex.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from concurrent.futures import ThreadPoolExecutor, as_completed, wait
33
from enum import Enum
4-
from typing import Optional, Union
54

65
import requests
76
from pydantic import BaseModel, ValidationError
@@ -29,7 +28,7 @@ class Author(BaseModel):
2928

3029
id: str
3130
display_name: str
32-
orcid: Optional[str] = None
31+
orcid: str | None = None
3332

3433

3534
class WorkAuthorship(BaseModel):
@@ -51,10 +50,10 @@ class WorkKeyword(BaseModel):
5150
class WorkBiblio(BaseModel):
5251
"""Work bibliographic information from the openalex API."""
5352

54-
volume: Optional[str] = None
55-
issue: Optional[str] = None
56-
first_page: Optional[str] = None
57-
last_page: Optional[str] = None
53+
volume: str | None = None
54+
issue: str | None = None
55+
first_page: str | None = None
56+
last_page: str | None = None
5857

5958

6059
class WorkLocationSource(BaseModel):
@@ -69,25 +68,25 @@ class WorkLoacation(BaseModel):
6968
"""Location of the work from the openalex API."""
7069

7170
is_oa: bool
72-
landing_page_url: Optional[str] = None
73-
pdf_url: Optional[str] = None
74-
source: Optional[WorkLocationSource]
71+
landing_page_url: str | None = None
72+
pdf_url: str | None = None
73+
source: WorkLocationSource | None
7574

7675

7776
class Work(BaseModel):
7877
"""A work from the openalex API."""
7978

8079
id: str
8180
ids: dict[str, str]
82-
doi: Optional[str] = None
83-
title: Optional[str] = None
81+
doi: str | None = None
82+
title: str | None = None
8483
publication_year: int
8584
authorships: list[WorkAuthorship]
8685
cited_by_count: int
8786
keywords: list[WorkKeyword]
8887
referenced_works: list[str]
8988
biblio: WorkBiblio
90-
primary_location: Optional[WorkLoacation] = None
89+
primary_location: WorkLoacation | None = None
9190

9291

9392
class ResponseMeta(BaseModel):
@@ -110,8 +109,8 @@ class OpenAlexClient:
110109

111110
def __init__(
112111
self,
113-
base_url: Optional[str] = None,
114-
email: Optional[str] = None,
112+
base_url: str | None = None,
113+
email: str | None = None,
115114
) -> None:
116115
self.base_url = base_url or "https://api.openalex.org"
117116
self.session = requests.Session()
@@ -124,7 +123,7 @@ def __init__(
124123
}
125124
)
126125

127-
def _fetch_works(self, params: dict[str, Union[str, int]]) -> WorkResponse:
126+
def _fetch_works(self, params: dict[str, str | int]) -> WorkResponse:
128127
response = self.session.get(
129128
f"{self.base_url}/works",
130129
params=params,

src/bibx/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Models for the bibx package."""
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections.abc import Mapping
22
from dataclasses import dataclass, field
3-
from typing import Optional, TypeVar, Union
3+
from typing import TypeVar
44

55
T = TypeVar("T")
66

@@ -20,15 +20,15 @@ class Article:
2020
label: str
2121
ids: set[str]
2222
authors: list[str] = field(default_factory=list)
23-
year: Optional[int] = None
24-
title: Optional[str] = None
25-
journal: Optional[str] = None
26-
volume: Optional[str] = None
27-
issue: Optional[str] = None
28-
page: Optional[str] = None
29-
doi: Optional[str] = None
30-
_permalink: Optional[str] = None
31-
times_cited: Optional[int] = None
23+
year: int | None = None
24+
title: str | None = None
25+
journal: str | None = None
26+
volume: str | None = None
27+
issue: str | None = None
28+
page: str | None = None
29+
doi: str | None = None
30+
_permalink: str | None = None
31+
times_cited: int | None = None
3232
references: list["Article"] = field(default_factory=list)
3333
keywords: list[str] = field(default_factory=list)
3434
sources: set[str] = field(default_factory=set)
@@ -61,7 +61,7 @@ def key(self) -> str:
6161
return next(iter(sorted(self.ids)))
6262

6363
@property
64-
def simple_label(self) -> Optional[str]:
64+
def simple_label(self) -> str | None:
6565
"""Return a simple label for the article."""
6666
pieces = {
6767
"AU": self.authors[0].replace(",", "") if self.authors else None,
@@ -76,7 +76,7 @@ def simple_label(self) -> Optional[str]:
7676
return ", ".join(value for value in pieces.values() if value)
7777

7878
@property
79-
def permalink(self) -> Optional[str]:
79+
def permalink(self) -> str | None:
8080
"""Return the permalink of the article."""
8181
if self._permalink is not None:
8282
return self._permalink
@@ -85,7 +85,7 @@ def permalink(self) -> Optional[str]:
8585
return None
8686

8787
@property
88-
def simple_id(self) -> Optional[str]:
88+
def simple_id(self) -> str | None:
8989
"""Return a simple ID for the article."""
9090
if not self.authors or self.year is None:
9191
return None
@@ -112,7 +112,7 @@ def set_simple_label(self) -> "Article":
112112

113113
def info(
114114
self,
115-
) -> dict[str, Union[str, int, list[str], None]]:
115+
) -> dict[str, str | int | list[str] | None]:
116116
"""Return a dictionary with the information of the article."""
117117
return {
118118
"permalink": self.permalink,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def published_by_year(self) -> dict[int, int]:
140140
141141
:return: a dictionary with the number of articles published each year.
142142
"""
143-
current_year = datetime.datetime.now(datetime.timezone.utc).year
143+
current_year = datetime.datetime.now(datetime.UTC).year
144144
years = {}
145145
for year in range(self._first_year, current_year + 1):
146146
years[year] = 0
@@ -164,7 +164,7 @@ def cited_by_year(self) -> dict[int, int]:
164164
165165
:return: a dictionary with the number of citations each year.
166166
"""
167-
current_year = datetime.datetime.now(datetime.timezone.utc).year
167+
current_year = datetime.datetime.now(datetime.UTC).year
168168
cited_items_per_year = {}
169169
for year in range(self._first_year, current_year + 1):
170170
cited_items_per_year[year] = 0

0 commit comments

Comments
 (0)