Skip to content

Commit c413458

Browse files
authored
refactor: ♻️ fix name to PropertyField (not descriptor) (#194)
1 parent 86183ac commit c413458

File tree

3 files changed

+92
-92
lines changed

3 files changed

+92
-92
lines changed

src/check_datapackage/extensions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from pydantic import BaseModel, PrivateAttr, field_validator, model_validator
66

77
from check_datapackage.internals import (
8-
DescriptorField,
98
JsonPath,
9+
PropertyField,
1010
_filter,
1111
_flat_map,
1212
_get_direct_jsonpaths,
@@ -75,11 +75,11 @@ def apply(self, properties: dict[str, Any]) -> list[Issue]:
7575
Returns:
7676
A list of `Issue`s.
7777
"""
78-
fields: list[DescriptorField] = _get_fields_at_jsonpath(
78+
fields: list[PropertyField] = _get_fields_at_jsonpath(
7979
self.jsonpath,
8080
properties,
8181
)
82-
matches: list[DescriptorField] = _filter(
82+
matches: list[PropertyField] = _filter(
8383
fields,
8484
lambda field: not self.check(field.value),
8585
)

src/check_datapackage/internals.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99
@dataclass
10-
class DescriptorField:
11-
"""A field in the Data Package descriptor.
10+
class PropertyField:
11+
"""The field of a Data Package property.
1212
1313
Attributes:
1414
jsonpath (str): The direct JSON path to the field.
@@ -21,10 +21,10 @@ class DescriptorField:
2121

2222
def _get_fields_at_jsonpath(
2323
jsonpath: str, json_object: dict[str, Any]
24-
) -> list[DescriptorField]:
24+
) -> list[PropertyField]:
2525
"""Returns all fields that match the JSON path."""
2626
matches = finditer(jsonpath, json_object)
27-
return _map(matches, _create_descriptor_field)
27+
return _map(matches, _create_property_field)
2828

2929

3030
def _get_direct_jsonpaths(jsonpath: str, json_object: dict[str, Any]) -> list[str]:
@@ -33,8 +33,8 @@ def _get_direct_jsonpaths(jsonpath: str, json_object: dict[str, Any]) -> list[st
3333
return _map(fields, lambda field: field.jsonpath)
3434

3535

36-
def _create_descriptor_field(match: JSONPathMatch) -> DescriptorField:
37-
return DescriptorField(
36+
def _create_property_field(match: JSONPathMatch) -> PropertyField:
37+
return PropertyField(
3838
jsonpath=match.path.replace("['", ".").replace("']", ""),
3939
value=match.obj,
4040
)

0 commit comments

Comments
 (0)