Skip to content

Conversation

sydney-runkle
Copy link
Contributor

@sydney-runkle sydney-runkle commented Sep 30, 2024

ConfigDict.protected_namespaces now supports matching on compiled patterns.

Whereas we used to only support prefix check for str type protected namespaces, this now expands the customizability of a protected namespace significantly.

Copy link

cloudflare-workers-and-pages bot commented Sep 30, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 35804ff
Status: ✅  Deploy successful!
Preview URL: https://d4c38ffd.pydantic-docs.pages.dev
Branch Preview URL: https://support-re-for-protected-ns.pydantic-docs.pages.dev

View logs

Copy link

codspeed-hq bot commented Sep 30, 2024

CodSpeed Performance Report

Merging #10522 will not alter performance

Comparing support-re-for-protected-ns (35804ff) with main (9de0648)

Summary

✅ 38 untouched benchmarks

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Coverage report

This PR does not seem to contain any modification to coverable code.

if ann_name.startswith(protected_namespace):
ns_violation: bool = False
if isinstance(protected_namespace, Pattern):
ns_violation = protected_namespace.match(ann_name) is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

Is match better than fullmatch here? I think match might be equally capable and more practical (don't need to include .* on the end to serve as a prefix match I guess), just want to make sure you've thought about it and decided to go with match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question - I think match is more practical, as you can use special characters (ex: ^<pattern>$) to basically ensure fullmatch behavior, whereas fullmatch does that by default and thus offers less customizability 👍

sydney-runkle and others added 4 commits October 1, 2024 17:18
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Merge branch 'support-re-for-protected-ns' of https://github.com/pydantic/pydantic into support-re-for-protected-ns
@sydney-runkle sydney-runkle enabled auto-merge (squash) October 2, 2024 13:27
@sydney-runkle sydney-runkle merged commit 296f2ca into main Oct 2, 2024
58 checks passed
@sydney-runkle sydney-runkle deleted the support-re-for-protected-ns branch October 2, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants