GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

db_wrapper.StaticClassList.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import os
2
from typing import Optional
3
4
import dotenv
5
from motor.motor_asyncio import AsyncIOMotorClient
6
from pymongo.errors import InvalidURI
7
8
from classes.logger import log
9
10
DB_PATH: Optional[str] = (
11
    os.environ.get('MONGO_DB_URL')
12
    or dotenv.dotenv_values('.env').get('MONGO_DB_URL')
13
)
14
15
if DB_PATH is None:
16
    log.error(
17
        'No mongo db path has been provided.'
18
        ' Make sure to create an `.env` file'
19
        ' or add in environ key'
20
    )
21
22
23
try:
24
    MONGO_CLIENT = AsyncIOMotorClient(DB_PATH)
25
26
except InvalidURI:
27
    log.error(
28
        'Cant connect to the mongo db database, '
29
        'make sure that the `.env` or os.ENVIRON'
30
        ' as been set properly.'
31
    )
32
33
34
class StaticClassList:
35
36
    def __init__(self):
37
        log.warn(
38
            'Classes from db wrapper should not be instantiated.'
39
            f' Consider using `{self.__class__.__name__}`.'
40
        )
41
42
43
class Database(StaticClassList):
44
    MAIN = MONGO_CLIENT["Axiol"]
45
    LEVEL = MONGO_CLIENT["Leveling"]
46
    KARMA = MONGO_CLIENT["Karma"]
47
    CUSTOM = MONGO_CLIENT["Custom"]
48
    WARNINGS = MONGO_CLIENT["Warnings"]
49
50
51
class Collections(StaticClassList):
52
    PLUGINS = Database.MAIN["Plugins"]
53
    PREFIXES = Database.MAIN["Prefixes"]
54
    REACTION_ROLES = Database.MAIN["Reaction Roles"]
55
    WELCOME = Database.MAIN["Welcome"]
56
    VERIFY = Database.MAIN["Verify"]
57
    CHATBOT = Database.MAIN["Chatbot"]
58
    PERMISSIONS = Database.MAIN["Permissions"]
59
    AUTO_MOD = Database.MAIN["AutoMod"]
60
    GIVEAWAY = Database.MAIN["Giveaway"]
61