Skip to content

Commit 7ee391c

Browse files
committed
Revert "Respect ECMA regex syntax for schemas."
This reverts commit 1a02f54, reversing changes made to cbb222c.
1 parent ccdeeb3 commit 7ee391c

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

jsonschema/_format.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import socket
44
import struct
55

6-
import js_regex
7-
86
from jsonschema.compat import str_types
97
from jsonschema.exceptions import FormatError
108

@@ -299,11 +297,11 @@ def is_time(instance):
299297
return is_datetime("1970-01-01T" + instance)
300298

301299

302-
@_checks_drafts(name="regex", raises=(re.error, js_regex.NotJavascriptRegex))
300+
@_checks_drafts(name="regex", raises=re.error)
303301
def is_regex(instance):
304302
if not isinstance(instance, str_types):
305303
return True
306-
return js_regex.compile(instance)
304+
return re.compile(instance)
307305

308306

309307
@_checks_drafts(draft3="date", draft7="date", raises=ValueError)

jsonschema/_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import itertools
22
import json
33
import pkgutil
4-
5-
import js_regex
4+
import re
65

76
from jsonschema.compat import MutableMapping, str_types, urlsplit
87

@@ -93,10 +92,10 @@ def find_additional_properties(instance, schema):
9392
"""
9493

9594
properties = schema.get("properties", {})
96-
patterns = "|".join(sorted(schema.get("patternProperties", {})))
95+
patterns = "|".join(schema.get("patternProperties", {}))
9796
for property in instance:
9897
if property not in properties:
99-
if patterns and js_regex.compile(patterns).search(property):
98+
if patterns and re.search(patterns, property):
10099
continue
101100
yield property
102101

jsonschema/_validators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import js_regex
1+
import re
22

33
from jsonschema._utils import (
44
ensure_list,
@@ -19,7 +19,7 @@ def patternProperties(validator, patternProperties, instance, schema):
1919

2020
for pattern, subschema in iteritems(patternProperties):
2121
for k, v in iteritems(instance):
22-
if js_regex.compile(pattern).search(k):
22+
if re.search(pattern, k):
2323
for error in validator.descend(
2424
v, subschema, path=k, schema_path=pattern,
2525
):
@@ -197,7 +197,7 @@ def uniqueItems(validator, uI, instance, schema):
197197
def pattern(validator, patrn, instance, schema):
198198
if (
199199
validator.is_type(instance, "string") and
200-
not js_regex.compile(patrn).search(instance)
200+
not re.search(patrn, instance)
201201
):
202202
yield ValidationError("%r does not match %r" % (instance, patrn))
203203

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def narrow_unicode_build(test): # pragma: no cover
6868

6969
TestDraft3 = DRAFT3.to_unittest_testcase(
7070
DRAFT3.tests(),
71-
DRAFT3.optional_tests_of(name="bignum"),
7271
DRAFT3.optional_tests_of(name="format"),
72+
DRAFT3.optional_tests_of(name="bignum"),
7373
DRAFT3.optional_tests_of(name="zeroTerminatedFloats"),
7474
Validator=Draft3Validator,
7575
format_checker=draft3_format_checker,
@@ -87,9 +87,8 @@ def narrow_unicode_build(test): # pragma: no cover
8787

8888
TestDraft4 = DRAFT4.to_unittest_testcase(
8989
DRAFT4.tests(),
90-
DRAFT4.optional_tests_of(name="bignum"),
91-
DRAFT4.optional_tests_of(name="ecmascript-regex"),
9290
DRAFT4.optional_tests_of(name="format"),
91+
DRAFT4.optional_tests_of(name="bignum"),
9392
DRAFT4.optional_tests_of(name="zeroTerminatedFloats"),
9493
Validator=Draft4Validator,
9594
format_checker=draft4_format_checker,
@@ -136,9 +135,8 @@ def narrow_unicode_build(test): # pragma: no cover
136135

137136
TestDraft6 = DRAFT6.to_unittest_testcase(
138137
DRAFT6.tests(),
139-
DRAFT6.optional_tests_of(name="bignum"),
140-
DRAFT6.optional_tests_of(name="ecmascript-regex"),
141138
DRAFT6.optional_tests_of(name="format"),
139+
DRAFT6.optional_tests_of(name="bignum"),
142140
DRAFT6.optional_tests_of(name="zeroTerminatedFloats"),
143141
Validator=Draft6Validator,
144142
format_checker=draft6_format_checker,
@@ -187,9 +185,8 @@ def narrow_unicode_build(test): # pragma: no cover
187185
DRAFT7.tests(),
188186
DRAFT7.format_tests(),
189187
DRAFT7.optional_tests_of(name="bignum"),
190-
DRAFT7.optional_tests_of(name="content"),
191-
DRAFT7.optional_tests_of(name="ecmascript-regex"),
192188
DRAFT7.optional_tests_of(name="zeroTerminatedFloats"),
189+
DRAFT7.optional_tests_of(name="content"),
193190
Validator=Draft7Validator,
194191
format_checker=draft7_format_checker,
195192
skip=lambda test: (

jsonschema/tests/test_validators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ def test_recursive(self):
849849
"children": {
850850
"type": "object",
851851
"patternProperties": {
852-
u"^.*$": {
852+
"^.*$": {
853853
"$ref": "#/definitions/node",
854854
},
855855
},
@@ -951,8 +951,8 @@ def test_patternProperties(self):
951951
instance = {"bar": 1, "foo": 2}
952952
schema = {
953953
"patternProperties": {
954-
u"bar": {"type": "string"},
955-
u"foo": {"minimum": 5},
954+
"bar": {"type": "string"},
955+
"foo": {"minimum": 5},
956956
},
957957
}
958958

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ setup_requires = setuptools_scm
2828
install_requires =
2929
attrs>=17.4.0
3030
importlib_metadata
31-
js-regex>=1.0.0
3231
pyrsistent>=0.14.0
3332
setuptools
3433
six>=1.11.0

0 commit comments

Comments
 (0)