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

Support both new and old style Union/Optional #687

Merged
merged 3 commits into from
Feb 24, 2023

Commits on Feb 23, 2023

  1. Support both union types

    The Python 3.10+ syntax of creating a union or optional type
    (with `str | int`), results in a differnt type than using the pre-Python
    3.10 syntax (`Union[str, int]`).
    
    ```pycon
    >>> from typing import Optional, Union, get_origin
    >>> get_origin(Union[int, str])
    typing.Union
    >>> get_origin(int | str)
    <class 'types.UnionType'>
    >>> get_origin(Optional[int])
    typing.Union
    >>> get_origin(int | None)
    <class 'types.UnionType'>
    ```
    gvangool committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    db711a3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    67eb802 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f015a7f View commit details
    Browse the repository at this point in the history