mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Remove type-breaking annotation on cog_i18n decorator (#6231)
Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
parent
742339a990
commit
b6471797cc
@ -8,7 +8,7 @@ import logging
|
|||||||
import discord
|
import discord
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, TYPE_CHECKING, Union, Dict, Optional
|
from typing import Callable, TYPE_CHECKING, Union, Dict, Optional, TypeVar
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
|
|
||||||
import babel.localedata
|
import babel.localedata
|
||||||
@ -358,11 +358,13 @@ def get_babel_regional_format(regional_format: Optional[str] = None) -> babel.co
|
|||||||
# noinspection PyPep8
|
# noinspection PyPep8
|
||||||
from . import commands
|
from . import commands
|
||||||
|
|
||||||
|
_TypeT = TypeVar("_TypeT", bound=type)
|
||||||
|
|
||||||
def cog_i18n(translator: Translator):
|
|
||||||
|
def cog_i18n(translator: Translator) -> Callable[[_TypeT], _TypeT]:
|
||||||
"""Get a class decorator to link the translator to this cog."""
|
"""Get a class decorator to link the translator to this cog."""
|
||||||
|
|
||||||
def decorator(cog_class: type):
|
def decorator(cog_class: _TypeT) -> _TypeT:
|
||||||
cog_class.__translator__ = translator
|
cog_class.__translator__ = translator
|
||||||
for name, attr in cog_class.__dict__.items():
|
for name, attr in cog_class.__dict__.items():
|
||||||
if isinstance(attr, (commands.Group, commands.Command)):
|
if isinstance(attr, (commands.Group, commands.Command)):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user