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
migrate some stuffs in ctypes/__init__.pyi into _ctypes.pyi, but circular import occurs #8633
You don't really need to worry about circular imports, since stub files are never imported by Python. All type checkers know how to resolve circular imports when resolving references. That said, in this case you could probably move the fake definitions _CArgObject, _PointerLike to _ctypes and import them in ctypes.
If you update to pytype 2022.08.30, you should be able to import RTLD_GLOBAL and RTLD_LOCAL from _ctypes now. (Just to clarify, what will happen "in a few weeks" is that I'll delete pytype's _ctypes stub so that it no longer has to be kept in sync with typeshed's.)
I just updated typeshed's pinned version of pytype to 2023.4.27 in #10111. pytype v2023.4.27 includes google/pytype@2e2088f, which removes pytype's copy of stdlib/_ctypes.pyi. This means we can now move the rest of the definitions that should be in _ctypes.pyi (but are currently in ctypes/__init__.pyi) over to _ctypes.pyi.
Activity
hauntsaninja commentedon Aug 29, 2022
You don't really need to worry about circular imports, since stub files are never imported by Python. All type checkers know how to resolve circular imports when resolving references. That said, in this case you could probably move the fake definitions
_CArgObject, _PointerLiketo_ctypesand import them inctypes.junkmd commentedon Aug 29, 2022
When we tried to make the change, we found that the test using
pytyperunning in CI failed.Please see #8643.
I will work on adding TODO comments to the stuffs originally defined in
_ctypesuntilpytypeis fixed or better workarounds are found.junkmd commentedon Aug 30, 2022
I submitted issue to
pytypegoogle/pytype#1281junkmd commentedon Aug 30, 2022
The
pytypeproblem causes by its own_ctypesstub.This will be fixed "in a few weeks".
junkmd commentedon Aug 30, 2022
List of the stuffs in
ctypes/__init__.pyithose what originally defined in_ctypesmarked stuffs have been migrated.
ArgumentErrorArrayFormatErrorPOINTERRTLD_GLOBALRTLD_LOCALStructureUnion_Pointer_SimpleCData_CData(hidden base class)addressofalignmentbyrefget_errnoget_last_errorpointerresizeset_errnoset_last_errorsizeofrchen152 commentedon Aug 30, 2022
If you update to pytype 2022.08.30, you should be able to import
RTLD_GLOBALandRTLD_LOCALfrom_ctypesnow. (Just to clarify, what will happen "in a few weeks" is that I'll delete pytype's_ctypesstub so that it no longer has to be kept in sync with typeshed's.)junkmd commentedon Aug 31, 2022
Currently,
RTLD_GLOBALandRTLD_LOCALare imported from_ctypes.pyi(#8656).AlexWaygood commentedon Aug 31, 2022
Yes, the pytype update did the trick — thanks v much @rchen152!
AlexWaygood commentedon Apr 29, 2023
I just updated typeshed's pinned version of pytype to 2023.4.27 in #10111. pytype v2023.4.27 includes google/pytype@2e2088f, which removes pytype's copy of
stdlib/_ctypes.pyi. This means we can now move the rest of the definitions that should be in_ctypes.pyi(but are currently inctypes/__init__.pyi) over to_ctypes.pyi.junkmd commentedon May 3, 2023
#10118, #10125, #10128, #10130, #10133 and #10137 have been merged and the definition movings are completed.
The
CFuncPtrand the_FuncPointerwill be addressed within the scope of #8968 and #10132.