Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.7.2
pydantic compiled: True
install path: /home/sebastiannl/.local/lib/python3.8/site-packages/pydantic
python version: 3.8.6 (default, Sep 30 2020, 04:00:38) [GCC 10.2.0]
platform: Linux-5.8.18-1-MANJARO-x86_64-with-glibc2.2.5
optional deps. installed: ['typing-extensions', 'email-validator']
currently its impossible to define a driver for a postgresdsn since only {'postgres', 'postgresql'} are allowed schemes. i think it should be possible to use "postgressql+asyncpg", too.
from pydantic import PostgresDsn
postgres = PostgresDsn.build(
scheme="postgresql+asyncpg",
user=values.get("POSTGRES_USER"),
password=values.get("POSTGRES_PASSWORD"),
host=values.get("POSTGRES_SERVER"),
path=f"/{values.get('POSTGRES_DB') or ''}",
)
There are other instances of +something in a URI scheme (git+https comes to mind, as does mongodb+srv from here. Perhaps it would be useful to add to the regex to grab a separate scheme_extra value?
Mainly I think it would be imprudent to try to enumerate all the possible postgres drivers (or other combinations of extra schemes) in Pydantic, so some flexibility here might be warranted.
Maybe an extra_scheme_allowed: bool flag on AnyUrl, defaulting to False?
makes sense.
I would like to submit a pr for that. Is that okay?
yes please.
Most helpful comment
There are other instances of
+somethingin a URI scheme (git+httpscomes to mind, as doesmongodb+srvfrom here. Perhaps it would be useful to add to the regex to grab a separatescheme_extravalue?Mainly I think it would be imprudent to try to enumerate all the possible postgres drivers (or other combinations of extra schemes) in Pydantic, so some flexibility here might be warranted.
Maybe an
extra_scheme_allowed: boolflag onAnyUrl, defaulting toFalse?