ADAPT-Chase commited on
Commit
f6553fb
·
verified ·
1 Parent(s): 222de8f

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. tool_server/.venv/lib/python3.12/site-packages/jsonschema-4.25.1.dist-info/licenses/COPYING +19 -0
  3. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__init__.cpython-312.pyc +0 -0
  4. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__main__.cpython-312.pyc +0 -0
  5. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_format.cpython-312.pyc +0 -0
  6. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_keywords.cpython-312.pyc +0 -0
  7. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_legacy_keywords.cpython-312.pyc +0 -0
  8. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_types.cpython-312.pyc +0 -0
  9. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_typing.cpython-312.pyc +0 -0
  10. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_utils.cpython-312.pyc +0 -0
  11. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/cli.cpython-312.pyc +0 -0
  12. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/exceptions.cpython-312.pyc +0 -0
  13. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/protocols.cpython-312.pyc +0 -0
  14. tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/validators.cpython-312.pyc +0 -0
  15. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__init__.py +5 -0
  16. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/__init__.cpython-312.pyc +0 -0
  17. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/const_vs_enum.cpython-312.pyc +0 -0
  18. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/contains.cpython-312.pyc +0 -0
  19. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/issue232.cpython-312.pyc +0 -0
  20. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/json_schema_test_suite.cpython-312.pyc +0 -0
  21. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/nested_schemas.cpython-312.pyc +0 -0
  22. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/subcomponents.cpython-312.pyc +0 -0
  23. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/unused_registry.cpython-312.pyc +0 -0
  24. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/useless_applicator_schemas.cpython-312.pyc +0 -0
  25. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/useless_keywords.cpython-312.pyc +0 -0
  26. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/validator_creation.cpython-312.pyc +0 -0
  27. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/const_vs_enum.py +30 -0
  28. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/contains.py +28 -0
  29. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232.py +25 -0
  30. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232/issue.json +0 -0
  31. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/json_schema_test_suite.py +12 -0
  32. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/nested_schemas.py +56 -0
  33. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/subcomponents.py +42 -0
  34. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/unused_registry.py +35 -0
  35. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/useless_applicator_schemas.py +106 -0
  36. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/useless_keywords.py +32 -0
  37. tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/validator_creation.py +14 -0
  38. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__init__.py +0 -0
  39. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  40. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/_suite.cpython-312.pyc +0 -0
  41. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/fuzz_validate.cpython-312.pyc +0 -0
  42. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_cli.cpython-312.pyc +0 -0
  43. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_deprecations.cpython-312.pyc +0 -0
  44. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-312.pyc +0 -0
  45. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_format.cpython-312.pyc +0 -0
  46. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_jsonschema_test_suite.cpython-312.pyc +0 -0
  47. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_types.cpython-312.pyc +0 -0
  48. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_utils.cpython-312.pyc +0 -0
  49. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc +3 -0
  50. tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/_suite.py +285 -0
.gitattributes CHANGED
@@ -4506,3 +4506,6 @@ tool_server/.venv/lib/python3.12/site-packages/torch/utils/__pycache__/cpp_exten
4506
  tool_server/.venv/lib/python3.12/site-packages/torch/utils/hipify/__pycache__/cuda_to_hip_mappings.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4507
  tool_server/.venv/lib/python3.12/site-packages/torchgen/__pycache__/gen.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4508
  tool_server/.venv/lib/python3.12/site-packages/torchgen/__pycache__/model.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
4506
  tool_server/.venv/lib/python3.12/site-packages/torch/utils/hipify/__pycache__/cuda_to_hip_mappings.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4507
  tool_server/.venv/lib/python3.12/site-packages/torchgen/__pycache__/gen.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4508
  tool_server/.venv/lib/python3.12/site-packages/torchgen/__pycache__/model.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4509
+ tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4510
+ tool_server/.venv/lib/python3.12/site-packages/xformers/flash_attn_3/_C.so filter=lfs diff=lfs merge=lfs -text
4511
+ tool_server/.venv/lib/python3.12/site-packages/xformers/_flash_attn/flash_attn_triton_amd/__pycache__/bwd_prefill_fused.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
tool_server/.venv/lib/python3.12/site-packages/jsonschema-4.25.1.dist-info/licenses/COPYING ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2013 Julian Berman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (3.78 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/__main__.cpython-312.pyc ADDED
Binary file (335 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_format.cpython-312.pyc ADDED
Binary file (18.4 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_keywords.cpython-312.pyc ADDED
Binary file (19.6 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_legacy_keywords.cpython-312.pyc ADDED
Binary file (17.1 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_types.cpython-312.pyc ADDED
Binary file (7.11 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_typing.cpython-312.pyc ADDED
Binary file (1.34 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/_utils.cpython-312.pyc ADDED
Binary file (14.3 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/cli.cpython-312.pyc ADDED
Binary file (12.2 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/exceptions.cpython-312.pyc ADDED
Binary file (21.7 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/protocols.cpython-312.pyc ADDED
Binary file (6.84 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/__pycache__/validators.cpython-312.pyc ADDED
Binary file (52.9 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ Benchmarks for validation.
3
+
4
+ This package is *not* public API.
5
+ """
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (271 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/const_vs_enum.cpython-312.pyc ADDED
Binary file (1.89 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/contains.cpython-312.pyc ADDED
Binary file (1.92 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/issue232.cpython-312.pyc ADDED
Binary file (896 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/json_schema_test_suite.cpython-312.pyc ADDED
Binary file (641 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/nested_schemas.cpython-312.pyc ADDED
Binary file (2.47 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/subcomponents.cpython-312.pyc ADDED
Binary file (2.27 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/unused_registry.cpython-312.pyc ADDED
Binary file (1.58 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/useless_applicator_schemas.cpython-312.pyc ADDED
Binary file (3.56 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/useless_keywords.cpython-312.pyc ADDED
Binary file (2.07 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/__pycache__/validator_creation.cpython-312.pyc ADDED
Binary file (561 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/const_vs_enum.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A benchmark for comparing equivalent validation of `const` and `enum`.
3
+ """
4
+
5
+ from pyperf import Runner
6
+
7
+ from jsonschema import Draft202012Validator
8
+
9
+ value = [37] * 100
10
+ const_schema = {"const": list(value)}
11
+ enum_schema = {"enum": [list(value)]}
12
+
13
+ valid = list(value)
14
+ invalid = [*valid, 73]
15
+
16
+ const = Draft202012Validator(const_schema)
17
+ enum = Draft202012Validator(enum_schema)
18
+
19
+ assert const.is_valid(valid)
20
+ assert enum.is_valid(valid)
21
+ assert not const.is_valid(invalid)
22
+ assert not enum.is_valid(invalid)
23
+
24
+
25
+ if __name__ == "__main__":
26
+ runner = Runner()
27
+ runner.bench_func("const valid", lambda: const.is_valid(valid))
28
+ runner.bench_func("const invalid", lambda: const.is_valid(invalid))
29
+ runner.bench_func("enum valid", lambda: enum.is_valid(valid))
30
+ runner.bench_func("enum invalid", lambda: enum.is_valid(invalid))
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/contains.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A benchmark for validation of the `contains` keyword.
3
+ """
4
+
5
+ from pyperf import Runner
6
+
7
+ from jsonschema import Draft202012Validator
8
+
9
+ schema = {
10
+ "type": "array",
11
+ "contains": {"const": 37},
12
+ }
13
+ validator = Draft202012Validator(schema)
14
+
15
+ size = 1000
16
+ beginning = [37] + [0] * (size - 1)
17
+ middle = [0] * (size // 2) + [37] + [0] * (size // 2)
18
+ end = [0] * (size - 1) + [37]
19
+ invalid = [0] * size
20
+
21
+
22
+ if __name__ == "__main__":
23
+ runner = Runner()
24
+ runner.bench_func("baseline", lambda: validator.is_valid([]))
25
+ runner.bench_func("beginning", lambda: validator.is_valid(beginning))
26
+ runner.bench_func("middle", lambda: validator.is_valid(middle))
27
+ runner.bench_func("end", lambda: validator.is_valid(end))
28
+ runner.bench_func("invalid", lambda: validator.is_valid(invalid))
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A performance benchmark using the example from issue #232.
3
+
4
+ See https://github.com/python-jsonschema/jsonschema/pull/232.
5
+ """
6
+ from pathlib import Path
7
+
8
+ from pyperf import Runner
9
+ from referencing import Registry
10
+
11
+ from jsonschema.tests._suite import Version
12
+ import jsonschema
13
+
14
+ issue232 = Version(
15
+ path=Path(__file__).parent / "issue232",
16
+ remotes=Registry(),
17
+ name="issue232",
18
+ )
19
+
20
+
21
+ if __name__ == "__main__":
22
+ issue232.benchmark(
23
+ runner=Runner(),
24
+ Validator=jsonschema.Draft4Validator,
25
+ )
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/issue232/issue.json ADDED
The diff for this file is too large to render. See raw diff
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/json_schema_test_suite.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A performance benchmark using the official test suite.
3
+
4
+ This benchmarks jsonschema using every valid example in the
5
+ JSON-Schema-Test-Suite. It will take some time to complete.
6
+ """
7
+ from pyperf import Runner
8
+
9
+ from jsonschema.tests._suite import Suite
10
+
11
+ if __name__ == "__main__":
12
+ Suite().benchmark(runner=Runner())
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/nested_schemas.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Validating highly nested schemas shouldn't cause exponential time blowups.
3
+
4
+ See https://github.com/python-jsonschema/jsonschema/issues/1097.
5
+ """
6
+ from itertools import cycle
7
+
8
+ from jsonschema.validators import validator_for
9
+
10
+ metaschemaish = {
11
+ "$id": "https://example.com/draft/2020-12/schema/strict",
12
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
13
+
14
+ "$vocabulary": {
15
+ "https://json-schema.org/draft/2020-12/vocab/core": True,
16
+ "https://json-schema.org/draft/2020-12/vocab/applicator": True,
17
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated": True,
18
+ "https://json-schema.org/draft/2020-12/vocab/validation": True,
19
+ "https://json-schema.org/draft/2020-12/vocab/meta-data": True,
20
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation": True,
21
+ "https://json-schema.org/draft/2020-12/vocab/content": True,
22
+ },
23
+ "$dynamicAnchor": "meta",
24
+
25
+ "$ref": "https://json-schema.org/draft/2020-12/schema",
26
+ "unevaluatedProperties": False,
27
+ }
28
+
29
+
30
+ def nested_schema(levels):
31
+ """
32
+ Produce a schema which validates deeply nested objects and arrays.
33
+ """
34
+
35
+ names = cycle(["foo", "bar", "baz", "quux", "spam", "eggs"])
36
+ schema = {"type": "object", "properties": {"ham": {"type": "string"}}}
37
+ for _, name in zip(range(levels - 1), names):
38
+ schema = {"type": "object", "properties": {name: schema}}
39
+ return schema
40
+
41
+
42
+ validator = validator_for(metaschemaish)(metaschemaish)
43
+
44
+ if __name__ == "__main__":
45
+ from pyperf import Runner
46
+ runner = Runner()
47
+
48
+ not_nested = nested_schema(levels=1)
49
+ runner.bench_func("not nested", lambda: validator.is_valid(not_nested))
50
+
51
+ for levels in range(1, 11, 3):
52
+ schema = nested_schema(levels=levels)
53
+ runner.bench_func(
54
+ f"nested * {levels}",
55
+ lambda schema=schema: validator.is_valid(schema),
56
+ )
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/subcomponents.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A benchmark which tries to compare the possible slow subparts of validation.
3
+ """
4
+ from referencing import Registry
5
+ from referencing.jsonschema import DRAFT202012
6
+ from rpds import HashTrieMap, HashTrieSet
7
+
8
+ from jsonschema import Draft202012Validator
9
+
10
+ schema = {
11
+ "type": "array",
12
+ "minLength": 1,
13
+ "maxLength": 1,
14
+ "items": {"type": "integer"},
15
+ }
16
+
17
+ hmap = HashTrieMap()
18
+ hset = HashTrieSet()
19
+
20
+ registry = Registry()
21
+
22
+ v = Draft202012Validator(schema)
23
+
24
+
25
+ def registry_data_structures():
26
+ return hmap.insert("foo", "bar"), hset.insert("foo")
27
+
28
+
29
+ def registry_add():
30
+ resource = DRAFT202012.create_resource(schema)
31
+ return registry.with_resource(uri="urn:example", resource=resource)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ from pyperf import Runner
36
+ runner = Runner()
37
+
38
+ runner.bench_func("HashMap/HashSet insertion", registry_data_structures)
39
+ runner.bench_func("Registry insertion", registry_add)
40
+ runner.bench_func("Success", lambda: v.is_valid([1]))
41
+ runner.bench_func("Failure", lambda: v.is_valid(["foo"]))
42
+ runner.bench_func("Metaschema validation", lambda: v.check_schema(schema))
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/unused_registry.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ An unused schema registry should not cause slower validation.
3
+
4
+ "Unused" here means one where no reference resolution is occurring anyhow.
5
+
6
+ See https://github.com/python-jsonschema/jsonschema/issues/1088.
7
+ """
8
+ from pyperf import Runner
9
+ from referencing import Registry
10
+ from referencing.jsonschema import DRAFT201909
11
+
12
+ from jsonschema import Draft201909Validator
13
+
14
+ registry = Registry().with_resource(
15
+ "urn:example:foo",
16
+ DRAFT201909.create_resource({}),
17
+ )
18
+
19
+ schema = {"$ref": "https://json-schema.org/draft/2019-09/schema"}
20
+ instance = {"maxLength": 4}
21
+
22
+ no_registry = Draft201909Validator(schema)
23
+ with_useless_registry = Draft201909Validator(schema, registry=registry)
24
+
25
+ if __name__ == "__main__":
26
+ runner = Runner()
27
+
28
+ runner.bench_func(
29
+ "no registry",
30
+ lambda: no_registry.is_valid(instance),
31
+ )
32
+ runner.bench_func(
33
+ "useless registry",
34
+ lambda: with_useless_registry.is_valid(instance),
35
+ )
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/useless_applicator_schemas.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ """
3
+ A benchmark for validation of applicators containing lots of useless schemas.
4
+
5
+ Signals a small possible optimization to remove all such schemas ahead of time.
6
+ """
7
+
8
+ from pyperf import Runner
9
+
10
+ from jsonschema import Draft202012Validator as Validator
11
+
12
+ NUM_USELESS = 100000
13
+
14
+ subschema = {"const": 37}
15
+
16
+ valid = 37
17
+ invalid = 12
18
+
19
+ baseline = Validator(subschema)
20
+
21
+
22
+ # These should be indistinguishable from just `subschema`
23
+ by_name = {
24
+ "single subschema": {
25
+ "anyOf": Validator({"anyOf": [subschema]}),
26
+ "allOf": Validator({"allOf": [subschema]}),
27
+ "oneOf": Validator({"oneOf": [subschema]}),
28
+ },
29
+ "redundant subschemas": {
30
+ "anyOf": Validator({"anyOf": [subschema] * NUM_USELESS}),
31
+ "allOf": Validator({"allOf": [subschema] * NUM_USELESS}),
32
+ },
33
+ "useless successful subschemas (beginning)": {
34
+ "anyOf": Validator({"anyOf": [subschema, *[True] * NUM_USELESS]}),
35
+ "allOf": Validator({"allOf": [subschema, *[True] * NUM_USELESS]}),
36
+ },
37
+ "useless successful subschemas (middle)": {
38
+ "anyOf": Validator(
39
+ {
40
+ "anyOf": [
41
+ *[True] * (NUM_USELESS // 2),
42
+ subschema,
43
+ *[True] * (NUM_USELESS // 2),
44
+ ],
45
+ },
46
+ ),
47
+ "allOf": Validator(
48
+ {
49
+ "allOf": [
50
+ *[True] * (NUM_USELESS // 2),
51
+ subschema,
52
+ *[True] * (NUM_USELESS // 2),
53
+ ],
54
+ },
55
+ ),
56
+ },
57
+ "useless successful subschemas (end)": {
58
+ "anyOf": Validator({"anyOf": [*[True] * NUM_USELESS, subschema]}),
59
+ "allOf": Validator({"allOf": [*[True] * NUM_USELESS, subschema]}),
60
+ },
61
+ "useless failing subschemas (beginning)": {
62
+ "anyOf": Validator({"anyOf": [subschema, *[False] * NUM_USELESS]}),
63
+ "oneOf": Validator({"oneOf": [subschema, *[False] * NUM_USELESS]}),
64
+ },
65
+ "useless failing subschemas (middle)": {
66
+ "anyOf": Validator(
67
+ {
68
+ "anyOf": [
69
+ *[False] * (NUM_USELESS // 2),
70
+ subschema,
71
+ *[False] * (NUM_USELESS // 2),
72
+ ],
73
+ },
74
+ ),
75
+ "oneOf": Validator(
76
+ {
77
+ "oneOf": [
78
+ *[False] * (NUM_USELESS // 2),
79
+ subschema,
80
+ *[False] * (NUM_USELESS // 2),
81
+ ],
82
+ },
83
+ ),
84
+ },
85
+ "useless failing subschemas (end)": {
86
+ "anyOf": Validator({"anyOf": [*[False] * NUM_USELESS, subschema]}),
87
+ "oneOf": Validator({"oneOf": [*[False] * NUM_USELESS, subschema]}),
88
+ },
89
+ }
90
+
91
+ if __name__ == "__main__":
92
+ runner = Runner()
93
+
94
+ runner.bench_func("baseline valid", lambda: baseline.is_valid(valid))
95
+ runner.bench_func("baseline invalid", lambda: baseline.is_valid(invalid))
96
+
97
+ for group, applicators in by_name.items():
98
+ for applicator, validator in applicators.items():
99
+ runner.bench_func(
100
+ f"{group}: {applicator} valid",
101
+ lambda validator=validator: validator.is_valid(valid),
102
+ )
103
+ runner.bench_func(
104
+ f"{group}: {applicator} invalid",
105
+ lambda validator=validator: validator.is_valid(invalid),
106
+ )
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/useless_keywords.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A benchmark for validation of schemas containing lots of useless keywords.
3
+
4
+ Checks we filter them out once, ahead of time.
5
+ """
6
+
7
+ from pyperf import Runner
8
+
9
+ from jsonschema import Draft202012Validator
10
+
11
+ NUM_USELESS = 100000
12
+ schema = dict(
13
+ [
14
+ ("not", {"const": 42}),
15
+ *((str(i), i) for i in range(NUM_USELESS)),
16
+ ("type", "integer"),
17
+ *((str(i), i) for i in range(NUM_USELESS, NUM_USELESS)),
18
+ ("minimum", 37),
19
+ ],
20
+ )
21
+ validator = Draft202012Validator(schema)
22
+
23
+ valid = 3737
24
+ invalid = 12
25
+
26
+
27
+ if __name__ == "__main__":
28
+ runner = Runner()
29
+ runner.bench_func("beginning of schema", lambda: validator.is_valid(42))
30
+ runner.bench_func("middle of schema", lambda: validator.is_valid("foo"))
31
+ runner.bench_func("end of schema", lambda: validator.is_valid(12))
32
+ runner.bench_func("valid", lambda: validator.is_valid(3737))
tool_server/.venv/lib/python3.12/site-packages/jsonschema/benchmarks/validator_creation.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyperf import Runner
2
+
3
+ from jsonschema import Draft202012Validator
4
+
5
+ schema = {
6
+ "type": "array",
7
+ "minLength": 1,
8
+ "maxLength": 1,
9
+ "items": {"type": "integer"},
10
+ }
11
+
12
+
13
+ if __name__ == "__main__":
14
+ Runner().bench_func("validator creation", Draft202012Validator, schema)
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__init__.py ADDED
File without changes
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (186 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/_suite.cpython-312.pyc ADDED
Binary file (13.1 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/fuzz_validate.cpython-312.pyc ADDED
Binary file (2.34 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_cli.cpython-312.pyc ADDED
Binary file (33.4 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_deprecations.cpython-312.pyc ADDED
Binary file (25.3 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-312.pyc ADDED
Binary file (33.4 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_format.cpython-312.pyc ADDED
Binary file (6.46 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_jsonschema_test_suite.cpython-312.pyc ADDED
Binary file (10.5 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_types.cpython-312.pyc ADDED
Binary file (11.9 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_utils.cpython-312.pyc ADDED
Binary file (7.9 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/__pycache__/test_validators.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f85dad42c3e6833a418a2b16908d7f292ceaaef85226b2cd8e54059218b6d22
3
+ size 132029
tool_server/.venv/lib/python3.12/site-packages/jsonschema/tests/_suite.py ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Python representations of the JSON Schema Test Suite tests.
3
+ """
4
+ from __future__ import annotations
5
+
6
+ from contextlib import suppress
7
+ from functools import partial
8
+ from pathlib import Path
9
+ from typing import TYPE_CHECKING, Any
10
+ import json
11
+ import os
12
+ import re
13
+ import sys
14
+ import unittest
15
+
16
+ from attrs import field, frozen
17
+ from referencing import Registry
18
+ import referencing.jsonschema
19
+
20
+ if TYPE_CHECKING:
21
+ from collections.abc import Iterable, Mapping, Sequence
22
+
23
+ from referencing.jsonschema import Schema
24
+ import pyperf
25
+
26
+ from jsonschema.validators import _VALIDATORS
27
+ import jsonschema
28
+
29
+ MAGIC_REMOTE_URL = "http://localhost:1234"
30
+
31
+ _DELIMITERS = re.compile(r"[\W\- ]+")
32
+
33
+
34
+ def _find_suite():
35
+ root = os.environ.get("JSON_SCHEMA_TEST_SUITE")
36
+ if root is not None:
37
+ return Path(root)
38
+
39
+ root = Path(jsonschema.__file__).parent.parent / "json"
40
+ if not root.is_dir(): # pragma: no cover
41
+ raise ValueError(
42
+ (
43
+ "Can't find the JSON-Schema-Test-Suite directory. "
44
+ "Set the 'JSON_SCHEMA_TEST_SUITE' environment "
45
+ "variable or run the tests from alongside a checkout "
46
+ "of the suite."
47
+ ),
48
+ )
49
+ return root
50
+
51
+
52
+ @frozen
53
+ class Suite:
54
+
55
+ _root: Path = field(factory=_find_suite)
56
+
57
+
58
+ def benchmark(self, runner: pyperf.Runner): # pragma: no cover
59
+ for name, Validator in _VALIDATORS.items():
60
+ self.version(name=name).benchmark(
61
+ runner=runner,
62
+ Validator=Validator,
63
+ )
64
+
65
+ def version(self, name) -> Version:
66
+ Validator = _VALIDATORS[name]
67
+ uri: str = Validator.ID_OF(Validator.META_SCHEMA) # type: ignore[assignment]
68
+ specification = referencing.jsonschema.specification_with(uri)
69
+
70
+ registry = Registry().with_contents(
71
+ remotes_in(root=self._root / "remotes", name=name, uri=uri),
72
+ default_specification=specification,
73
+ )
74
+ return Version(
75
+ name=name,
76
+ path=self._root / "tests" / name,
77
+ remotes=registry,
78
+ )
79
+
80
+
81
+ @frozen
82
+ class Version:
83
+
84
+ _path: Path
85
+ _remotes: referencing.jsonschema.SchemaRegistry
86
+
87
+ name: str
88
+
89
+ def benchmark(self, **kwargs): # pragma: no cover
90
+ for case in self.cases():
91
+ case.benchmark(**kwargs)
92
+
93
+ def cases(self) -> Iterable[_Case]:
94
+ return self._cases_in(paths=self._path.glob("*.json"))
95
+
96
+ def format_cases(self) -> Iterable[_Case]:
97
+ return self._cases_in(paths=self._path.glob("optional/format/*.json"))
98
+
99
+ def optional_cases_of(self, name: str) -> Iterable[_Case]:
100
+ return self._cases_in(paths=[self._path / "optional" / f"{name}.json"])
101
+
102
+ def to_unittest_testcase(self, *groups, **kwargs):
103
+ name = kwargs.pop("name", "Test" + self.name.title().replace("-", ""))
104
+ methods = {
105
+ method.__name__: method
106
+ for method in (
107
+ test.to_unittest_method(**kwargs)
108
+ for group in groups
109
+ for case in group
110
+ for test in case.tests
111
+ )
112
+ }
113
+ cls = type(name, (unittest.TestCase,), methods)
114
+
115
+ # We're doing crazy things, so if they go wrong, like a function
116
+ # behaving differently on some other interpreter, just make them
117
+ # not happen.
118
+ with suppress(Exception):
119
+ cls.__module__ = _someone_save_us_the_module_of_the_caller()
120
+
121
+ return cls
122
+
123
+ def _cases_in(self, paths: Iterable[Path]) -> Iterable[_Case]:
124
+ for path in paths:
125
+ for case in json.loads(path.read_text(encoding="utf-8")):
126
+ yield _Case.from_dict(
127
+ case,
128
+ version=self,
129
+ subject=path.stem,
130
+ remotes=self._remotes,
131
+ )
132
+
133
+
134
+ @frozen
135
+ class _Case:
136
+
137
+ version: Version
138
+
139
+ subject: str
140
+ description: str
141
+ schema: Mapping[str, Any] | bool
142
+ tests: list[_Test]
143
+ comment: str | None = None
144
+ specification: Sequence[dict[str, str]] = ()
145
+
146
+ @classmethod
147
+ def from_dict(cls, data, remotes, **kwargs):
148
+ data.update(kwargs)
149
+ tests = [
150
+ _Test(
151
+ version=data["version"],
152
+ subject=data["subject"],
153
+ case_description=data["description"],
154
+ schema=data["schema"],
155
+ remotes=remotes,
156
+ **test,
157
+ ) for test in data.pop("tests")
158
+ ]
159
+ return cls(tests=tests, **data)
160
+
161
+ def benchmark(self, runner: pyperf.Runner, **kwargs): # pragma: no cover
162
+ for test in self.tests:
163
+ runner.bench_func(
164
+ test.fully_qualified_name,
165
+ partial(test.validate_ignoring_errors, **kwargs),
166
+ )
167
+
168
+
169
+ def remotes_in(
170
+ root: Path,
171
+ name: str,
172
+ uri: str,
173
+ ) -> Iterable[tuple[str, Schema]]:
174
+ # This messy logic is because the test suite is terrible at indicating
175
+ # what remotes are needed for what drafts, and mixes in schemas which
176
+ # have no $schema and which are invalid under earlier versions, in with
177
+ # other schemas which are needed for tests.
178
+
179
+ for each in root.rglob("*.json"):
180
+ schema = json.loads(each.read_text())
181
+
182
+ relative = str(each.relative_to(root)).replace("\\", "/")
183
+
184
+ if (
185
+ ( # invalid boolean schema
186
+ name in {"draft3", "draft4"}
187
+ and each.stem == "tree"
188
+ ) or
189
+ ( # draft<NotThisDialect>/*.json
190
+ "$schema" not in schema
191
+ and relative.startswith("draft")
192
+ and not relative.startswith(name)
193
+ )
194
+ ):
195
+ continue
196
+ yield f"{MAGIC_REMOTE_URL}/{relative}", schema
197
+
198
+
199
+ @frozen(repr=False)
200
+ class _Test:
201
+
202
+ version: Version
203
+
204
+ subject: str
205
+ case_description: str
206
+ description: str
207
+
208
+ data: Any
209
+ schema: Mapping[str, Any] | bool
210
+
211
+ valid: bool
212
+
213
+ _remotes: referencing.jsonschema.SchemaRegistry
214
+
215
+ comment: str | None = None
216
+
217
+ def __repr__(self): # pragma: no cover
218
+ return f"<Test {self.fully_qualified_name}>"
219
+
220
+ @property
221
+ def fully_qualified_name(self): # pragma: no cover
222
+ return " > ".join( # noqa: FLY002
223
+ [
224
+ self.version.name,
225
+ self.subject,
226
+ self.case_description,
227
+ self.description,
228
+ ],
229
+ )
230
+
231
+ def to_unittest_method(self, skip=lambda test: None, **kwargs):
232
+ if self.valid:
233
+ def fn(this):
234
+ self.validate(**kwargs)
235
+ else:
236
+ def fn(this):
237
+ with this.assertRaises(jsonschema.ValidationError):
238
+ self.validate(**kwargs)
239
+
240
+ fn.__name__ = "_".join(
241
+ [
242
+ "test",
243
+ _DELIMITERS.sub("_", self.subject),
244
+ _DELIMITERS.sub("_", self.case_description),
245
+ _DELIMITERS.sub("_", self.description),
246
+ ],
247
+ )
248
+ reason = skip(self)
249
+ if reason is None or os.environ.get("JSON_SCHEMA_DEBUG", "0") != "0":
250
+ return fn
251
+ elif os.environ.get("JSON_SCHEMA_EXPECTED_FAILURES", "0") != "0": # pragma: no cover # noqa: E501
252
+ return unittest.expectedFailure(fn)
253
+ else:
254
+ return unittest.skip(reason)(fn)
255
+
256
+ def validate(self, Validator, **kwargs):
257
+ Validator.check_schema(self.schema)
258
+ validator = Validator(
259
+ schema=self.schema,
260
+ registry=self._remotes,
261
+ **kwargs,
262
+ )
263
+ if os.environ.get("JSON_SCHEMA_DEBUG", "0") != "0": # pragma: no cover
264
+ breakpoint() # noqa: T100
265
+ validator.validate(instance=self.data)
266
+
267
+ def validate_ignoring_errors(self, Validator): # pragma: no cover
268
+ with suppress(jsonschema.ValidationError):
269
+ self.validate(Validator=Validator)
270
+
271
+
272
+ def _someone_save_us_the_module_of_the_caller():
273
+ """
274
+ The FQON of the module 2nd stack frames up from here.
275
+
276
+ This is intended to allow us to dynamically return test case classes that
277
+ are indistinguishable from being defined in the module that wants them.
278
+
279
+ Otherwise, trial will mis-print the FQON, and copy pasting it won't re-run
280
+ the class that really is running.
281
+
282
+ Save us all, this is all so so so so so terrible.
283
+ """
284
+
285
+ return sys._getframe(2).f_globals["__name__"]