Skip to content

Change validator mode to after #58

Description

@korikuzma

Describe the bug

Validators fail when values are Pydantic models instead of dicts

Steps to reproduce

onco_evidence_lines.append(
    VariantOncogenicityEvidenceLine(
        directionOfEvidenceProvided=Direction.SUPPORTS,
        strengthOfEvidenceProvided=MappableConcept(
            primaryCoding=Coding(
                code=code(evidence_line_confidence.lower()),
                system=CCV_SYSTEM,
            )
        ),
        evidenceOutcome=MappableConcept(
            primaryCoding=Coding(
                code=code(evidence_code_value["evidence_code"]),
                system=CCV_SYSTEM,
            )
        ),
        scoreOfEvidenceProvided=evidence_line_confidence["score"],
    )
)

Expected behavior

No error

Current behavior

Error is raised

    @staticmethod
    def _validate_evidence_outcome(
        values: dict, system: System, code_pattern: str
    ) -> dict:
        """Validate ``evidenceOutcome`` property if it exists

        :param values: Input values
        :param system: System that should be used for ``primaryCoding.system``
        :param code_pattern: The regex pattern that should be used for
            ``primaryCoding.code``
        :raises ValueError: If ``evidenceOutcome`` exists and is invalid
        :return: Validated input values. If ``evidenceOutcome`` exists, then it will be
            validated and converted to a ``MappableConcept``
        """
        if "evidenceOutcome" in values:
>           mc = MappableConcept(**values["evidenceOutcome"])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           TypeError: ga4gh.core.models.MappableConcept() argument after ** must be a mapping, not MappableConcept

Possible reason(s)

No response

Suggested fix

Change validator mode to after since we're just doing validation checks and no pre-processing

Branch, commit, and/or version

version: 0.5.0-a0

Screenshots

No response

Environment details

NA

Additional details

No response

Contribution

Yes, I can create a PR for this fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions