Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Enable explicit-override in mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
monosans committed Oct 25, 2023
1 parent 07726f6 commit 016a2ae
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ repos:
- aiofile<4
- aiohttp<4
- rich<14
- typing-extensions<5
- uvloop<0.20; implementation_name == "cpython" and (sys_platform == "darwin" or sys_platform == "linux")
3 changes: 3 additions & 0 deletions nitro_generator_checker/nitro_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import string
from typing import Iterator

from typing_extensions import override


class NitroGenerator(Iterator[str]):
__slots__ = ("characters",)

def __init__(self) -> None:
self.characters = string.ascii_letters + string.digits

@override
def __next__(self) -> str:
return "".join(random.choices(self.characters, k=16))
4 changes: 4 additions & 0 deletions nitro_generator_checker/result_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from aiofile import async_open
from aiohttp import ClientSession
from typing_extensions import override

from .utils import sync_to_async

Expand All @@ -28,6 +29,7 @@ def __init__(self, file_path: str) -> None:
self.file_path = file_path
self._ready_event = asyncio.Event()

@override
async def pre_run(self) -> None:
def inner() -> None:
path = Path(self.file_path)
Expand All @@ -39,6 +41,7 @@ def inner() -> None:
await sync_to_async(inner)
self._ready_event.set()

@override
async def save(self, gift_url: str) -> None:
await self._ready_event.wait()
async with async_open(self.file_path, "a", encoding="utf-8") as f:
Expand All @@ -52,6 +55,7 @@ def __init__(self, session: ClientSession, url: str) -> None:
self.session = session
self.url = url

@override
async def save(self, gift_url: str) -> None:
async with self.session.post(
self.url, json={"content": f"@everyone {gift_url}"}
Expand Down
4 changes: 3 additions & 1 deletion nitro_generator_checker/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import asyncio
from typing import Any, Callable, Coroutine, Set, TypeVar
from typing import Callable, Coroutine, Set

from typing_extensions import Any, TypeVar

T = TypeVar("T")

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ disallow_untyped_decorators = false
warn_unreachable = true
local_partial_types = true
enable_error_code = [
"explicit-override",
"redundant-self",
"redundant-expr",
"possibly-undefined",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ aiofile>=3.8,<4
aiohttp-socks>=0.7,<0.9
aiohttp>=3.8,<4
rich>=12.0,<14
typing-extensions>=4.4,<5
uvloop>=0.16,<0.20; implementation_name == "cpython" and (sys_platform == "darwin" or sys_platform == "linux")

0 comments on commit 016a2ae

Please sign in to comment.