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
Fixing the return type of from_buffer()/from_buffer_copy() would require fixing python/mypy#1212; I think I'll use Any for now. This isn't great, but that bug is pretty subtle. Most other things are doable.
Fixing c_char*16 is also problematic, because c_char is a class! The __mul__ operation is overloaded on the metaclass. But mypy doesn't support that yet. I think that's another case of python/mypy#1267.
@matthiaskramm@tharvik How bad would it be if I just reverted #454? There's no way I can get our internal usages of ctypes to pass without fixing some tricky mypy issues (see previous comments). Putting # type: ignore in the stub won't be possible for these -- we'd have to ignore each call site of those features.
I've deleted the ctypes stub for now. After mypy 0.4.4 has been released (tomorrow?) I'll try to restore the previous version and improve it to the point where our internal code can pass with it.
Activity
euresti commentedon Aug 22, 2016
Couple of others:
from_bufferis optionalfrom_bufferandfrom_buffer_copyexpect _CData as first argumentfrom_bufferandfrom_buffer_copyreturn _CData instead of the class that is being created.(e.g.
p.xyields a type error.gvanrossum commentedon Aug 23, 2016
Fixing the return type of from_buffer()/from_buffer_copy() would require fixing python/mypy#1212; I think I'll use Any for now. This isn't great, but that bug is pretty subtle. Most other things are doable.
gvanrossum commentedon Aug 24, 2016
Fixing
c_char*16is also problematic, becausec_charis a class! The__mul__operation is overloaded on the metaclass. But mypy doesn't support that yet. I think that's another case of python/mypy#1267.gvanrossum commentedon Aug 24, 2016
@matthiaskramm @tharvik How bad would it be if I just reverted #454? There's no way I can get our internal usages of ctypes to pass without fixing some tricky mypy issues (see previous comments). Putting
# type: ignorein the stub won't be possible for these -- we'd have to ignore each call site of those features.tharvik commentedon Aug 24, 2016
It is not documented and only available on Windows (which I don't have).
I found a way by using (not pretty, but working)
@gvanrossum I guess we can revert it but keep this issue open to have a remainder to do something when mypy is fixed.
Delete ctypes. It is not yet ready for prime time, alas.
gvanrossum commentedon Aug 24, 2016
I've deleted the ctypes stub for now. After mypy 0.4.4 has been released (tomorrow?) I'll try to restore the previous version and improve it to the point where our internal code can pass with it.
JukkaL commentedon Aug 24, 2016
There's also the option of annotation
c_charwith typeAny. Again, not optimal, but some type checking is better than nothing.gvanrossum commentedon Aug 24, 2016
I think @tharvik's solution can be made to work, I just don't want to do it so close to the 0.4.4 release.
JelleZijlstra commentedon Apr 4, 2018
We have pretty good ctypes stubs now.
Rename TypeExpr to TypeForm (python#475)