-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix for inquiry validate * add tests * Add InquiryResource file * Export InquiryResource * Fixed implementation --------- Co-authored-by: roll <[email protected]>
- Loading branch information
1 parent
bee2303
commit b7d6ccc
Showing
5 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .file import * | ||
from .inquiry import * | ||
from .json import * | ||
from .metadata import * | ||
from .package import * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Optional | ||
|
||
from .. import settings | ||
from ..exception import FrictionlessException | ||
from ..inquiry import Inquiry | ||
from ..report import Report | ||
from .metadata import MetadataResource | ||
|
||
if TYPE_CHECKING: | ||
from .. import types | ||
from ..checklist import Checklist | ||
|
||
|
||
class InquiryResource(MetadataResource[Inquiry]): | ||
datatype = "inquiry" | ||
dataclass = Inquiry | ||
|
||
# Validate | ||
|
||
def validate( | ||
self, | ||
checklist: Optional[Checklist] = None, | ||
*, | ||
name: Optional[str] = None, | ||
on_row: Optional[types.ICallbackFunction] = None, | ||
parallel: bool = False, | ||
limit_rows: Optional[int] = None, | ||
limit_errors: int = settings.DEFAULT_LIMIT_ERRORS, | ||
) -> Report: | ||
try: | ||
inquiry = self.read_metadata() | ||
except FrictionlessException as exception: | ||
return Report.from_validation(errors=exception.to_errors()) | ||
return inquiry.validate( | ||
parallel=parallel, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters