Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Add option to preserve empty URL paths - #1789

Merged
davidhewitt merged 4 commits into
mainfrom
dh/url-preserve-empty-path
Oct 1, 2025
Merged

davidhewitt merged 4 commits into
mainfrom
dh/url-preserve-empty-path

Conversation

@davidhewitt

@davidhewitt davidhewitt commented Sep 16, 2025 •

Copy link
Copy Markdown
Collaborator

Change Summary

My take on #1719.

I am reasonably confident that the issue only applies to empty paths, so in this variation I named the config option preserve_empty_path (default False for backwards compatibility).

Related issue number

pydantic/pydantic#7186

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@codspeed

codspeed Bot commented Sep 16, 2025 •

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #1789 will not alter performance

Comparing dh/url-preserve-empty-path (e527443) with main (ed0d1ca)

Summary

✅ 163 untouched

@davidhewitt
davidhewitt marked this pull request as ready for review September 18, 2025 13:07
@Viicos Viicos changed the title add option to preserve empty URL paths Add option to preserve empty URL paths Sep 29, 2025

@Viicos Viicos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Comment thread src/url.rs
}

pub fn __str__(&self) -> String {
pub fn __str__(&self, py: Python<'_>) -> String {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If str(...) is called from Python, I assume this doesn't error because of a missing argument (same for other methods)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed PyO3 will fill in Python<'_> as a special argument.

Comment thread src/validators/url.rs Outdated
davidhewitt and others added 2 commits October 1, 2025 11:17
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
@davidhewitt
davidhewitt merged commit 400a083 into main Oct 1, 2025
32 checks passed
@davidhewitt
davidhewitt deleted the dh/url-preserve-empty-path branch October 1, 2025 11:13
davidhewitt added a commit to pydantic/pydantic that referenced this pull request Oct 20, 2025
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>

Original-commit-hash: 400a083
davidhewitt added a commit to pydantic/pydantic that referenced this pull request Oct 22, 2025
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>

Original-commit-link: pydantic/pydantic-core@400a083
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants