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
Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.0
Expected behaviour
ctypes objects can be used to instantiate bytes and bytearray objects via copying their buffer. The following code should not produce any static analysis errors:
The code above runs just fine, but produces the following errors in the editor:
print(bytearray(c_uint8(65)))
# ~~~~~~~~~~~~~~~~~~~~~~# ^ No overloads for "bytearray(c_uint8(65))" match parameters# Argument types: (c_uint8)print(bytes(A(65, 17218)))
# ~~~~~~~~~~~~~~~~~~~~# ^ No overloads for "bytes(A(65, 17218))" match parameters# Argument types: (A)
Code Snippet / Additional information
Possibly related: python/typing issue and python bug report. I don't fully expect this to be resolvable in a general sense, until the issues mentioned are resolved, but it would sure be nice to have constructor overloads in buffer-like objects for ctypes objects.
The text was updated successfully, but these errors were encountered:
Like other type checkers, Pylance/pyright use the stubs from typeshed, which it appears that those linked threads are covering changes to (or some other related typing change). There's not much we can do when these types are defined to have a specific signature for their constructors.
For the specific lines if you know the invocations to be correct, you should be able to add # type: ignore to tell the type checker to suppress any messages, though.
My bad, this is clearly to be solved in the dependency then. I wrongfully attributed the .pyi definitions in question to be pylance related. I'll just use the ignore hint to get rid of the errors
Environment data
Expected behaviour
ctypes
objects can be used to instantiatebytes
andbytearray
objects via copying their buffer. The following code should not produce any static analysis errors:Actual behaviour
The code above runs just fine, but produces the following errors in the editor:
Code Snippet / Additional information
Possibly related: python/typing issue and python bug report. I don't fully expect this to be resolvable in a general sense, until the issues mentioned are resolved, but it would sure be nice to have constructor overloads in buffer-like objects for ctypes objects.
The text was updated successfully, but these errors were encountered: