-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix "ignored exception in hasattr
" in dmypy
#19428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! Raising an exception in a property is a bit questionable, so an alternative way to do this would be to make setter
a method. But let's merge this since this should fix still the underlying bug.
@JukkaL why do we even try to copy properties in Well there is a TODO item there, maybe we should try addressing it? |
@ilevkivskyi Compiled and non-compiled versions of properties are vastly different, and we need to support both modes. In particular, properties accessed on class in compiled code aren't instances of cat <<EOF >c.py
class A:
@property
def foo(self) -> int:
return 0
EOF
$ mypyc c.py
running build_ext
building 'c' extension
creating build/temp.linux-x86_64-cpython-313/build
cc -pthread -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -fPIC -fPIC -I/home/stas/Documents/Work/mypy/mypyc/lib-rt -I/tmp/tmp.Y6rtvxbGHL/.venv/include -I/home/stas/.local/share/uv/python/cpython-3.13.3-linux-x86_64-gnu/include/python3.13 -c build/__native.c -o build/temp.linux-x86_64-cpython-313/build/__native.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
creating build/lib.linux-x86_64-cpython-313
cc -pthread -shared -Wl,--exclude-libs,ALL -LModules/_hacl build/temp.linux-x86_64-cpython-313/build/__native.o -L/home/stas/.local/share/uv/python/cpython-3.13.3-linux-x86_64-gnu/lib -o build/lib.linux-x86_64-cpython-313/c.cpython-313-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-cpython-313/c.cpython-313-x86_64-linux-gnu.so ->
$ python -c 'from c import A; print(isinstance(A.foo, property))'
False
$ rm *.so
$ python -c 'from c import A; print(isinstance(A.foo, property))'
True Unless mypyc sets some extra attribute on the generated property, I don't know how to detect them without brute force. |
Hmm, what about |
@brianschubert They are intentionally included for some reason! Lines 367 to 409 in f209888
|
Fixes #19425. That property has no setter so it should safe to exclude. It can raise in inconsistent state that arises when it is not copied last?