Use Optional instead of Union

This could be simplified by using typing.Optional

Core to the philosophy of Python is it's written to be read. Optional does a better job at communicates to the reader that the value is optional. Given that these are completely equivalent:

Why not choose the easiest to both read and write (the first one)

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
helpers.py
1
+
def foo_bar() -> Union[int, None]:

This could be simplified by using typing.Optional

Read more
Suggested changes
-
def foo_bar() -> Union[int, None]:
+
def foo_bar() -> Optional[int]:
Commit suggestion
2
+
    # sometimes return int other times None
Update helpers.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.