07.4.4.1.11 — Advanced Trend Quality & EMA Distance Layer
This commit is contained in:
23
app/src/core/numbers.py
Normal file
23
app/src/core/numbers.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# app/src/core/numbers.py
|
||||
|
||||
# src/core/numbers.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from src.core.types import NumericLike
|
||||
|
||||
|
||||
def safe_float(
|
||||
value: object,
|
||||
default: float | None = None,
|
||||
) -> float | None:
|
||||
if value is None:
|
||||
return default
|
||||
|
||||
if isinstance(value, bool):
|
||||
return default
|
||||
|
||||
try:
|
||||
return float(str(value).strip())
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
18
app/src/core/telegram_errors.py
Normal file
18
app/src/core/telegram_errors.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# app/src/core/telegram_errors.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from aiogram.exceptions import TelegramBadRequest
|
||||
|
||||
|
||||
def is_message_not_modified(exc: TelegramBadRequest) -> bool:
|
||||
return "message is not modified" in str(exc).lower()
|
||||
|
||||
|
||||
def is_message_to_edit_not_found(exc: TelegramBadRequest) -> bool:
|
||||
text = str(exc).lower()
|
||||
|
||||
return (
|
||||
"message to edit not found" in text
|
||||
or "message_id_invalid" in text
|
||||
)
|
||||
12
app/src/core/types.py
Normal file
12
app/src/core/types.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# app/src/core/types.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, TypeAlias
|
||||
|
||||
|
||||
NumericLike: TypeAlias = float | int | str
|
||||
|
||||
JsonDict: TypeAlias = dict[str, Any]
|
||||
|
||||
JsonList: TypeAlias = list[Any]
|
||||
Reference in New Issue
Block a user