Coverage for src / check_datapackage / issue.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-30 13:13 +0000

1from dataclasses import dataclass, field 

2from typing import Any 

3 

4 

5class MissingValue: 

6 """Marker for a value that is absent from the checked object.""" 

7 

8 def __repr__(self) -> str: 

9 """Represent the absent value in error messages.""" 

10 return "<MISSING>" 

11 

12 def __str__(self) -> str: 

13 """Represent the absent value in user-facing text.""" 

14 return "<MISSING>" 

15 

16 

17MISSING = MissingValue() 

18 

19 

20@dataclass(order=True, frozen=True) 

21class Issue: 

22 """An issue found while checking a Data Package's properties. 

23 

24 One `Issue` object represents one failed check on one field within the properties. 

25 

26 Attributes: 

27 jsonpath (string): A [JSON path](https://jg-rp.github.io/python-jsonpath/syntax/) 

28 format pointing to the field in the input object where the issue is located. 

29 For example, `$.resources[2].name`. 

30 type (string): The type of the check that failed (e.g., a JSON schema type such 

31 as "required", "type", "pattern", or "format", or a custom type). Used to 

32 exclude specific types of issues. 

33 message (string): A description of what exactly the issue is. 

34 instance (Any): The part of the object that failed the check. This field is not 

35 considered when comparing or hashing `Issue` objects. 

36 

37 Examples: 

38 ```{python} 

39 import check_datapackage as cdp 

40 

41 issue = cdp.Issue( 

42 jsonpath="$.resources[2].title", 

43 type="required", 

44 message="The `title` field is required but missing at the given JSON path.", 

45 ) 

46 ``` 

47 """ 

48 

49 jsonpath: str 

50 type: str 

51 message: str 

52 instance: Any = field(default=None, compare=False, hash=False)