From 8cd4555f18e73b25761f48044793eda8e1791f6b Mon Sep 17 00:00:00 2001 From: grey-cat-1908 Date: Sat, 25 Sep 2021 20:19:38 +0300 Subject: [PATCH] maybe pep-8? --- .gitignore | 1 + boticordpy/config.py | 4 ++-- boticordpy/modules/bots.py | 16 ++++++++-------- boticordpy/modules/servers.py | 18 +++++++++--------- boticordpy/modules/users.py | 22 +++++++++++----------- boticordpy/webhook.py | 11 +++++------ 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 0d33821..0fe9d15 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ __pycache__ dist docs/_build boticordpy.egg-info +test.py diff --git a/boticordpy/config.py b/boticordpy/config.py index edd6fb0..8cea61f 100644 --- a/boticordpy/config.py +++ b/boticordpy/config.py @@ -1,8 +1,8 @@ -from aiohttp import ClientResponse - from typing import Union import json +from aiohttp import ClientResponse + from . import exceptions from . import types diff --git a/boticordpy/modules/bots.py b/boticordpy/modules/bots.py index 20eea4d..23abfd0 100644 --- a/boticordpy/modules/bots.py +++ b/boticordpy/modules/bots.py @@ -1,7 +1,7 @@ -import aiohttp - import asyncio +import aiohttp + from ..config import Config, _json_or_text @@ -22,18 +22,18 @@ class Bots: self.loop = kwargs.get('loop') or asyncio.get_event_loop() self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop) - async def get_bot_info(self, botID: int): + async def get_bot_info(self, bot_id: int): """ Returns information about discord bot with the given ID. Parameters ---------- - botID : :class:`int` + bot_id : :class:`int` Discord Bot's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/bot/{botID}', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/bot/{bot_id}', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) @@ -41,18 +41,18 @@ class Bots: raise status(resp) return data - async def get_bot_comments(self, botID: int): + async def get_bot_comments(self, bot_id: int): """ Returns comments of the discord bot with the given ID. Parameters ---------- - botID : :class:`int` + bot_id : :class:`int` Discord Bot's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/bot/{botID}/comments', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/bot/{bot_id}/comments', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: diff --git a/boticordpy/modules/servers.py b/boticordpy/modules/servers.py index 6cb184b..16e46e4 100644 --- a/boticordpy/modules/servers.py +++ b/boticordpy/modules/servers.py @@ -1,8 +1,8 @@ +import asyncio + import aiohttp import discord -import asyncio - from ..config import Config, _json_or_text @@ -23,36 +23,36 @@ class Servers: self.loop = kwargs.get('loop') or asyncio.get_event_loop() self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop) - async def get_server_info(self, serverID: int): + async def get_server_info(self, server_id: int): """ Returns information about discord server with the given ID. Parameters ---------- - serverID : :class:`int` + server_id : :class:`int` Discord Server's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/server/{serverID}', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/server/{server_id}', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: raise status(resp) return data - async def get_server_comments(self, serverID: int): + async def get_server_comments(self, server_id: int): """ Returns comments of the discord server with the given ID. Parameters ---------- - serverID : :class:`int` + server_id : :class:`int` Discord Server's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/server/{serverID}/comments', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/server/{server_id}/comments', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: @@ -78,7 +78,7 @@ class Servers: guild_owner = guild.owner stats = { - "serverID": str(guild.id), + "server_id": str(guild.id), "up": 1, "status": 1, "serverName": guild.name, diff --git a/boticordpy/modules/users.py b/boticordpy/modules/users.py index 54f41d8..42a43dc 100644 --- a/boticordpy/modules/users.py +++ b/boticordpy/modules/users.py @@ -1,7 +1,7 @@ -import aiohttp - import asyncio +import aiohttp + from ..config import Config, _json_or_text @@ -16,54 +16,54 @@ class Users: self.loop = kwargs.get('loop') or asyncio.get_event_loop() self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop) - async def get_user(self, userID: int): + async def get_user(self, user_id: int): """ Returns information about discord user with the given ID. Parameters ---------- - userID : :class:`int` + user_id : :class:`int` Discord User's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/profile/{userID}', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/profile/{user_id}', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: raise status(resp) return data - async def get_user_comments(self, userID: int): + async def get_user_comments(self, user_id: int): """ Returns comments of discord user with the given ID. Parameters ---------- - userID : :class:`int` + user_id : :class:`int` Discord User's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/profile/{userID}/comments', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/profile/{user_id}/comments', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: raise status(resp) return data - async def get_user_bots(self, userID: int): + async def get_user_bots(self, user_id: int): """ Returns bots of discord user with the given ID. Parameters ---------- - userID : :class:`int` + user_id : :class:`int` Discord User's ID """ headers = {"Authorization": self.token} - async with self.session.get(f'{Config.general_api}/bots/{userID}', headers=headers) as resp: + async with self.session.get(f'{Config.general_api}/bots/{user_id}', headers=headers) as resp: data = await _json_or_text(resp) status = Config.http_exceptions.get(resp.status) if status is not None: diff --git a/boticordpy/webhook.py b/boticordpy/webhook.py index eb0e853..4b596c9 100644 --- a/boticordpy/webhook.py +++ b/boticordpy/webhook.py @@ -1,16 +1,15 @@ -from discord.ext.commands import Bot, AutoShardedBot -from aiohttp.web_urldispatcher import _WebHandler -from aiohttp import web -import aiohttp - import sys +from typing import Dict, Union if sys.version_info >= (3, 8): from typing import TypedDict else: from typing_extensions import TypedDict -from typing import Dict, Union +from discord.ext.commands import Bot, AutoShardedBot +from aiohttp.web_urldispatcher import _WebHandler +from aiohttp import web +import aiohttp from . import BoticordClient from . import config