Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
refactor: let __init__ import export only
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Dec 24, 2024
1 parent cc058bc commit 8e27ae0
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 32 deletions.
10 changes: 5 additions & 5 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
},
"Telegram": {
"properties": {
"enabled": {
"default": true,
"title": "Enabled",
"type": "boolean"
},
"bot_token": {
"title": "Bot Token",
"type": "string"
Expand All @@ -62,6 +57,11 @@
},
"TelegramNotify": {
"properties": {
"enabled": {
"default": true,
"title": "Enabled",
"type": "boolean"
},
"telegram": {
"$ref": "#/$defs/Telegram"
}
Expand Down
17 changes: 2 additions & 15 deletions src/check_phat_nguoi/models/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
from pydantic import BaseModel, ConfigDict

from check_phat_nguoi.models.config.config import Config
from check_phat_nguoi.models.config.log_level import LogLevel
from check_phat_nguoi.models.config.notify.telegram_notify import TelegramNotify
from check_phat_nguoi.models.config.plate_info import PlateInfo


class Config(BaseModel):
model_config = ConfigDict(use_enum_values=True, validate_default=True)

data: list[PlateInfo] = []
notify: list[TelegramNotify] = []
havent_paid_only: bool = True
detail_log: bool = False
log_level: LogLevel = LogLevel.warning


__all__ = ["Config"]
__all__ = ["PlateInfo", "Config", "LogLevel"]
18 changes: 18 additions & 0 deletions src/check_phat_nguoi/models/config/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pydantic import BaseModel, ConfigDict

from check_phat_nguoi.models.config.log_level import LogLevel
from check_phat_nguoi.models.config.notify.telegram_notify import TelegramNotify
from check_phat_nguoi.models.config.plate_info import PlateInfo


class Config(BaseModel):
model_config = ConfigDict(use_enum_values=True, validate_default=True)

data: list[PlateInfo] = []
notify: list[TelegramNotify] = []
havent_paid_only: bool = True
detail_log: bool = False
log_level: LogLevel = LogLevel.warning


__all__ = ["Config"]
3 changes: 3 additions & 0 deletions src/check_phat_nguoi/models/config/notify/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from check_phat_nguoi.models.config.notify.telegram_notify import TelegramNotify

__all__ = ["TelegramNotify"]
8 changes: 8 additions & 0 deletions src/check_phat_nguoi/models/config/notify/base_notify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pydantic import BaseModel


class BaseNotify(BaseModel):
enabled: bool = True


__all__ = ["BaseNotify"]
1 change: 0 additions & 1 deletion src/check_phat_nguoi/models/config/notify/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Telegram(BaseModel):
enabled: bool = True
bot_token: str
chat_id: str

Expand Down
5 changes: 2 additions & 3 deletions src/check_phat_nguoi/models/config/notify/telegram_notify.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from pydantic import BaseModel

from check_phat_nguoi.models.config.notify.base_notify import BaseNotify
from check_phat_nguoi.models.config.notify.telegram import Telegram


class TelegramNotify(BaseModel):
class TelegramNotify(BaseNotify):
telegram: Telegram


Expand Down
9 changes: 1 addition & 8 deletions src/check_phat_nguoi/models/context/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
from pydantic import BaseModel

from check_phat_nguoi.models.context.plate_info import PlateInfo


class Context(BaseModel):
data: list[PlateInfo] = []

from check_phat_nguoi.models.context.context import Context

__all__ = ["Context"]
10 changes: 10 additions & 0 deletions src/check_phat_nguoi/models/context/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pydantic import BaseModel

from check_phat_nguoi.models.context.plate_info import PlateInfo


class Context(BaseModel):
data: list[PlateInfo] = []


__all__ = ["Context"]

0 comments on commit 8e27ae0

Please sign in to comment.