Merge pull request #12 from muhammedfurkan/deepsource-fix-bdf298fa

Change methods not using its bound instance to staticmethods
This commit is contained in:
M.Furkan 2020-11-09 00:54:22 +03:00 committed by GitHub
commit 44a07f26ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 20 deletions

View file

@ -16,7 +16,8 @@ class LoggingMiddleware(BaseMiddleware):
super(LoggingMiddleware, self).__init__()
def check_timeout(self, obj):
@staticmethod
def check_timeout(obj):
start = obj.conf.get('_start', None)
if start:
del obj.conf['_start']
@ -248,7 +249,8 @@ class LoggingFilter(logging.Filter):
yield 'update_type', 'pre_checkout_query'
yield from self.process_pre_checkout_query(update.pre_checkout_query)
def make_prefix(self, prefix, iterable):
@staticmethod
def make_prefix(prefix, iterable):
"""
Add prefix to the label

View file

@ -385,7 +385,8 @@ class HashTag(Filter):
or self.cashtags and set(cashtags) & set(self.cashtags):
return {'hashtags': hashtags, 'cashtags': cashtags}
def _get_tags(self, text, entities):
@staticmethod
def _get_tags(text, entities):
hashtags = []
cashtags = []
@ -529,7 +530,8 @@ class StateFilter(BoundFilter):
states.append(item)
self.states = states
def get_target(self, obj):
@staticmethod
def get_target(obj):
return getattr(getattr(obj, 'chat', None), 'id', None), getattr(getattr(obj, 'from_user', None), 'id', None)
async def check(self, obj):

View file

@ -198,7 +198,8 @@ class BaseStorage:
"""
await self.reset_state(chat=chat, user=user, with_data=True)
def has_bucket(self):
@staticmethod
def has_bucket():
return False
async def get_bucket(self, *,

View file

@ -218,7 +218,8 @@ class WebhookRequestHandler(web.View):
if response is not None:
asyncio.ensure_future(response.execute_response(dispatcher.bot), loop=loop)
def get_response(self, results):
@staticmethod
def get_response(results):
"""
Get response object from results.

View file

@ -23,10 +23,12 @@ def invalid_token_fixture(request):
class TestCheckToken:
def test_valid(self):
@staticmethod
def test_valid():
if check_token(VALID_TOKEN) is not True:
raise AssertionError
def test_invalid_token(self, invalid_token):
@staticmethod
def test_invalid_token(invalid_token):
with pytest.raises(ValidationError):
check_token(invalid_token)

View file

@ -2,7 +2,8 @@ from aiogram.dispatcher.filters.state import StatesGroup
class TestStatesGroup:
def test_all_childs(self):
@staticmethod
def test_all_childs():
class InnerState1(StatesGroup):
pass

View file

@ -18,7 +18,8 @@ async def callback3(foo: int, **kwargs):
class TestHandlerObj:
def test_init_decorated(self):
@staticmethod
def test_init_decorated():
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):

View file

@ -30,22 +30,26 @@ class Test_check_token:
This case gonna be deleted
"""
def test_ok(self, data):
@staticmethod
def test_ok(data):
if check_token(data, TOKEN) is not True:
raise AssertionError
def test_fail(self, data):
@staticmethod
def test_fail(data):
data.pop("username")
if check_token(data, TOKEN) is not False:
raise AssertionError
class Test_check_integrity:
def test_ok(self, data):
@staticmethod
def test_ok(data):
if check_integrity(TOKEN, data) is not True:
raise AssertionError
def test_fail(self, data):
@staticmethod
def test_fail(data):
data.pop("username")
if check_integrity(TOKEN, data) is not False:
raise AssertionError

View file

@ -2,7 +2,8 @@ from aiogram.utils.helper import Item, ListItem, OrderedHelper
class TestOrderedHelper:
def test_items_are_ordered(self):
@staticmethod
def test_items_are_ordered():
class Helper(OrderedHelper):
A = Item()
D = Item()
@ -12,7 +13,8 @@ class TestOrderedHelper:
if Helper.all() != ["A", "D", "C", "B"]:
raise AssertionError
def test_list_items_are_ordered(self):
@staticmethod
def test_list_items_are_ordered():
class Helper(OrderedHelper):
A = ListItem()
D = ListItem()

View file

@ -4,10 +4,12 @@ from aiogram.utils import markdown
class TestMarkdownEscape:
def test_equality_sign_is_escaped(self):
@staticmethod
def test_equality_sign_is_escaped():
if markdown.escape_md(r"e = mc2") != r"e \= mc2":
raise AssertionError
def test_pre_escaped(self):
@staticmethod
def test_pre_escaped():
if markdown.escape_md(r"hello\.") != r"hello\\\.":
raise AssertionError

View file

@ -3,7 +3,8 @@ from aiogram.utils import text_decorations
class TestTextDecorations:
def test_unparse_entities_normal_text(self):
@staticmethod
def test_unparse_entities_normal_text():
if (
text_decorations.markdown_decoration.unparse(
"hi i'm bold and italic and still bold",
@ -18,7 +19,8 @@ class TestTextDecorations:
):
raise AssertionError
def test_unparse_entities_emoji_text(self):
@staticmethod
def test_unparse_entities_emoji_text():
"""
emoji is encoded as two chars in json
"""