The if __name__ == "__main__" idiom is needed only when (a) your script needs to run directly, AND (b) your script needs to be imported as a module. Otherwise, just put top-level code.
One might as well use the if __name__ == "__main__" idiom most of the time, as it doesn’t get in the way and you may want to use the code as a module later.
The only time it may get in the way for me is when I am writing for execution in an ipython/jupyter cell-based interactive environment.
I only ever use it to return 0 (success), 1 (most failures), 2 (bad
invocation/usage) and occasionally other small nonzero ints if the
programme has a suite of defined failure modes.
Returning None (eg main() forgets an explicit return) is also like
returning 0.