|
| 1 | +import tomllib |
1 | 2 | from functools import cached_property |
| 3 | +from pathlib import Path |
2 | 4 | from typing import Any |
3 | 5 |
|
4 | 6 | import jwt |
@@ -209,16 +211,25 @@ class Settings(BaseSettings): |
209 | 211 | # If this token is not set, the service will not be able to access the data and no integrity check will be performed |
210 | 212 | MYECLPAY_DATA_VERIFIER_ACCESS_TOKEN: str | None = None |
211 | 213 |
|
212 | | - ################################# |
213 | | - # Hardcoded Hyperion parameters # |
214 | | - ################################# |
| 214 | + # Maximum wallet balance for MyECLPay in cents, we will prevent user from adding more money to their wallet if it will make their balance exceed this value |
215 | 215 |
|
216 | | - # Hyperion follows Semantic Versioning |
217 | | - # https://semver.org/ |
218 | | - HYPERION_VERSION: str = "4.5.1" |
219 | | - MINIMAL_TITAN_VERSION_CODE: int = 139 |
| 216 | + ############################# |
| 217 | + # pyproject.toml parameters # |
| 218 | + ############################# |
220 | 219 |
|
221 | | - # Maximum wallet balance for MyECLPay in cents, we will prevent user from adding more money to their wallet if it will make their balance exceed this value |
| 220 | + @computed_field # type: ignore[prop-decorator] |
| 221 | + @cached_property |
| 222 | + def HYPERION_VERSION(cls) -> str: |
| 223 | + with Path("pyproject.toml").open("rb") as pyproject_binary: |
| 224 | + pyproject = tomllib.load(pyproject_binary) |
| 225 | + return str(pyproject["project"]["version"]) |
| 226 | + |
| 227 | + @computed_field # type: ignore[prop-decorator] |
| 228 | + @cached_property |
| 229 | + def MINIMAL_TITAN_VERSION_CODE(cls) -> str: |
| 230 | + with Path("pyproject.toml").open("rb") as pyproject_binary: |
| 231 | + pyproject = tomllib.load(pyproject_binary) |
| 232 | + return str(pyproject["project"]["minimal-titan-version-code"]) |
222 | 233 |
|
223 | 234 | ###################################### |
224 | 235 | # Automatically generated parameters # |
@@ -374,6 +385,8 @@ def init_cached_property(self) -> "Settings": |
374 | 385 | By calling them in this validator, we force their initialization during the instantiation of the class. |
375 | 386 | This allow them to raise error on Hyperion startup if they are not correctly configured instead of creating an error on runtime. |
376 | 387 | """ |
| 388 | + self.HYPERION_VERSION # noqa: B018 |
| 389 | + self.MINIMAL_TITAN_VERSION_CODE # noqa: B018 |
377 | 390 | self.KNOWN_AUTH_CLIENTS # noqa: B018 |
378 | 391 | self.RSA_PRIVATE_KEY # noqa: B018 |
379 | 392 | self.RSA_PUBLIC_KEY # noqa: B018 |
|
0 commit comments