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

How to indicate [this type] or None #56

Closed
arush opened this issue May 24, 2018 · 1 comment
Closed

How to indicate [this type] or None #56

arush opened this issue May 24, 2018 · 1 comment

Comments

@arush
Copy link

arush commented May 24, 2018

It is very common for functions to return a type or None. In typescript you can say string | null and the checker will warn you where you forgot to defend against potential null instances. How do you indicate that something may be a type or None ?

@arush arush changed the title How to indicate [this type] or [that type] How to indicate [this type] or None May 24, 2018
@arush arush changed the title How to indicate [this type] or None How to indicate [this type] or None May 24, 2018
@dark
Copy link
Contributor

dark commented May 24, 2018

In Python, that would be Optional[str], that is a shorthand for Union[str, None].
You can find a full description of these type annotations, and more, at https://docs.python.org/3/library/typing.html

@dark dark closed this as completed May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants