Skip to content

Commit 65714a1

Browse files
committed
Fix type errors in pywin32 using types-pywin32
1 parent 0ac66cd commit 65714a1

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

stubs/pywin32/_win32typing.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,9 @@ class PyHANDLE:
921921
def Close(self) -> None: ...
922922
def close(self) -> None: ...
923923
def Detach(self) -> Self: ...
924+
def __bool__(self) -> bool: ...
925+
def __int__(self) -> int: ...
926+
# PyHANDLE sets a lot more dunder methods, only to make them all raise with `TypeError: bad operand type`
924927

925928
@final
926929
class PyHDESK:
@@ -5138,7 +5141,7 @@ class PyCDocTemplate:
51385141
) -> None: ...
51395142
def SetContainerInfo(self, _id, /) -> None: ...
51405143
def SetDocStrings(self, docStrings: str, /) -> None: ...
5141-
def OpenDocumentFile(self, filename: str, bMakeVisible: int = ..., /) -> None: ...
5144+
def OpenDocumentFile(self, filename: str, bMakeVisible: int = ..., /) -> PyCDocument | None: ...
51425145

51435146
class PyCDockContext:
51445147
@property
@@ -5868,7 +5871,7 @@ class PyCWinApp:
58685871
def LoadOEMCursor(self, cursorId, /): ...
58695872
def LoadIcon(self, idResource: int, /) -> int: ...
58705873
def LoadStandardIcon(self, resourceName: PyResourceId, /): ...
5871-
def OpenDocumentFile(self, fileName: str, /) -> None: ...
5874+
def OpenDocumentFile(self, fileName: str, /) -> PyCDocument | None: ...
58725875
def OnFileNew(self) -> None: ...
58735876
def OnFileOpen(self) -> None: ...
58745877
def RemoveDocTemplate(self, template: PyCDocTemplate | DocTemplate, /) -> None: ...

stubs/pywin32/pythonwin/win32ui.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def FullPath(path: str, /) -> str: ...
9797
def GetActiveWindow() -> _win32typing.PyCWnd: ...
9898
def GetApp() -> _win32typing.PyCWinApp: ...
9999
def GetAppName(): ...
100-
def GetAppRegistryKey() -> None: ...
100+
def GetAppRegistryKey() -> _win32typing.PyHKEY: ...
101101
def GetBytes(address, size, /) -> str: ...
102102
def GetCommandLine() -> str: ...
103103
def GetDeviceCaps(hdc, index, /): ...

stubs/pywin32/win32/win32api.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def CloseHandle(handle: int, /) -> None: ...
7777
def CopyFile(src, dest: str, bFailOnExist: int = ..., /) -> None: ...
7878
def DebugBreak() -> None: ...
7979
def DeleteFile(fileName: str, /) -> None: ...
80+
@overload
81+
def DragQueryFile(hDrop, fileNum: Literal[-1] = -1, /) -> int: ...
82+
@overload
8083
def DragQueryFile(hDrop, fileNum: int = ..., /) -> str: ...
8184
def DragFinish(hDrop, /) -> None: ...
8285
def DuplicateHandle(

stubs/pywin32/win32/win32event.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def CreateEvent(
1111
Name: str | None,
1212
/,
1313
) -> int: ...
14-
def CreateMutex(MutexAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialOwner, Name: str, /) -> int: ...
14+
def CreateMutex(MutexAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialOwner, Name: str, /) -> _win32typing.PyHANDLE: ...
1515
def CreateSemaphore(
1616
SemaphoreAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialCount, MaximumCount, SemaphoreName, /
1717
) -> int: ...

stubs/pywin32/win32/win32pdh.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def OpenQuery(DataSource: Incomplete | None = ..., userData: int = ..., /): ...
1111
def CloseQuery(handle, /) -> None: ...
1212
def MakeCounterPath(
1313
elements: tuple[Incomplete, Incomplete, Incomplete, Incomplete, Incomplete, Incomplete], flags=..., /
14-
) -> None: ...
14+
) -> str: ...
1515
def GetCounterInfo(handle, bRetrieveExplainText, /) -> None: ...
1616
def GetFormattedCounterValue(handle, _format, /) -> tuple[Incomplete, Incomplete]: ...
1717
def CollectQueryData(hQuery, /) -> None: ...

stubs/pywin32/win32comext/shell/shell.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from typing import Literal, overload
23
from typing_extensions import TypeAlias
34

45
import _win32typing
@@ -8,8 +9,14 @@ error: TypeAlias = com_error # noqa: Y042
89

910
def AssocCreate() -> _win32typing.PyIQueryAssociations: ...
1011
def AssocCreateForClasses() -> _win32typing.PyIUnknown: ...
11-
def DragQueryFile(hglobal: int, index, /) -> str: ...
12-
def DragQueryFileW(hglobal: int, index, /) -> str: ...
12+
@overload
13+
def DragQueryFile(hglobal: int | _win32typing.PyHANDLE | None, index: Literal[-1] = -1, /) -> int: ...
14+
@overload
15+
def DragQueryFile(hglobal: int | _win32typing.PyHANDLE | None, index: int, /) -> str: ...
16+
@overload
17+
def DragQueryFileW(hglobal: int | _win32typing.PyHANDLE | None, index: Literal[-1] = -1, /) -> int: ...
18+
@overload
19+
def DragQueryFileW(hglobal: int | _win32typing.PyHANDLE | None, index: int, /) -> str: ...
1320
def DragQueryPoint(hglobal: int, /) -> tuple[Incomplete, Incomplete, Incomplete]: ...
1421
def IsUserAnAdmin() -> bool: ...
1522
def SHCreateDataObject(

0 commit comments

Comments
 (0)