File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 22
33import json
44
5- from pathlib import Path
5+ from importlib . resources import files
66from typing import Any
77
88import fastjsonschema
99
1010from fastjsonschema .exceptions import JsonSchemaValueException
11- from poetry .core .json import SCHEMA_DIR as CORE_SCHEMA_DIR
12-
13-
14- SCHEMA_DIR = Path (__file__ ).parent / "schemas"
1511
1612
1713def validate_object (obj : dict [str , Any ]) -> list [str ]:
18- schema_file = Path (SCHEMA_DIR , "poetry.json" )
19- schema = json .loads (schema_file .read_text (encoding = "utf-8" ))
14+ schema = json .loads (
15+ (files (__package__ ) / "schemas" / "poetry.json" ).read_text (encoding = "utf-8" )
16+ )
2017
2118 validate = fastjsonschema .compile (schema )
2219
@@ -27,7 +24,9 @@ def validate_object(obj: dict[str, Any]) -> list[str]:
2724 errors = [e .message ]
2825
2926 core_schema = json .loads (
30- (CORE_SCHEMA_DIR / "poetry-schema.json" ).read_text (encoding = "utf-8" )
27+ (files ("poetry.core" ) / "json" / "schemas" / "poetry-schema.json" ).read_text (
28+ encoding = "utf-8"
29+ )
3130 )
3231
3332 properties = schema ["properties" ].keys () | core_schema ["properties" ].keys ()
Original file line number Diff line number Diff line change 22
33import json
44
5+ from importlib .resources import files
56from pathlib import Path
67from typing import Any
78
8- from poetry .core .json import SCHEMA_DIR as CORE_SCHEMA_DIR
9-
109from poetry .factory import Factory
11- from poetry .json import SCHEMA_DIR
1210from poetry .toml import TOMLFile
1311
1412
13+ SCHEMA_FILE = files ("poetry.json" ) / "schemas" / "poetry.json"
1514FIXTURE_DIR = Path (__file__ ).parent / "fixtures"
1615SOURCE_FIXTURE_DIR = FIXTURE_DIR / "source"
1716
@@ -59,12 +58,14 @@ def test_self_invalid_plugin() -> None:
5958
6059
6160def test_dependencies_is_consistent_to_poetry_core_schema () -> None :
62- with ( SCHEMA_DIR / "poetry.json" ) .open (encoding = "utf-8" ) as f :
61+ with SCHEMA_FILE .open (encoding = "utf-8" ) as f :
6362 schema = json .load (f )
6463 dependency_definitions = {
6564 key : value for key , value in schema ["definitions" ].items () if "depend" in key
6665 }
67- with (CORE_SCHEMA_DIR / "poetry-schema.json" ).open (encoding = "utf-8" ) as f :
66+ with (files ("poetry.core" ) / "json" / "schemas" / "poetry-schema.json" ).open (
67+ encoding = "utf-8"
68+ ) as f :
6869 core_schema = json .load (f )
6970 core_dependency_definitions = {
7071 key : value
You can’t perform that action at this time.
0 commit comments