You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you reporting a bug, or opening a feature request? bug
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
try:
# os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17".version_string=os.confstr("CS_GNU_LIBC_VERSION")
assertversion_stringisnotNone_, version=version_string.split()
except (AssertionError, AttributeError, OSError, ValueError):
# os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...returnNonereturnversion
What is the actual behavior/output? "error: Module has no attribute "confstr"
What is the behavior/output you expect? No warning as the try block captures AttributeError
What are the versions of mypy and Python you are using? mypy 0.750, Python 3.7.4
Putting this to even more extreme what if a user has
try:
main()
exceptException:
fail_gracefully()
Should mypy just show no errors in the whole program? I think no. There were some discussions about supporting checked exceptions, but even if this will be ever supported, it will be likely only for user-defined exceptions, not for builtin ones.
Realistically this will be never supported, so I would propose to close this unless someone disagrees. For now you can put # type: ignore[attr-defined] there.
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
try
block capturesAttributeError
the full traceback below.
(You can freely edit this text, please remove all the lines
you believe are unnecessary.)
The text was updated successfully, but these errors were encountered: