Skip to content

Commit

Permalink
🐛 no duplicated warnings (merge #66)
Browse files Browse the repository at this point in the history
  • Loading branch information
j1g5awi committed Feb 16, 2024
2 parents a44c87a + b347e23 commit 89c6c58
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Run Pytest
run: |
cd tests/
pdm run pytest -n auto --cov=nonebot/adapters/telegram --cov-report xml
pdm run pytest -n auto --cov-report xml
- name: Upload coverage report
uses: codecov/codecov-action@v3
Expand Down
8 changes: 4 additions & 4 deletions nonebot/adapters/telegram/adapter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import asyncio
from typing_extensions import override
from typing import Any, Dict, List, Tuple, Union, Iterable, Optional, cast

import anyio
from pydantic.main import BaseModel
from nonebot.typing import overrides
from pydantic.json import pydantic_encoder
from nonebot.utils import escape_tag, logger_wrapper
from nonebot.drivers import URL, Driver, Request, Response, HTTPServerSetup
Expand All @@ -26,15 +26,15 @@ def _escape_none(data: Dict[str, Any]) -> Dict[str, Any]:


class Adapter(BaseAdapter):
@overrides(BaseAdapter)
@override
def __init__(self, driver: Driver, **kwargs: Any):
super().__init__(driver, **kwargs)
self.adapter_config = AdapterConfig(**self.config.model_dump())
self.tasks: List[asyncio.Task] = []
self.setup()

@classmethod
@overrides(BaseAdapter)
@override
def get_name(cls) -> str:
return "Telegram"

Expand Down Expand Up @@ -143,7 +143,7 @@ def setup(self) -> None:
else:
self.setup_polling(bot)

@overrides(BaseAdapter)
@override
async def _call_api(self, bot: Bot, api: str, **data) -> Any:
# 将方法名称改为驼峰式
api = api.split("_", maxsplit=1)[0] + "".join(
Expand Down
4 changes: 2 additions & 2 deletions nonebot/adapters/telegram/bot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import inspect
from uuid import uuid4
from functools import partial
from typing_extensions import override
from typing import Any, List, Union, Optional, Sequence, cast

from pydantic import TypeAdapter
from nonebot.typing import overrides
from nonebot.message import handle_event

from nonebot.adapters import Adapter
Expand Down Expand Up @@ -288,7 +288,7 @@ async def send_to(
**kwargs,
)

@overrides(BaseBot)
@override
async def send(
self,
event: Event,
Expand Down
14 changes: 5 additions & 9 deletions nonebot/adapters/telegram/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import Field, BaseModel
from pydantic import Field, BaseModel, ConfigDict


class BotConfig(BaseModel):
Expand All @@ -18,10 +18,6 @@ class BotConfig(BaseModel):
api_server: str = "https://api.telegram.org/"
is_webhook: bool = False

class Config:
extra = "ignore"
allow_population_by_field_name = True


class AdapterConfig(BaseModel):
"""
Expand All @@ -37,7 +33,7 @@ class AdapterConfig(BaseModel):
proxy: Optional[str] = Field(default=None, alias="telegram_proxy")
telegram_bots: List["BotConfig"] = []
telegram_webhook_url: Optional[str] = None

class Config:
extra = "ignore"
allow_population_by_field_name = True
model_config: ConfigDict = ConfigDict(
extra="ignore",
populate_by_name=True,
)
Loading

0 comments on commit 89c6c58

Please sign in to comment.