Skip to content

Commit

Permalink
fix(lint): Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nythepegasus committed Jan 10, 2025
1 parent 2f4d0eb commit ad4e999
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 44 deletions.
3 changes: 1 addition & 2 deletions SideBot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# pylint: disable=C0103,C0114
import logging
import pathlib
import typing

import yaml
Expand Down Expand Up @@ -99,5 +98,5 @@ def run(

@classmethod
def from_yaml_file(cls, path: str = "conf.yaml") -> "SideBot":
with open(path, 'r') as f:
with open(path, "r") as f:
return cls(yaml.safe_load(f))
64 changes: 22 additions & 42 deletions SideBot/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@

class DBConfig:
"""DBConfig class for Postgresql with Bot"""
__slot__ = ('user', 'password', 'host', 'port', 'name')

def __init__(
self,
user: str,
password: str,
host: str,
port: int | None = None,
name: str | None = None
):

__slot__ = ("user", "password", "host", "port", "name")

def __init__(self, user: str, password: str, host: str, port: int | None = None, name: str | None = None):
self.user = user
self.password = password
self.host = host
Expand All @@ -28,54 +22,40 @@ def connect_str(self):
@property
def as_dict(self):
return {
'user': self.user,
'pass': self.password,
'host': self.host,
'port': self.port,
'name': self.name,
"user": self.user,
"pass": self.password,
"host": self.host,
"port": self.port,
"name": self.name,
}

@classmethod
def from_dict(cls, data: dict):
return cls(
data['user'],
data['pass'],
data['host'],
data['port'] if 'port' in data else None,
data['name'] if 'name' in data else data['user']
data["user"],
data["pass"],
data["host"],
data["port"] if "port" in data else None,
data["name"] if "name" in data else data["user"],
)


class BotConfig:
"""BotConfig class for SideBot"""
__slots__ = ('token', 'owner', 'db_url', 'cogs')

def __init__(
self,
token: str,
owner: int,
db_url: str,
cogs: list[str]
):

__slots__ = ("token", "owner", "db_url", "cogs")

def __init__(self, token: str, owner: int, db_url: str, cogs: list[str]):
self.token = token
self.owner = owner
self.db_url = db_url
self.cogs = cogs

@classmethod
def from_dict(cls, data: dict):
if 'botDB' in data:
return cls(
data['discordToken'],
data['owner'],
DBConfig.from_dict(data['botDB']).connect_str,
data['cogs']
)
return cls(
data['discordToken'],
data['owner'],
data['botDBURL'],
data['cogs']
)
if "botDB" in data:
return cls(data["discordToken"], data["owner"], DBConfig.from_dict(data["botDB"]).connect_str, data["cogs"])
return cls(data["discordToken"], data["owner"], data["botDBURL"], data["cogs"])


class DiscordUser:
Expand Down

0 comments on commit ad4e999

Please sign in to comment.