Skip to content

Commit

Permalink
fix(core): 🚑 Fix `pymongo.errors.InvalidURI: mongodb+srv:// URIs must…
Browse files Browse the repository at this point in the history
… not include a port number`

See pydantic/pydantic#6774 for background
  • Loading branch information
M1N0RM1N3R committed May 10, 2024
1 parent 3a20200 commit d806447
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kolkra_ng/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import re
from pathlib import Path
from typing import Any
from typing import Annotated, Any, TypeAlias

import tomli
from pydantic import BaseModel, Field, MongoDsn, Secret, field_validator
from pydantic import BaseModel, Field, Secret, UrlConstraints, field_validator
from pydantic_core import MultiHostUrl
from typing_extensions import Self

from kolkra_ng.enums.staff_level import StaffLevel
Expand All @@ -19,6 +20,14 @@ class StaffRoles(BaseModel):
cosmetic_roles: list[int] = Field(default_factory=list)


MongoDsn: TypeAlias = Annotated[
MultiHostUrl,
UrlConstraints(
allowed_schemes=["mongodb", "mongodb+srv"],
),
]


class Config(BaseModel):
bot_token: Secret[str]
guild: int
Expand Down

0 comments on commit d806447

Please sign in to comment.