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
{{ message }}
Repository navigation
assertIsNotNone(foo) in tests is not treated the same as assert foo is not None #5088
As part of Zulip's strict-optional effort, I had to convert a test that was using assertIsNotNone(foo) to use assert foo is not None in order to get mypy to pass. I think mypy should treat those two the same.
I have seen the forward to #4063. However, that issue is open for 5 years with no result. And currently I prefer to have this issue solved. I just do not want to double-check everything with both an assert statement and a unittest check. I also do not want to refactor all unittests of a project just because of a missing functionality of mypy. I hope that makes it understandable why it might be more reasonable to pick up this track. Thank you!
Activity
JelleZijlstra commentedon May 20, 2018
Is
assertIsNotNonehere a custom function? One way to implement this could be to typeassertisNotNoneas:Haven't tested it though.
elazarg commentedon May 20, 2018
@JelleZijlstra that's #4063. It is not implemented.
timabbott commentedon May 21, 2018
It's part of the standard unittest library: https://docs.python.org/2/library/unittest.html#unittest.TestCase.debug
emmatyping commentedon May 21, 2018
I think this can be closed in favor of #4063 then.
1kastner commentedon Aug 21, 2022
Is that something that should be added to the typeshed description of unittest then? I checked https://github.com/python/typeshed/blob/master/stdlib/unittest/case.pyi#L120 which reads this:
I have seen the forward to #4063. However, that issue is open for 5 years with no result. And currently I prefer to have this issue solved. I just do not want to double-check everything with both an assert statement and a unittest check. I also do not want to refactor all unittests of a project just because of a missing functionality of mypy. I hope that makes it understandable why it might be more reasonable to pick up this track. Thank you!
added type checks to the tests
added type checks to the tests
Ignore (false) error mypy now finds
test: Fix some lint issues after tornadoweb#3298