Skip to content

Commit

Permalink
Flake&Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Nov 30, 2021
1 parent 0ee609e commit ee9d3e1
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from tribler_common.simpledefs import DLSTATUS_SEEDING

from tribler_core.components.libtorrent.torrentdef import TorrentDef
from tribler_core.components.gigachannel_manager.gigachannel_manager import GigaChannelManager
from tribler_core.components.libtorrent.torrentdef import TorrentDef
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler_core.tests.tools.base_test import MockObject
from tribler_core.tests.tools.common import TORRENT_UBUNTU_FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
HealthItemsPayload,
)
from tribler_core.utilities.path_util import Path
from tribler_core.utilities.utilities import random_infohash
from tribler_core.utilities.unicode import hexlify
from tribler_core.utilities.utilities import random_infohash

CHANNEL_DIR_NAME_PK_LENGTH = 32 # Its not 40 so it could be distinguished from infohash
CHANNEL_DIR_NAME_ID_LENGTH = 16 # Zero-padded long int in hex form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
from datetime import datetime
from unittest.mock import patch

import pytest
from ipv8.keyvault.crypto import default_eccrypto

from pony.orm import db_session

from ipv8.keyvault.crypto import default_eccrypto
from tribler_core.components.metadata_store.remote_query_community.payload_checker import ObjState, ProcessingResult
from tribler_core.components.metadata_store.db.orm_bindings.channel_metadata import CHANNEL_DIR_NAME_LENGTH, \
entries_to_chunk
import pytest

from tribler_core.components.metadata_store.db.orm_bindings.channel_metadata import (
CHANNEL_DIR_NAME_LENGTH,
entries_to_chunk,
)
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler_core.components.metadata_store.db.serialization import (
CHANNEL_TORRENT,
Expand All @@ -22,12 +25,12 @@
UnknownBlobTypeException,
int2time,
)
from tribler_core.components.metadata_store.remote_query_community.payload_checker import ObjState, ProcessingResult
from tribler_core.components.metadata_store.tests.test_channel_download import CHANNEL_METADATA_UPDATED
from tribler_core.tests.tools.common import TESTS_DATA_DIR
from tribler_core.utilities.path_util import Path
from tribler_core.utilities.utilities import random_infohash


# pylint: disable=protected-access,unused-argument


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
)
from tribler_core.components.metadata_store.remote_query_community.settings import RemoteQueryCommunitySettings
from tribler_core.utilities.path_util import Path
from tribler_core.utilities.utilities import random_infohash
from tribler_core.utilities.unicode import hexlify
from tribler_core.utilities.utilities import random_infohash

# pylint: disable=protected-access

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from tribler_core.components.restapi.rest.base_api_test import do_request
from tribler_core.components.restapi.rest.rest_manager import error_middleware
from tribler_core.tests.tools.common import TORRENT_UBUNTU_FILE
from tribler_core.utilities.utilities import random_infohash
from tribler_core.utilities.unicode import hexlify
from tribler_core.utilities.utilities import random_infohash

PNG_DATA = unhexlify(
"89504e470d0a1a0a0000000d494844520"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from tribler_core.components.metadata_store.restapi.remote_query_endpoint import RemoteQueryEndpoint
from tribler_core.components.restapi.rest.base_api_test import do_request
from tribler_core.components.restapi.rest.rest_manager import error_middleware
from tribler_core.utilities.utilities import random_infohash
from tribler_core.utilities.unicode import hexlify
from tribler_core.utilities.utilities import random_infohash

# pylint: disable=unused-argument

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import pytest
from aiohttp import ClientSession

import pytest

from tribler_core.utilities.utilities import (
is_channel_public_key,
is_infohash,
is_simple_match_query,
is_valid_url,
parse_magnetlink, random_infohash,
parse_magnetlink,
random_infohash,
)


Expand Down
10 changes: 4 additions & 6 deletions src/tribler-core/tribler_core/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
provides a method for HTTP GET requests as well as a function to translate peers into health.
Author(s): Jie Yang
"""
import os
import random

import binascii
import logging
import random
import re
from base64 import b32decode
from functools import wraps
Expand Down Expand Up @@ -40,6 +38,7 @@ def init_decorator(func):
def wrapper(self, *args, **kwargs):
func(self, *args, **kwargs)
self.__frozen = True

return wrapper

cls.__setattr__ = frozensetattr
Expand All @@ -63,7 +62,7 @@ def is_valid_url(url):
url = url.lower().replace('udp', 'http', 1)
split_url = urlsplit(url)

return not(split_url[0] == '' or split_url[1] == '')
return not (split_url[0] == '' or split_url[1] == '')


def parse_magnetlink(url):
Expand Down Expand Up @@ -169,5 +168,4 @@ def bdecode_compat(packet_buffer):

def random_infohash(random_gen=None):
r = random_gen or random
""" Generates a random torrent infohash binary string """
return r.getrandbits(20*8).to_bytes(20, byteorder='big')
return r.getrandbits(20 * 8).to_bytes(20, byteorder='big')

0 comments on commit ee9d3e1

Please sign in to comment.