8000 chore: Template upgrade · AntoineD/mkdocstrings-python@d35f2d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit d35f2d7

Browse files
committed
chore: Template upgrade
1 parent ee59c8c commit d35f2d7

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 0.15.6
2+
_commit: 0.15.7
33
_src_path: gh:pawamoy/copier-pdm
44
author_email: pawamoy@pm.me
55
author_fullname: Timothée Mazzucotelli

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Changelog = "https://mkdocstrings.github.io/python/changelog"
4040
Repository = "https://github.com/mkdocstrings/python"
4141
Issues = "https://github.com/mkdocstrings/python/issues"
4242
Discussions = "https://github.com/mkdocstrings/python/discussions"
43-
Gitter = "https://gitter.im/python/community"
44-
Funding = "https://github.com/sponsors/mkdocstrings"
43+
Gitter = "https://gitter.im/mkdocstrings/python"
44+
Funding = "https://github.com/sponsors/pawamoy"
4545

4646
[tool.pdm]
4747
version = {source = "scm"}

scripts/insiders.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,32 @@ def load_goals(data: str, funding: int = 0, project: Project | None = None) -> d
112112
}
113113

114114

115-
def funding_goals(source: str | list[tuple[str, str, str]], funding: int = 0) -> dict:
115+
def _load_goals_from_disk(path: str, funding: int = 0) -> dict[int, Goal]:
116+
try:
117+
data = Path(path).read_text()
118+
except OSError as error:
119+
raise RuntimeError(f"Could not load data from disk: {path}") from error
120+
return load_goals(data, funding)
121+
122+
123+
def _load_goals_from_url(source_data: tuple[str, str, str], funding: int = 0) -> dict[int, Goal]:
124+
project_name, project_url, data_fragment = source_data
125+
data_url = urljoin(project_url, data_fragment)
126+
try:
127+
with urlopen(data_url) as response: # noqa: S310
128+
data = response.read()
129+
except HTTPError as error:
130+
raise RuntimeError(f"Could not load data from network: {data_url}") from error
131+
return load_goals(data, funding, project=Project(name=project_name, url=project_url))
132+
133+
134+
def _load_goals(source: str | tuple[str, str, str], funding: int = 0) -> dict[int, Goal]:
135+
if isinstance(source, str):
136+
return _load_goals_from_disk(source, funding)
137+
return _load_goals_from_url(source, funding)
138+
139+
140+
def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int = 0) -> dict[int, Goal]:
116141
"""Load funding goals from a given data source.
117142
118143
Parameters:
@@ -123,20 +148,10 @@ def funding_goals(source: str | list[tuple[str, str, str]], funding: int = 0) ->
123148
A dictionaries of goals, keys being their target monthly amount.
124149
"""
125150
if isinstance(source, str):
126-
try:
127-
data = Path(source).read_text()
128-
except OSError as error:
129-
raise RuntimeError(f"Could not load data from disk: {source}") from error
130-
return load_goals(data, funding)
151+
return _load_goals_from_disk(source, funding)
131152
goals = {}
132-
for project_name, project_url, data_fragment in source:
133-
data_url = urljoin(project_url, data_fragment)
134-
try:
135-
with urlopen(data_url) as response: # noqa: S310
136-
data = response.read()
137-
except HTTPError as error:
138-
raise RuntimeError(f"Could not load data from network: {data_url}") from error
139-
source_goals = load_goals(data, funding, project=Project(name=project_name, url=project_url))
153+
for src in source:
154+
source_goals = _load_goals(src)
140155
for amount, goal in source_goals.items():
141156
if amount not in goals:
142157
goals[amount] = goal

0 commit comments

Comments
 (0)
0