Skip to content

Commit 52458fe

Browse files
committed
Add re import when using regex pattern
1 parent b0e2bcc commit 52458fe

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fixed detecting when infinity is reached with multipleOf
55
* Fixed that min/max items/lenght/properties can be float
66
* Fixed that everything with empty `not` is invalid
7+
* Fixed missing re import when using regex pattern
78
* Improved regexp for email format to comfort test suite
89
* Improved regexp for date format to comfort test suite
910
* Improved regexp for ipv4 format to comfort test suite

fastjsonschema/draft04.py

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def generate_format(self):
271271
self._generate_format(format_, format_ + '_re_pattern', format_regex)
272272
# Format regex is used only in meta schemas.
273273
elif format_ == 'regex':
274+
self._extra_imports_lines = ['import re']
274275
with self.l('try:', optimize=False):
275276
self.l('re.compile({variable})')
276277
with self.l('except Exception:'):

0 commit comments

Comments
 (0)