From a7162edd36e4a90bcc40ab28b86e65aa62397530 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 4 Jun 2024 19:41:54 -0400 Subject: [PATCH 1/3] pyright turn on reportOptionalCall --- com/win32comext/axscript/client/framework.py | 9 ++++++--- pyrightconfig.json | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/com/win32comext/axscript/client/framework.py b/com/win32comext/axscript/client/framework.py index e4c69f7ba8..67769d1f84 100644 --- a/com/win32comext/axscript/client/framework.py +++ b/com/win32comext/axscript/client/framework.py @@ -11,7 +11,8 @@ import re import sys -from typing import NoReturn +from collections.abc import Callable +from typing import Any, NoReturn import pythoncom # Need simple connection point support import win32api @@ -192,7 +193,9 @@ def __init__(self, myItem, coDispatch): self.connection = None self.coDispatch = coDispatch self.myScriptItem = myItem - self.myInvokeMethod = myItem.GetEngine().ProcessScriptItemEvent + self.myInvokeMethod: Callable[[Any, Any, Any, Any, Any], Any] = ( + myItem.GetEngine().ProcessScriptItemEvent + ) # Incomplete type self.iid = None def Reset(self): @@ -218,7 +221,7 @@ def _invoke_(self, dispid, lcid, wFlags, args): event = self.events[dispid] except: raise COMException(scode=winerror.DISP_E_MEMBERNOTFOUND) - # print("Invoke for ", event, "on", self.myScriptItem, " - calling", self.myInvokeMethod) + # print("Invoke for", event, "on", self.myScriptItem, "- calling", self.myInvokeMethod) return self.myInvokeMethod(self.myScriptItem, event, lcid, wFlags, args) def GetSourceTypeInfo(self, typeinfo): diff --git a/pyrightconfig.json b/pyrightconfig.json index 356d749bae..1028665a3e 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -35,7 +35,6 @@ // some of the fixes need to be done in types-pywin32 from typeshed "reportCallIssue": "warning", "reportOperatorIssue": "warning", - "reportOptionalCall": "warning", "reportOptionalIterable": "warning", "reportOptionalMemberAccess": "warning", "reportOptionalSubscript": "warning", From f59d460a640675873c78ff5b41bcedb1783a921c Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 13 Nov 2024 14:40:14 -0500 Subject: [PATCH 2/3] Replace exc_info with reraise in adodbapi.adodbapibase --- adodbapi/apibase.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adodbapi/apibase.py b/adodbapi/apibase.py index 749c378d38..1f37b8a1e1 100644 --- a/adodbapi/apibase.py +++ b/adodbapi/apibase.py @@ -552,9 +552,8 @@ def __getitem__(self, key): # used for row[key] type of value access return self._getValue( self.rows.columnNames[key.lower()] ) # extension row[columnName] designation - except (KeyError, TypeError): - er, st, tr = sys.exc_info() - raise er(f'No such key as "{key!r}" in {self!r}').with_traceback(tr) + except (KeyError, TypeError) as er: + raise type(er)(f'No such key as "{key!r}" in {self!r}') from er def __iter__(self): return iter(self.__next__()) From 8e892d65ff137aaed88f0c815119787248553856 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 28 Apr 2025 15:25:59 -0400 Subject: [PATCH 3/3] Fixed from typeshed's side --- pyrightconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index e3aa6accbf..bf65e809cb 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -32,7 +32,6 @@ "reportArgumentType": "none", "reportAttributeAccessIssue": "none", // FIXE: These all need to be fixed first and turned back to error - // some of the fixes need to be done in types-pywin32 from typeshed "reportCallIssue": "warning", "reportOperatorIssue": "warning", "reportOptionalIterable": "warning",