Improved docs and typing

This commit is contained in:
2023-08-17 23:04:38 +02:00
parent 4cbb51ca61
commit 32260e95a7
5 changed files with 38 additions and 9 deletions

View File

@@ -1,9 +1,11 @@
"""Module that provides all database collections"""
from async_pymongo import AsyncClient
from typing import Any, Mapping
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
from libbot.sync import config_get
db_config = config_get("database")
db_config: Mapping[str, Any] = config_get("database")
if db_config["user"] is not None and db_config["password"] is not None:
con_string = "mongodb://{0}:{1}@{2}:{3}/{4}".format(
@@ -19,6 +21,6 @@ else:
)
db_client = AsyncClient(con_string)
db = db_client.get_database(name=db_config["name"])
db: AsyncDatabase = db_client.get_database(name=db_config["name"])
col_users = db.get_collection("users")
col_users: AsyncCollection = db.get_collection("users")