Skip to content

Commit f20d248

Browse files
committed
Replace jsonschema's indent utility with textwrap
It was a simpler version of that anyway and now got replaced. See python-jsonschema/jsonschema@b0be7bf We should be jsonschema v4 compatible now.
1 parent fa9e814 commit f20d248

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

glean_parser/util.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ def pprint_validation_error(error) -> str:
313313

314314
description = error.schema.get("description")
315315
if description:
316-
parts.extend(["", "Documentation for this node:", _utils.indent(description)])
316+
parts.extend(
317+
["", "Documentation for this node:", textwrap.indent(description, " ")]
318+
)
317319

318320
return "\n".join(parts)
319321

@@ -327,9 +329,9 @@ def format_error(filepath: Union[str, Path], header: str, content: str) -> str:
327329
else:
328330
filepath = "<string>"
329331
if header:
330-
return f"{filepath}: {header}\n{_utils.indent(content)}"
332+
return f"{filepath}: {header}\n{textwrap.indent(content, ' ')}"
331333
else:
332-
return f"{filepath}:\n{_utils.indent(content)}"
334+
return f"{filepath}:\n{textwrap.indent(content, ' ')}"
333335

334336

335337
def parse_expires(expires: str) -> datetime.date:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"diskcache>=4",
3030
"iso8601>=0.1.10; python_version<='3.6'",
3131
"Jinja2>=2.10.1",
32-
"jsonschema>=3.0.2,<4",
32+
"jsonschema>=3.0.2",
3333
"PyYAML>=5.3.1",
3434
"yamllint>=1.18.0",
3535
]

tests/test_parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import textwrap
99

1010
import pytest
11-
from jsonschema import _utils
1211

1312
from glean_parser import metrics
1413
from glean_parser import parser
@@ -183,7 +182,7 @@ def test_parser_schema_violation():
183182
]
184183

185184
expected_errors = set(
186-
re.sub(r"\s", "", _utils.indent(textwrap.dedent(x)).strip())
185+
re.sub(r"\s", "", textwrap.indent(textwrap.dedent(x), " ").strip())
187186
for x in expected_errors
188187
)
189188

0 commit comments

Comments
 (0)