diff --git a/setup.py b/setup.py index 4ab335a..be9c820 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ from setuptools import setup setup( - name='v6d2ctx', - version='', - packages=['v6d2ctx', 'v6d2ctx.integration'], - url='', - license='', - author='PARRRATE T&V', - author_email='', - description='' + name="v6d2ctx", + version="", + packages=["v6d2ctx", "v6d2ctx.integration"], + url="", + license="", + author="PARRRATE T&V", + author_email="", + description="", ) diff --git a/v6d2ctx/at_of.py b/v6d2ctx/at_of.py index e01ac74..911f32c 100644 --- a/v6d2ctx/at_of.py +++ b/v6d2ctx/at_of.py @@ -2,11 +2,11 @@ from typing import Callable, Generic, TypeVar from .context import * -__all__ = ('AtOf',) +__all__ = ("AtOf",) -K = TypeVar('K') -V = TypeVar('V') +K = TypeVar("K") +V = TypeVar("V") class AtOf(Generic[K, V]): @@ -17,6 +17,7 @@ class AtOf(Generic[K, V]): def wrap(value: V) -> V: bucket[key] = value return value + return wrap def of(key: K) -> V: diff --git a/v6d2ctx/context.py b/v6d2ctx/context.py index 9832a63..da5a788 100644 --- a/v6d2ctx/context.py +++ b/v6d2ctx/context.py @@ -3,7 +3,7 @@ from typing import Awaitable, Callable, Optional, Union import discord -__all__ = ('usertype', 'Context', 'escape', 'command_type', 'Explicit', 'Implicit') +__all__ = ("usertype", "Context", "escape", "command_type", "Explicit", "Implicit") usertype = Union[discord.abc.User, discord.user.BaseUser, discord.Member, discord.User] @@ -23,7 +23,7 @@ class Context: async def long(self, s: str): resio = StringIO(s) - res = '' + res = "" for line in resio: if len(res) + len(line) < 2000: res += line @@ -34,14 +34,14 @@ class Context: await self.reply(res) -ESCAPED = '`_*\'"\\' +ESCAPED = "`_*'\"\\" def escape(s: str): res = StringIO() for c in s: if c in ESCAPED: - c = '\\' + c + c = "\\" + c res.write(c) return res.getvalue() diff --git a/v6d2ctx/handle_args.py b/v6d2ctx/handle_args.py index c983419..4228eec 100644 --- a/v6d2ctx/handle_args.py +++ b/v6d2ctx/handle_args.py @@ -5,10 +5,12 @@ import discord from v6d2ctx.context import * from v6d2ctx.handle_command import * -__all__ = ('handle_args',) +__all__ = ("handle_args",) -async def handle_args(of: Callable[[str], command_type], message: discord.Message, args: list[str], client: discord.Client): +async def handle_args( + of: Callable[[str], command_type], message: discord.Message, args: list[str], client: discord.Client +): match args: case []: return diff --git a/v6d2ctx/handle_command.py b/v6d2ctx/handle_command.py index 196499b..1424c50 100644 --- a/v6d2ctx/handle_command.py +++ b/v6d2ctx/handle_command.py @@ -2,7 +2,7 @@ from typing import Callable from v6d2ctx.context import * -__all__ = ('handle_command',) +__all__ = ("handle_command",) async def handle_command(of: Callable[[str], command_type], ctx: Context, name: str, args: list[str]) -> None: diff --git a/v6d2ctx/handle_content.py b/v6d2ctx/handle_content.py index 99bfeb5..246eab9 100644 --- a/v6d2ctx/handle_content.py +++ b/v6d2ctx/handle_content.py @@ -6,10 +6,12 @@ import discord from v6d2ctx.context import * from v6d2ctx.handle_args import * -__all__ = ('handle_content',) +__all__ = ("handle_content",) -async def handle_content(of: Callable[[str], command_type], message: discord.Message, content: str, prefix: str, client: discord.Client): +async def handle_content( + of: Callable[[str], command_type], message: discord.Message, content: str, prefix: str, client: discord.Client +): if message.author.bot: return if not content.startswith(prefix): diff --git a/v6d2ctx/integration/event.py b/v6d2ctx/integration/event.py index 7f8b4fb..960035d 100644 --- a/v6d2ctx/integration/event.py +++ b/v6d2ctx/integration/event.py @@ -1,4 +1,4 @@ -__all__ = ('Event', 'SendableEvents', 'ReceivableEvents', 'Events', 'Receiver') +__all__ = ("Event", "SendableEvents", "ReceivableEvents", "Events", "Receiver") import asyncio from typing import Callable, Generic, TypeVar @@ -13,9 +13,9 @@ class Event: raise NotImplementedError -T = TypeVar('T', bound=Event) -T_co = TypeVar('T_co', bound=Event, covariant=True) -T_contra = TypeVar('T_contra', bound=Event, contravariant=True) +T = TypeVar("T", bound=Event) +T_co = TypeVar("T_co", bound=Event, covariant=True) +T_contra = TypeVar("T_contra", bound=Event, contravariant=True) class Receiver(Generic[T_contra]): diff --git a/v6d2ctx/integration/responsetype.py b/v6d2ctx/integration/responsetype.py index 2181c0d..e41b5e0 100644 --- a/v6d2ctx/integration/responsetype.py +++ b/v6d2ctx/integration/responsetype.py @@ -1,8 +1,8 @@ -__all__ = ('ResponseType', 'cast_to_response') +__all__ = ("ResponseType", "cast_to_response") from typing import Any, TypeAlias -ResponseType: TypeAlias = list['ResponseType'] | dict[str, 'ResponseType'] | float | int | bool | str | None +ResponseType: TypeAlias = list["ResponseType"] | dict[str, "ResponseType"] | float | int | bool | str | None def cast_to_response(target: Any) -> ResponseType: diff --git a/v6d2ctx/integration/targets.py b/v6d2ctx/integration/targets.py index eb58130..e5b7da4 100644 --- a/v6d2ctx/integration/targets.py +++ b/v6d2ctx/integration/targets.py @@ -1,4 +1,4 @@ -__all__ = ('Targets', 'JsonLike', 'Async') +__all__ = ("Targets", "JsonLike", "Async") import abc from typing import Any, Callable, Generic, TypeVar @@ -9,10 +9,10 @@ from .responsetype import * def qualname(t: type) -> str: - return f'{t.__module__}.{t.__qualname__}' + return f"{t.__module__}.{t.__qualname__}" -T = TypeVar('T') +T = TypeVar("T") class Flagful(Generic[T]): @@ -29,13 +29,13 @@ class Targets: def register_target(self, targetname: str, target: Any, methodname: str, /, *flags: object) -> None: self.targets[targetname] = Flagful((target, methodname), set(flags)) - print(f'registered target: {targetname}') + print(f"registered target: {targetname}") def register_type(self, target: type, methodname: str, /, *flags: object) -> None: - self.register_target(f'{qualname(target)}.{methodname}', target, methodname, *flags) + self.register_target(f"{qualname(target)}.{methodname}", target, methodname, *flags) def register_instance(self, target: object, methodname: str, /, *flags: object) -> None: - self.register_target(f'{qualname(target.__class__)}().{methodname}', target, methodname, *flags) + self.register_target(f"{qualname(target.__class__)}().{methodname}", target, methodname, *flags) def register_instrumentation( self, @@ -45,7 +45,7 @@ class Targets: *flags: object, ) -> None: self.instrumentations[instrumentationname] = Flagful(instrumentation_factory, set(flags)) - print(f'registered instrumentation: {instrumentationname}') + print(f"registered instrumentation: {instrumentationname}") def get_factory( self, @@ -54,16 +54,14 @@ class Targets: methodname: str, instrumentationname: str, instrumentation_factory: Callable[[Any, str], Instrumentation], - / + /, ) -> Callable[[], Instrumentation]: if (targetname, instrumentationname) not in self.factories: flags_required = self.instrumentations[instrumentationname].flags flags_present = self.targets[targetname].flags if not flags_required.issubset(flags_present): - raise KeyError('target lacks flags required by instrumentation') - self.factories[targetname, instrumentationname] = ( - lambda: instrumentation_factory(target, methodname) - ) + raise KeyError("target lacks flags required by instrumentation") + self.factories[targetname, instrumentationname] = lambda: instrumentation_factory(target, methodname) return self.factories[targetname, instrumentationname] diff --git a/v6d2ctx/lock_for.py b/v6d2ctx/lock_for.py index 7e39e5b..af3a04d 100644 --- a/v6d2ctx/lock_for.py +++ b/v6d2ctx/lock_for.py @@ -3,7 +3,10 @@ from typing import Hashable from v6d2ctx.context import * -__all__ = ('lock_for', 'Locks',) +__all__ = ( + "lock_for", + "Locks", +) class Locks: diff --git a/v6d2ctx/pain.py b/v6d2ctx/pain.py index 36b9d6e..785fbae 100644 --- a/v6d2ctx/pain.py +++ b/v6d2ctx/pain.py @@ -5,7 +5,7 @@ import time from rainbowadn.instrument import Instrumentation -__all__ = ('ALog', 'SLog', 'FrameTrace', 'ABlockMonitor') +__all__ = ("ALog", "SLog", "FrameTrace", "ABlockMonitor") class ALog(Instrumentation): @@ -70,7 +70,7 @@ class ABlockMonitor: delay = spent - delta if delay > self.threshold: self.threshold = delay - print(f'block monitor reached new peak delay {delay:.4f}') + print(f"block monitor reached new peak delay {delay:.4f}") interval = self.interval if interval > 0: await asyncio.sleep(interval) diff --git a/v6d2ctx/serve.py b/v6d2ctx/serve.py index a891cc2..2efaf06 100644 --- a/v6d2ctx/serve.py +++ b/v6d2ctx/serve.py @@ -3,7 +3,7 @@ import signal import discord -__all__ = ('serve',) +__all__ = ("serve",) def serve(main, client: discord.Client, loop: asyncio.AbstractEventLoop):