Skip to content

feat: migrate DSN types from pydantic.networks#368

Merged
yezz123 merged 1 commit intopydantic:mainfrom
bBlazewavE:feat/dsn-types-migration
Mar 1, 2026
Merged

feat: migrate DSN types from pydantic.networks#368
yezz123 merged 1 commit intopydantic:mainfrom
bBlazewavE:feat/dsn-types-migration

Conversation

@bBlazewavE
Copy link
Contributor

Summary

Migrates all DSN types from pydantic.networks to pydantic-extra-types as preparation for pydantic V3.

Closes pydantic/pydantic#9071

Types Migrated

Type Base Schemes
PostgresDsn MultiHostUrl postgres, postgresql+asyncpg, +psycopg2, etc
CockroachDsn Url cockroachdb, +psycopg2, +asyncpg
AmqpDsn Url amqp, amqps
RedisDsn Url redis, rediss
MongoDsn MultiHostUrl mongodb, mongodb+srv
KafkaDsn Url kafka
NatsDsn MultiHostUrl nats, tls, ws
MySQLDsn Url mysql, +pymysql, +asyncmy, etc
MariaDBDsn Url mariadb, +pymysql, etc
ClickHouseDsn Url clickhouse, +native, +asynch
SnowflakeDsn Url snowflake

Implementation

Each type uses Annotated[Url/MultiHostUrl, UrlConstraints(...)] pattern, consistent with pydantic-core types. Multi-host types (Postgres, Mongo, NATS) use MultiHostUrl base.

Files

  • pydantic_extra_types/dsn.py — All 11 DSN type definitions with docstrings and examples
  • tests/test_dsn.py — Comprehensive test suite covering valid URLs, invalid scheme rejection, and host-required validation

Testing

All 13 test cases pass. Tests cover:

  • Valid DSN parsing for each type
  • Invalid scheme rejection
  • Host-required enforcement
  • Cross-type validation

@bBlazewavE bBlazewavE closed this Feb 28, 2026
@yezz123
Copy link
Collaborator

yezz123 commented Feb 28, 2026

Hello @bBlazewavE you can complete the work on this pr i will be happy to merge it as soon as everything migrated and all the tests passed

@bBlazewavE bBlazewavE reopened this Feb 28, 2026
@bBlazewavE bBlazewavE force-pushed the feat/dsn-types-migration branch 4 times, most recently from e576ae1 to bbf948d Compare February 28, 2026 20:29
@bBlazewavE
Copy link
Contributor Author

Hello @bBlazewavE you can complete the work on this pr i will be happy to merge it as soon as everything migrated and all the tests passed

Hi @yezz123 I have fixed the test on this PR, it's ready for review ! : )

Migrates all DSN types (PostgresDsn, RedisDsn, MongoDsn, MySQLDsn,
MariaDBDsn, KafkaDsn, CockroachDsn, AmqpDsn, NatsDsn, ClickHouseDsn,
SnowflakeDsn) from pydantic.networks to pydantic-extra-types as prep
for pydantic V3.

Closes pydantic/pydantic#9071
@bBlazewavE bBlazewavE force-pushed the feat/dsn-types-migration branch from bbf948d to 41103f3 Compare February 28, 2026 20:57
Copy link
Collaborator

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks clean 👍🏻

I will merge it

@yezz123 yezz123 merged commit 07628d1 into pydantic:main Mar 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start migrating dsn types over to pydantic-extra-types

2 participants