From 3be8e07445965dd71853b710f51d5ea5cd23baea Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 9 Oct 2021 07:44:25 +0000 Subject: [PATCH] Format code with yapf This commit fixes the style issues introduced in 03284a2 according to the output from yapf. Details: https://deepsource.io/gh/dae-cmyk/LegendDiscordBot/transform/55688539-c04b-40fb-95a5-6a3ff659b559/ --- clashstat.py | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/clashstat.py b/clashstat.py index 5d9ae1c..7b5bdf7 100644 --- a/clashstat.py +++ b/clashstat.py @@ -1,8 +1,9 @@ -import coc #type: ignore -import nest_asyncio #type: ignore +import coc #type: ignore +import nest_asyncio #type: ignore import asyncio from typing import List, Dict, Optional, Union, Any + class PlayerStats: def __init__(self, ID: str, Password: str, filename: str) -> None: nest_asyncio.apply() @@ -28,7 +29,10 @@ async def GetUserTrophies(self) -> Dict[str, Dict[str, Union[str, int]]]: return list of dict[playertag, dict[player name, tag, trophies]] why?: to find playertag within O(1) """ - tasks = list(map(lambda player: asyncio.create_task(self.client.get_player(player)), self.PlayersTag)) + tasks = list( + map( + lambda player: asyncio.create_task( + self.client.get_player(player)), self.PlayersTag)) PlayersInfo = await asyncio.gather(*tasks) @@ -59,10 +63,12 @@ def ComparePlayerData(self, NewPlayersInfo: Dict[str, Dict[str, Union[str, int]] def IsItSameTrophies(profile_1: Optional[Dict[str, Union[str, int]]],\ profile_2: Optional[Dict[str, Union[str, int]]]) -> bool: - if isinstance(profile_1, type(None)) or isinstance(profile_2, type(None)): + if isinstance(profile_1, type(None)) or isinstance( + profile_2, type(None)): return False - return profile_1.get('trophies') == profile_2.get('trophies') #type: ignore - + return profile_1.get('trophies') == profile_2.get( + 'trophies') #type: ignore + #If nothing is in the prev player info list #return every player info if len(self.PrevPlayersFullInfo.keys()) == 0: @@ -70,35 +76,39 @@ def IsItSameTrophies(profile_1: Optional[Dict[str, Union[str, int]]],\ UpdateRequiredInfo: Dict[str, Dict[str, Union[str, int]]] = {} for tag in self.PlayersTag: - if not IsItSameTrophies(NewPlayersInfo.get(tag), self.PrevPlayersFullInfo.get(tag)): + if not IsItSameTrophies(NewPlayersInfo.get(tag), + self.PrevPlayersFullInfo.get(tag)): UpdateRequiredInfo[tag] = NewPlayersInfo[tag] return UpdateRequiredInfo - def FindTrophyDifferenceAndUpdate(self, NewPlayersInfo: Dict[str, Dict[str, Union[str, int]]]) -> Dict[str, Dict[str, Union[str, int]]]: + def FindTrophyDifferenceAndUpdate( + self, NewPlayersInfo: Dict[str, Dict[str, Union[str, int]]] + ) -> Dict[str, Dict[str, Union[str, int]]]: """ Get the difference in trophy and return the information """ if len(self.PrevPlayersFullInfo.keys()) == 0: - self.PrevPlayersFullInfo = NewPlayersInfo #type: ignore + self.PrevPlayersFullInfo = NewPlayersInfo #type: ignore return {} def FindTrophyDifference(CurrInfo, PastInfo): - if isinstance(CurrInfo, type(None)) or isinstance(PastInfo, type(None)): + if isinstance(CurrInfo, type(None)) or isinstance( + PastInfo, type(None)): print(f"Error!: CurrInfo: {CurrInfo}, PrevInfo: {PastInfo}") return 0 return CurrInfo.get('trophies') - PastInfo.get('trophies') TrophyDifferenceCollection = {} for tag in NewPlayersInfo.keys(): - TrophyDifference = FindTrophyDifference(NewPlayersInfo.get(tag), self.PrevPlayersFullInfo.get(tag)) + TrophyDifference = FindTrophyDifference( + NewPlayersInfo.get(tag), self.PrevPlayersFullInfo.get(tag)) TrophyDifferenceCollection[tag] = \ {'trophies': TrophyDifference, 'name': NewPlayersInfo[tag].get('name'), 'tag': tag} - - self.PrevPlayersFullInfo = NewPlayersInfo #type: ignore + self.PrevPlayersFullInfo = NewPlayersInfo #type: ignore return TrophyDifferenceCollection - + async def Run(self): """ IMPORTANT: Call self.GetPlayerList() first before calling this function. @@ -111,7 +121,8 @@ async def Run(self): print(self.PrevPlayersFullInfo) DifferenceDetectedPlayers = self.ComparePlayerData(NewPlayersInfo) print("Compare Player Data") - TrophyDifference = self.FindTrophyDifferenceAndUpdate(DifferenceDetectedPlayers) + TrophyDifference = self.FindTrophyDifferenceAndUpdate( + DifferenceDetectedPlayers) print("Find Trophy Difference") print(TrophyDifference) - return TrophyDifference \ No newline at end of file + return TrophyDifference