-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Description of the false positive
This is idiomatic Python and shouldn't raise a warning, even when the result of main
is always None
.
if __name__ == "__main__":
sys.exit(main())
See:
https://docs.python.org/fr//3/library/__main__.html#packaging-considerations
Since the call to
main
is wrapped insys.exit()
, the expectation is that your function will return some value acceptable as an input tosys.exit()
; typically, an integer orNone
(which is implicitly returned if your function does not have a return statement).By proactively following this convention ourselves, our module will have the same behavior when run directly (i.e.
python3 echo.py
) as it will have if we later package it as a console script entry-point in a pip-installable package.
URL to the alert on the project page on LGTM.com