Uh oh!
There was an error while loading. Please reload this page.
Conversation
Diff from mypy_primer, showing the effect of this PR on open source code: psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: error: Unused "type: ignore" comment+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: note: Error code "valid-type" not covered by "type: ignore" comment+ psycopg/psycopg/pq/_pq_ctypes.pyi:13: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:65: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:65: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:72: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:72: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: error: Unused "type: ignore" comment+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: note: Error code "valid-type" not covered by "type: ignore" comment+ psycopg/psycopg/pq/_pq_ctypes.pyi:113: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:136: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:136: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:161: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:161: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:185: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:185: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:186: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:186: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:187: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:187: note: Perhaps you need "Callable[...]" or a callback protocol?+ psycopg/psycopg/pq/_pq_ctypes.pyi:189: error: Function "ctypes.pointer" is not valid as a type [valid-type]+ psycopg/psycopg/pq/_pq_ctypes.pyi:189: note: Perhaps you need "Callable[...]" or a callback protocol? |
AlexWaygood
commented
Jul 30, 2022
As expected, the "moral" thing to do here is quite disruptive. @srittau, what do you think? Worth it anyway? |
Having said that, it looks like the So the fix for that library would be pretty trivial, I think. |
srittau
left a comment
There was a problem hiding this comment.
Let's do this. It might hurt now, but will probably prevent more hurt in the future.
AlexWaygood
commented
Jul 31, 2022
@dvarrazzo, just to give you a heads-up about this — the typeshed stubs for |
dvarrazzo
commented
Jul 31, 2022
@AlexWaygood no problem at all! When this change will be released I'll be happy to update our stubs and set a dependency on the newer mypy version 🙂 |
As @AlexWaygood mentioned, this breaks things where a user may want to define pointer annotations: importctypesasctclassFoo(ct.Structure):
... # other stuff defined here test: "ct.pointer[ct.c_int32]"# these now errortest2: "ct.pointer[ct.c_bool]"# these now errorCould |
JelleZijlstra
commented
Aug 13, 2022
Maybe, but that's not a decision we can make in typeshed. If you want it to be, you should open an issue over at CPython. |
nathanrpage97
commented
Aug 14, 2022
Ok, I don’t think it is worthy of a change to cpython implementation. The big thing is linters not liking a reference to a private api. I think for now I will re-export ctypes._Pointer -> PointerType to reduce linter silencing needed. |
Akuli
commented
Aug 14, 2022
Cpython might accept making it a public type, a bit similarly to how |
AlexWaygood
commented
Aug 14, 2022
Especially given that |
Most changes needed by python/typeshed#8446.
Fixes#8351. Fixes#7747. Closes#7753.