diff --git a/hive/community/roles.py b/hive/community/roles.py index 1eda73405c6f49bac0d9ad8a8a5a4bedd954c1ff..8245339348ff44c10c4b0c95dcb86cf581f53b22 100644 --- a/hive/community/roles.py +++ b/hive/community/roles.py @@ -52,6 +52,7 @@ def is_permitted(account: str, community: str, action: str) -> bool: def get_user_role(account: str, community: str) -> str: + """Get user role within a specific community.""" if account == community: return 'owner' @@ -76,6 +77,7 @@ def get_user_role(account: str, community: str) -> str: def get_community_privacy(community: str) -> str: + """Load community privacy level""" type_id = query_one('SELECT type_id from hive_communities WHERE name = "%s"' % community) return PRIVACY_MAP.get(type_id) diff --git a/hive/db/query_stats.py b/hive/db/query_stats.py index 134e562b45b01a42851cbfaa4442edfb0eb96229..c9531fe543821f8cf0a9539864e3adf5f4b3b9f6 100644 --- a/hive/db/query_stats.py +++ b/hive/db/query_stats.py @@ -5,6 +5,8 @@ import re import atexit from hive.utils.system import colorize, peak_usage_mb +# pylint: disable=missing-docstring + class QueryStats: SLOW_QUERY_MS = 250 diff --git a/hive/indexer/follow.py b/hive/indexer/follow.py index 3e6156bee7bae3ee0332fc645ddee0fdf824e624..23345546d2231cd0789069670dfa48998ca6ece6 100644 --- a/hive/indexer/follow.py +++ b/hive/indexer/follow.py @@ -11,6 +11,7 @@ FOLLOWERS = 'followers' FOLLOWING = 'following' class Follow: + """Handles processing of incoming follow ups and flushing to db.""" @classmethod def follow_op(cls, account, op_json, date): diff --git a/hive/steem/client_stats.py b/hive/steem/client_stats.py index 466e416eade573b6ee78e2b678191c473d7a3664..7164075fbfc1da659f8831bfdc2b55d0b76f4416 100644 --- a/hive/steem/client_stats.py +++ b/hive/steem/client_stats.py @@ -3,6 +3,8 @@ import atexit from hive.utils.system import colorize, peak_usage_mb +# pylint: disable=missing-docstring + class ClientStats: """Collects steemd API timing data.""" diff --git a/hive/steem/http_client.py b/hive/steem/http_client.py index 92ee74f31fe9e573c2d2f4dd0055f78039afcb30..6957262e3d09fa12ff2a7524eb8026def611637d 100644 --- a/hive/steem/http_client.py +++ b/hive/steem/http_client.py @@ -109,7 +109,6 @@ class HttpClient(object): get_order_book='condenser_api', get_feed_history='condenser_api', get_dynamic_global_properties='database_api', - broadcast_transaction_synchronous='network_broadcast_api', # temporary; for testing condenser_api ) def __init__(self, nodes, **kwargs): diff --git a/hive/steem/steem_client.py b/hive/steem/steem_client.py index c549392dd13b9a4155a01c470164aee3fb478481..46a0e8aaed6201a083c8c4126d8344ec681f9072 100644 --- a/hive/steem/steem_client.py +++ b/hive/steem/steem_client.py @@ -15,6 +15,7 @@ class SteemClient: @classmethod def instance(cls): + """Get a singleton, lazily initialized""" if not cls._instance: cls._instance = SteemClient( url=Conf.get('steemd_url'), @@ -35,13 +36,16 @@ class SteemClient: % (url, max_batch, max_workers)) def get_accounts(self, accounts): + """Fetch multiple accounts by name.""" assert accounts, "no accounts passed to get_accounts" + assert len(accounts) <= 1000, "max 1000 accounts" ret = self.__exec('get_accounts', [accounts]) assert len(accounts) == len(ret), ("requested %d accounts got %d" % (len(accounts), len(ret))) return ret def get_content_batch(self, tuples): + """Fetch multiple comment objects.""" posts = self.__exec_batch('get_content', tuples) # TODO: how are we ensuring sequential results? need to set and sort id. for post in posts: # sanity-checking jussi responses @@ -141,12 +145,15 @@ class SteemClient: return ret def head_time(self): + """Get timestamp of head block""" return self._gdgp()['time'] def head_block(self): + """Get head block number""" return self._gdgp()['head_block_number'] def last_irreversible(self): + """Get last irreversible block""" return self._gdgp()['last_irreversible_block_num'] def gdgp_extended(self): diff --git a/hive/utils/system.py b/hive/utils/system.py index 0f021553d70b57a9958b4028fd297c32e99ef75c..d6eed13f2f28ae8889c5bc90ed4e4166a34cb5f4 100644 --- a/hive/utils/system.py +++ b/hive/utils/system.py @@ -6,11 +6,13 @@ import resource USE_COLOR = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() def colorize(string, color='93'): + """Colorizes a string for stdout, if attached to terminal""" if not USE_COLOR: return string return "\033[%sm%s\033[0m" % (color, string) def peak_usage_mb(): + """Get peak memory usage of hive process.""" mem_denom = (1024 * 1024) if sys.platform == 'darwin' else 1024 max_mem = int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) return max_mem / mem_denom diff --git a/pylintrc b/pylintrc index affde1ca73b912841921f47a7d020576075b4384..864ff9fbe6144611b5920b570fd4c75ba91ffbf5 100644 --- a/pylintrc +++ b/pylintrc @@ -260,7 +260,7 @@ single-line-if-stmt=no no-space-check=trailing-comma,dict-separator # Maximum number of lines in a module -max-module-lines=1000 +max-module-lines=250 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab).