Sourcery refactored development branch#6
Conversation
ac9cb98 to
3ad9791
Compare
b48e46d to
27ad621
Compare
| if "-" in pool_name: | ||
| pool_name = sorted(pool_name.split("-")) | ||
| pool_name = "{}/{}".format(pool_name[0], pool_name[1]) | ||
| pool_name = f"{pool_name[0]}/{pool_name[1]}" |
There was a problem hiding this comment.
Function get_summary_detail refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting) - Remove unnecessary else after guard condition [×2] (
remove-unnecessary-else) - Merge dictionary assignment with declaration (
merge-dict-assign) - Simplify sequence length comparison (
simplify-len-comparison) - Simplify dictionary access using default get [×3] (
default-get) - Swap if/else branches (
swap-if-else-branches)
| list_volume_1d["{}/{}".format(v["sold_ticker"], v["got_ticker"])] = { | ||
| list_volume_1d[f'{v["sold_ticker"]}/{v["got_ticker"]}'] = { |
There was a problem hiding this comment.
Function get_summary refactored with the following changes:
- Replace call to format with f-string [×4] (
use-fstring-for-formatting)
| else: | ||
| all_coin_withdraw = await get_all_coin_names("cexswap_withdraw", 1, 100) | ||
| app.coin_list = await get_coin_setting() | ||
| list_coins = {} | ||
| if len(all_coin_withdraw) > 0: | ||
| for i in all_coin_withdraw: | ||
| min_tx = getattr(getattr(app.coin_list, i), "real_min_tx") | ||
| max_tx = getattr(getattr(app.coin_list, i), "real_max_tx") | ||
| list_coins[i] = { | ||
| "api_withdraw": 1, | ||
| "min_amount": truncate(min_tx, 8), | ||
| "max_amount": truncate(max_tx, 8), | ||
| } | ||
| try: | ||
| set_cache_kv( | ||
| app, | ||
| config["kv_db"]["prefix_cexswap"], | ||
| key="withdraw_list", | ||
| value=list_coins, | ||
| ) | ||
| except Exception: | ||
| traceback.print_exc(file=sys.stdout) | ||
| return {"success": True, "result": list_coins, "time": int(time.time())} | ||
| all_coin_withdraw = await get_all_coin_names("cexswap_withdraw", 1, 100) | ||
| app.coin_list = await get_coin_setting() | ||
| list_coins = {} | ||
| if len(all_coin_withdraw) > 0: | ||
| for i in all_coin_withdraw: | ||
| min_tx = getattr(getattr(app.coin_list, i), "real_min_tx") | ||
| max_tx = getattr(getattr(app.coin_list, i), "real_max_tx") | ||
| list_coins[i] = { | ||
| "api_withdraw": 1, | ||
| "min_amount": truncate(min_tx, 8), | ||
| "max_amount": truncate(max_tx, 8), | ||
| } | ||
| try: | ||
| set_cache_kv( | ||
| app, | ||
| config["kv_db"]["prefix_cexswap"], | ||
| key="withdraw_list", | ||
| value=list_coins, | ||
| ) | ||
| except Exception: | ||
| traceback.print_exc(file=sys.stdout) | ||
| return {"success": True, "result": list_coins, "time": int(time.time())} |
There was a problem hiding this comment.
Function get_withdraw_list refactored with the following changes:
- Swap if/else branches [×2] (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| name="Coins with CEXSwap: {}".format(len(self.bot.cexswap_coins)), | ||
| value="{}".format(", ".join(self.bot.cexswap_coins)), | ||
| name=f"Coins with CEXSwap: {len(self.bot.cexswap_coins)}", | ||
| value=f'{", ".join(self.bot.cexswap_coins)}', |
There was a problem hiding this comment.
Function ViewSummary.btn_summary_liqudity refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting)
| name="Coins with CEXSwap: {}".format(len(self.bot.cexswap_coins)), | ||
| value="{}".format(", ".join(self.bot.cexswap_coins)), | ||
| name=f"Coins with CEXSwap: {len(self.bot.cexswap_coins)}", | ||
| value=f'{", ".join(self.bot.cexswap_coins)}', |
There was a problem hiding this comment.
Function ViewSummary.btn_summary_volume refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting)
| name="Coins with CEXSwap: {}".format(len(self.bot.cexswap_coins)), | ||
| value="{}".format(", ".join(self.bot.cexswap_coins)), | ||
| name=f"Coins with CEXSwap: {len(self.bot.cexswap_coins)}", | ||
| value=f'{", ".join(self.bot.cexswap_coins)}', |
There was a problem hiding this comment.
Function ViewSummary.btn_summary_fee refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting)
| description="Select {}".format(each), | ||
| emoji=getattr(getattr(self.bot.coin_list, each), "coin_emoji_discord"), | ||
| description=f"Select {each}", | ||
| emoji=getattr( | ||
| getattr(self.bot.coin_list, each), "coin_emoji_discord" | ||
| ), |
There was a problem hiding this comment.
Function DropdownLP.__init__ refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting)
| text="Requested by: {}#{}".format( | ||
| self.ctx.author.name, self.ctx.author.discriminator | ||
| ) | ||
| text=f"Requested by: {self.ctx.author.name}#{self.ctx.author.discriminator}" | ||
| ) | ||
| embed.set_thumbnail(url=self.bot.user.display_avatar) | ||
| # get LP by coin | ||
| get_pools = await cexswap_get_pools(self.values[0]) | ||
| showing_num = 8 | ||
| if len(get_pools) > 0: | ||
| embed.add_field( | ||
| name="Selected Coin {}".format(self.values[0]), | ||
| name=f"Selected Coin {self.values[0]}", | ||
| value="There {} LP with {}".format( | ||
| "is {}".format(len(get_pools)) | ||
| f"is {len(get_pools)}" | ||
| if len(get_pools) == 1 | ||
| else "are {}".format(len(get_pools)), | ||
| else f"are {len(get_pools)}", | ||
| self.values[0], | ||
| ), | ||
| inline=False, | ||
| ) | ||
| for each_p in get_pools[0:showing_num]: | ||
| showing_num = 8 | ||
| for each_p in get_pools[:showing_num]: | ||
| rate_1 = num_format_coin( | ||
| each_p["amount_ticker_2"] / each_p["amount_ticker_1"] | ||
| ) | ||
| rate_2 = num_format_coin( | ||
| each_p["amount_ticker_1"] / each_p["amount_ticker_2"] | ||
| ) | ||
| rate_coin_12 = "{} {} = {} {}\n{} {} = {} {}".format( | ||
| 1, | ||
| each_p["ticker_1_name"], | ||
| rate_1, | ||
| each_p["ticker_2_name"], | ||
| 1, | ||
| each_p["ticker_2_name"], | ||
| rate_2, | ||
| each_p["ticker_1_name"], | ||
| ) | ||
| rate_coin_12 = f'1 {each_p["ticker_1_name"]} = {rate_1} {each_p["ticker_2_name"]}\n1 {each_p["ticker_2_name"]} = {rate_2} {each_p["ticker_1_name"]}' | ||
|
|
||
| embed.add_field( | ||
| name="Active LP {}{}".format( | ||
| each_p["pairs"], | ||
| " {} / {}".format( | ||
| self.utils.get_coin_emoji(each_p["ticker_1_name"]), | ||
| self.utils.get_coin_emoji(each_p["ticker_2_name"]), | ||
| ), | ||
| ), | ||
| value="{} {}\n{} {}\n{}".format( | ||
| num_format_coin(each_p["amount_ticker_1"]), | ||
| each_p["ticker_1_name"], | ||
| num_format_coin(each_p["amount_ticker_2"]), | ||
| each_p["ticker_2_name"], | ||
| rate_coin_12, | ||
| ), | ||
| name=f'Active LP {each_p["pairs"]} {self.utils.get_coin_emoji(each_p["ticker_1_name"])} / {self.utils.get_coin_emoji(each_p["ticker_2_name"])}', | ||
| value=f'{num_format_coin(each_p["amount_ticker_1"])} {each_p["ticker_1_name"]}\n{num_format_coin(each_p["amount_ticker_2"])} {each_p["ticker_2_name"]}\n{rate_coin_12}', |
There was a problem hiding this comment.
Function DropdownLP.callback refactored with the following changes:
- Replace call to format with f-string [×10] (
use-fstring-for-formatting) - Move assignments closer to their usage (
move-assign) - Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index) - Simplify sequence length comparison (
simplify-len-comparison) - Simplify unnecessary nesting, casting and constant values in f-strings [×2] (
simplify-fstring-formatting)
| f"You do not get any reward because it is a free game! " | ||
| "Waiting to refresh your paid plays (24h max)." | ||
| ) | ||
| result = 'You do not get any reward because it is a free game! Waiting to refresh your paid plays (24h max).' |
There was a problem hiding this comment.
Function Maze_Buttons.up_button refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| result = ( | ||
| f"You do not get any reward because it is a free game! " | ||
| "Waiting to refresh your paid plays (24h max)." | ||
| ) | ||
| result = 'You do not get any reward because it is a free game! Waiting to refresh your paid plays (24h max).' |
There was a problem hiding this comment.
Function Maze_Buttons.down_button refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
Branch
developmentrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
developmentbranch, then run:Help us improve this pull request!