diff options
author | 2021-08-07 23:02:18 +0200 | |
---|---|---|
committer | 2021-08-07 23:02:18 +0200 | |
commit | 22abc00742a610443b2cffe3ae609056a98da713 (patch) | |
tree | cd5be6ae7d30c8c780f5728fc3280ea262b93b8c | |
parent | Update Hacktoberstats' get_october_prs function to use aiohttps get params (diff) |
Improve code consistency in Movie, Wikipedia and Hactoberstats Cogs
-rw-r--r-- | bot/exts/evergreen/movie.py | 2 | ||||
-rw-r--r-- | bot/exts/evergreen/wikipedia.py | 2 | ||||
-rw-r--r-- | bot/exts/halloween/hacktoberstats.py | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/bot/exts/evergreen/movie.py b/bot/exts/evergreen/movie.py index 82fd50bc..c6af4bcd 100644 --- a/bot/exts/evergreen/movie.py +++ b/bot/exts/evergreen/movie.py @@ -141,6 +141,8 @@ class Movie(Cog): async def get_movie(self, client: ClientSession, movie: int) -> Dict: """Get Movie by movie ID from TMDB. Return result dictionary.""" + if not isinstance(movie, int): + raise ValueError("Error while fetching movie from TMDB, movie argument must be integer. ") url = BASE_URL + f"movie/{movie}" async with client.get(url, params=MOVIE_PARAMS) as resp: diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 28bbf0de..7b96cb7b 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -44,7 +44,7 @@ class WikipediaSearch(commands.Cog): async def wiki_request(self, channel: TextChannel, search: str) -> Optional[List[str]]: """Search wikipedia search string and return formatted first 10 pages found.""" - params = dict(WIKI_PARAMS, srlimit=10, srsearch=search) + params = WIKI_PARAMS | {"srlimit": 10, "srsearch": search} async with self.bot.http_session.get(url=SEARCH_API, params=params) as resp: if resp.status == 200: raw_data = await resp.json() diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py index b5d8591d..24106a5e 100644 --- a/bot/exts/halloween/hacktoberstats.py +++ b/bot/exts/halloween/hacktoberstats.py @@ -226,7 +226,7 @@ class HacktoberStats(commands.Cog): log.debug(f"GitHub query parameters generated: {query_params}") - jsonresp = await self._fetch_url(base_url, REQUEST_HEADERS, dict(q=query_params)) + jsonresp = await self._fetch_url(base_url, REQUEST_HEADERS, {"q": query_params}) if "message" in jsonresp: # One of the parameters is invalid, short circuit for now api_message = jsonresp["errors"][0]["message"] |