1
- """ Functions related to Insiders funding goals."""
1
+ # Functions related to Insiders funding goals.
2
2
3
3
from __future__ import annotations
4
4
@@ -23,7 +23,7 @@ if TYPE_CHECKING:
23
23
logger = logging.getLogger(f"mkdocs.logs.{__name__}")
24
24
25
25
26
- def human_readable_amount(amount: int) -> str: # noqa: D103
26
+ def human_readable_amount(amount: int) -> str:
27
27
str_amount = str(amount)
28
28
if len(str_amount) >= 4: # noqa: PLR2004
29
29
return f"{str_amount[: len(str_amount) - 3]},{str_amount[-3:]}"
@@ -32,16 +32,12 @@ def human_readable_amount(amount: int) -> str: # noqa: D103
32
32
33
33
@dataclass
34
34
class Project:
35
- """Class representing an Insiders project."""
36
-
37
35
name: str
38
36
url: str
39
37
40
38
41
39
@dataclass
42
40
class Feature:
43
- """Class representing an Insiders feature."""
44
-
45
41
name: str
46
42
ref: str | None
47
43
since: date | None
@@ -68,8 +64,6 @@ class Feature:
68
64
69
65
@dataclass
70
66
class Goal:
71
- """Class representing an Insiders goal."""
72
-
73
67
name: str
74
68
amount: int
75
69
features: list[Feature]
@@ -96,16 +90,6 @@ class Goal:
96
90
97
91
98
92
def load_goals(data: str, funding: int = 0, project: Project | None = None) -> dict[int, Goal]:
99
- """Load goals from JSON data.
100
-
101
- Parameters:
102
- data: The JSON data.
103
- funding: The current total funding, per month.
104
- origin: The origin of the data (URL).
105
-
106
- Returns:
107
- A dictionaries of goals, keys being their target monthly amount.
108
- """
109
93
goals_data = yaml.safe_load(data)["goals"]
110
94
return {
111
95
amount: Goal(
@@ -153,15 +137,6 @@ def _load_goals(source: str | tuple[str, str, str], funding: int = 0) -> dict[in
153
137
154
138
155
139
def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int = 0) -> dict[int, Goal]:
156
- """Load funding goals from a given data source.
157
-
158
- Parameters:
159
- source: The data source (local file path or URL).
160
- funding: The current total funding, per month.
161
-
162
- Returns:
163
- A dictionaries of goals, keys being their target monthly amount.
164
- """
165
140
if isinstance(source, str):
166
141
return _load_goals_from_disk(source, funding)
167
142
goals = {}
@@ -176,18 +151,10 @@ def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int =
176
151
177
152
178
153
def feature_list(goals: Iterable[Goal]) -> list[Feature]:
179
- """Extract feature list from funding goals.
180
-
181
- Parameters:
182
- goals: A list of funding goals.
183
-
184
- Returns:
185
- A list of features.
186
- """
187
154
return list(chain.from_iterable(goal.features for goal in goals))
188
155
189
156
190
- def load_json(url: str) -> str | list | dict: # noqa: D103
157
+ def load_json(url: str) -> str | list | dict:
191
158
with urlopen(url) as response: # noqa: S310
192
159
return json.loads(response.read().decode())
193
160
0 commit comments