Skip to content

Commit 7eec637

Browse files
feat: switch to use third party regex library for extended support
1 parent 720e489 commit 7eec637

File tree

8 files changed

+12
-8
lines changed

8 files changed

+12
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ venv/
2727

2828
# Editors
2929
.vscode
30+
.idea

fastjsonschema/draft04.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import decimal
2-
import re
2+
import regex as re
33

44
from .exceptions import JsonSchemaDefinitionException
55
from .generator import CodeGenerator, enforce_list
@@ -271,7 +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']
274+
self._extra_imports_lines = ['import regex as re']
275275
with self.l('try:', optimize=False):
276276
self.l('re.compile({variable})')
277277
with self.l('except Exception:'):

fastjsonschema/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import re
1+
import regex as re
22

33

44
SPLIT_RE = re.compile(r'[\.\[\]]+')

fastjsonschema/generator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import OrderedDict
22
from decimal import Decimal
3-
import re
3+
import regex as re
44

55
from .exceptions import JsonSchemaValueException, JsonSchemaDefinitionException
66
from .indent import indent
@@ -108,7 +108,7 @@ def global_state_code(self):
108108
'',
109109
])
110110
return '\n'.join(self._extra_imports_lines + [
111-
'import re',
111+
'import regex as re',
112112
'from fastjsonschema import JsonSchemaValueException',
113113
'',
114114
'',

fastjsonschema/ref_resolver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import contextlib
1010
import json
11-
import re
11+
import regex as re
1212
from urllib import parse as urlparse
1313
from urllib.parse import unquote
1414

setup.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
name='fastjsonschema',
1818
version=VERSION,
1919
packages=['fastjsonschema'],
20+
install_requires=[
21+
'regex'
22+
],
2023
extras_require={
2124
'devel': [
2225
'colorama',

tests/test_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
import re
2+
import regex as re
33

44
import pytest
55

tests/test_pattern_serialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import re
1+
import regex as re
22

33
from fastjsonschema.generator import serialize_regexes
44

0 commit comments

Comments
 (0)