Created
February 8, 2021 04:18
-
-
Save mawillcockson/a2f9297cfee24bf18d01b15954bf1c70 to your computer and use it in GitHub Desktop.
[Python] linting bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| neither pylint nor mypy catch this error, even with the most stringent checks | |
| """ | |
| def func() -> int: | |
| "raises an exception" | |
| raise RuntimeError("i can't do it :(") | |
| try: | |
| # var is never defined if func() raises an exception | |
| var = func() | |
| except RuntimeError: | |
| pass | |
| try: | |
| print(var) | |
| except NameError: | |
| print("var does not exist") | |
| # a common version of this issue | |
| try: | |
| file = open("probably does not exist") | |
| except OSError: | |
| print("couldn't open that file") | |
| finally: | |
| file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment