Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deserialization for str unions #1239

Merged
merged 7 commits into from
Oct 21, 2024

Commits on Oct 15, 2024

  1. Fix deserialization for str unions

    PR argoproj-labs#1168 changed the logic of map_runner_input and _parse to no longer
    pass incoming values to json.loads if their annotated type was a union
    that included str, rather than only when given a subtype of
    `Optional[str]`. Split `origin_type_issubclass` into two functions,
    `origin_type_issupertype` (which matches the previous behaviour) and
    `origin_type_issubtype`, and use the latter instead to restore the
    original behaviour.
    
    Add a runner check which verifies this behaviour.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    52437be View commit details
    Browse the repository at this point in the history
  2. Skip union tests for Pydantic v1

    parse_obj_as does not appear to support union types (it is converting
    ints to strings).
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    83eb2ee View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2024

  1. Document behaviour when given a tuple

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    f0e1ddc View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2024

  1. Fix runtime error in origin_type_is*type functions

    If origin_type_issubtype or origin_type_issupertype are passed a special
    form annotation, they will raise a TypeError due to passing it into
    issubclass. Fix this issue by first checking if the annotation is a
    type, and returning False if not.
    
    Unit test this with NoReturn, as we are very unlikely to ever create
    a special case for this type in the function.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    22d6bdc View commit details
    Browse the repository at this point in the history
  2. Support annotated unions

    The origin_type_is* functions were accidentally calling get_args on the
    original annotation rather than the unwrapped type.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    c434384 View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2024

  1. Fix str-or-int-given-int for Pydantic v1

    Pydantic v1 checks union types in declaration order, returning as soon
    as a coercion succeeds; see
    https://docs.pydantic.dev/1.10/usage/model_config/#smart-union for more.
    Change the test str_or_int_parameter signature from `str | int` to `int
    | str` to work with this legacy mode.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    f3782e8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    925150b View commit details
    Browse the repository at this point in the history