File tree 2 files changed +13
-13
lines changed
2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import json
4
4
5
- from pathlib import Path
5
+ from importlib . resources import files
6
6
from typing import Any
7
7
8
8
import fastjsonschema
9
9
10
10
from 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"
15
11
16
12
17
13
def 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
+ )
20
17
21
18
validate = fastjsonschema .compile (schema )
22
19
@@ -27,7 +24,9 @@ def validate_object(obj: dict[str, Any]) -> list[str]:
27
24
errors = [e .message ]
28
25
29
26
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
+ )
31
30
)
32
31
33
32
properties = schema ["properties" ].keys () | core_schema ["properties" ].keys ()
Original file line number Diff line number Diff line change 2
2
3
3
import json
4
4
5
+ from importlib .resources import files
5
6
from pathlib import Path
6
7
from typing import Any
7
8
8
- from poetry .core .json import SCHEMA_DIR as CORE_SCHEMA_DIR
9
-
10
9
from poetry .factory import Factory
11
- from poetry .json import SCHEMA_DIR
12
10
from poetry .toml import TOMLFile
13
11
14
12
13
+ SCHEMA_FILE = files ("poetry.json" ) / "schemas" / "poetry.json"
15
14
FIXTURE_DIR = Path (__file__ ).parent / "fixtures"
16
15
SOURCE_FIXTURE_DIR = FIXTURE_DIR / "source"
17
16
@@ -59,12 +58,14 @@ def test_self_invalid_plugin() -> None:
59
58
60
59
61
60
def 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 :
63
62
schema = json .load (f )
64
63
dependency_definitions = {
65
64
key : value for key , value in schema ["definitions" ].items () if "depend" in key
66
65
}
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 :
68
69
core_schema = json .load (f )
69
70
core_dependency_definitions = {
70
71
key : value
You can’t perform that action at this time.
0 commit comments