Skip to content

Commit

Permalink
Add re import when using regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
horejsek committed Nov 27, 2024
1 parent b0e2bcc commit 52458fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fixed detecting when infinity is reached with multipleOf
* Fixed that min/max items/lenght/properties can be float
* Fixed that everything with empty `not` is invalid
* Fixed missing re import when using regex pattern
* Improved regexp for email format to comfort test suite
* Improved regexp for date format to comfort test suite
* Improved regexp for ipv4 format to comfort test suite
Expand Down
1 change: 1 addition & 0 deletions fastjsonschema/draft04.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def generate_format(self):
self._generate_format(format_, format_ + '_re_pattern', format_regex)
# Format regex is used only in meta schemas.
elif format_ == 'regex':
self._extra_imports_lines = ['import re']
with self.l('try:', optimize=False):
self.l('re.compile({variable})')
with self.l('except Exception:'):
Expand Down

0 comments on commit 52458fe

Please sign in to comment.