Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regex_engine="python-re" if regex uses lookaround #1945

Merged
merged 3 commits into from
Jun 2, 2024

Conversation

camillol
Copy link
Contributor

@camillol camillol commented May 3, 2024

Pydantic 2 uses Rust's regex implementation by default, which runs in linear time but doesn't support lookarounds or backreferences. If a field needs to use such a regex, it is necessary to set up the model's config to use Python's regex engine instead. See documentation.

This change adds the necessary config when generating Pydantic 2 models that contain a field with a pattern containing lookarounds.

Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@fcab9a4). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1945   +/-   ##
=======================================
  Coverage        ?   98.47%           
=======================================
  Files           ?       37           
  Lines           ?     4189           
  Branches        ?      974           
=======================================
  Hits            ?     4125           
  Misses          ?       47           
  Partials        ?       17           
Flag Coverage Δ
unittests 98.13% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented May 3, 2024

CodSpeed Performance Report

Merging #1945 will not alter performance

Comparing camillol:regex_engine (cdcd01d) with main (fcab9a4)

Summary

✅ 29 untouched benchmarks

@camillol camillol force-pushed the regex_engine branch 2 times, most recently from bf1f69d to 7979e94 Compare May 3, 2024 04:33
@koxudaxi koxudaxi merged commit e977ec9 into koxudaxi:main Jun 2, 2024
58 of 94 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.

None yet

2 participants