Skip to content

Commit b0be7bf

Browse files
committed
Make utils.indent exit stage left.
1 parent fad645f commit b0be7bf

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

jsonschema/_utils.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ def load_schema(name):
5555
return json.loads(data.decode("utf-8"))
5656

5757

58-
def indent(string, times=1):
59-
"""
60-
A dumb version of `textwrap.indent` from Python 3.3.
61-
"""
62-
63-
return "\n".join(" " * (4 * times) + line for line in string.splitlines())
64-
65-
6658
def format_as_index(indices):
6759
"""
6860
Construct a single string containing indexing operations for the indices.

jsonschema/exceptions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def __str__(self):
8080
self.validator,
8181
self._word_for_schema_in_error_message,
8282
_utils.format_as_index(list(self.relative_schema_path)[:-1]),
83-
_utils.indent(pschema),
83+
textwrap.indent(pschema, " "),
8484
self._word_for_instance_in_error_message,
8585
_utils.format_as_index(self.relative_path),
86-
_utils.indent(pinstance),
86+
textwrap.indent(pinstance, " "),
8787
)
8888

8989
@classmethod
@@ -195,7 +195,11 @@ def __str__(self):
195195
While checking instance:
196196
%s
197197
""".rstrip()
198-
) % (self.type, _utils.indent(pschema), _utils.indent(pinstance))
198+
) % (
199+
self.type,
200+
textwrap.indent(pschema, " "),
201+
textwrap.indent(pinstance, " "),
202+
)
199203

200204

201205
class FormatError(Exception):

jsonschema/tests/test_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from jsonschema import ValidationError, _validators
1212
from jsonschema._types import TypeChecker
13-
from jsonschema.exceptions import UndefinedTypeCheck
13+
from jsonschema.exceptions import UndefinedTypeCheck, UnknownType
1414
from jsonschema.validators import Draft4Validator, extend
1515

1616

0 commit comments

Comments
 (0)