diff --git a/Pythonwin/Scintilla/win32/DepGen.py b/Pythonwin/Scintilla/win32/DepGen.py index 4ab6f6f31b..ea3b573e0b 100644 --- a/Pythonwin/Scintilla/win32/DepGen.py +++ b/Pythonwin/Scintilla/win32/DepGen.py @@ -19,7 +19,7 @@ def Generate(): # Create the dependencies file for g++ deps = Dependencies.FindDependencies( - ["../win32/*.cxx"] + sources, ["../win32"] + includes, ".o", "../win32/" + ["../win32/*.cxx", *sources], ["../win32", *includes], ".o", "../win32/" ) # Add ScintillaBaseL as the same as ScintillaBase diff --git a/Pythonwin/pywin/Demos/ocx/ocxserialtest.py b/Pythonwin/pywin/Demos/ocx/ocxserialtest.py index 52416ab655..a92d9d1a6d 100644 --- a/Pythonwin/pywin/Demos/ocx/ocxserialtest.py +++ b/Pythonwin/pywin/Demos/ocx/ocxserialtest.py @@ -67,7 +67,7 @@ def OnComm(self): class TestSerDialog(dialog.Dialog): def __init__(self, *args): - dialog.Dialog.__init__(*(self,) + args) + dialog.Dialog.__init__(self, *args) self.olectl = None def OnComm(self): diff --git a/Pythonwin/pywin/docking/DockingBar.py b/Pythonwin/pywin/docking/DockingBar.py index cc8d3853d6..6e3c0d4f53 100644 --- a/Pythonwin/pywin/docking/DockingBar.py +++ b/Pythonwin/pywin/docking/DockingBar.py @@ -96,7 +96,7 @@ def CreateWindow( self._obj_.CreateWindow(wndClass, title, style, (0, 0, 0, 0), parent, id) # Create the child dialog - self.dialog = childCreator(*(self,) + childCreatorArgs) + self.dialog = childCreator(self, *childCreatorArgs) # use the dialog dimensions as default base dimensions assert self.dialog.IsWindow(), ( diff --git a/Pythonwin/pywin/framework/editor/color/coloreditor.py b/Pythonwin/pywin/framework/editor/color/coloreditor.py index d2a78e69db..fb4f3538df 100644 --- a/Pythonwin/pywin/framework/editor/color/coloreditor.py +++ b/Pythonwin/pywin/framework/editor/color/coloreditor.py @@ -631,8 +631,9 @@ def GetPythonPropertyPages(self): """Returns a list of property pages""" from pywin.scintilla import configui - return EditorTemplateBase.GetPythonPropertyPages(self) + [ - configui.ScintillaFormatPropertyPage() + return [ + *EditorTemplateBase.GetPythonPropertyPages(self), + configui.ScintillaFormatPropertyPage(), ] diff --git a/Pythonwin/pywin/framework/interact.py b/Pythonwin/pywin/framework/interact.py index c26bf6e829..32ecdcf4c0 100644 --- a/Pythonwin/pywin/framework/interact.py +++ b/Pythonwin/pywin/framework/interact.py @@ -486,7 +486,7 @@ def ExtractCommand(self, lines): while end >= start: thisLine = self.DoGetLine(end) promptLen = len(GetPromptPrefix(thisLine)) - retList = [thisLine[promptLen:]] + retList + retList = [thisLine[promptLen:], *retList] end -= 1 return retList diff --git a/Pythonwin/pywin/scintilla/config.py b/Pythonwin/pywin/scintilla/config.py index 45c2a095c0..410f891577 100644 --- a/Pythonwin/pywin/scintilla/config.py +++ b/Pythonwin/pywin/scintilla/config.py @@ -175,7 +175,7 @@ def configure(self, editor, subsections=None): # First, we "recursively" connect any we are based on. if subsections is None: subsections = [] - subsections = [""] + subsections + subsections = ["", *subsections] general = self.get_data("general") if general: parents = general.get("based on", []) @@ -224,7 +224,7 @@ def configure(self, editor, subsections=None): def get_key_binding(self, event, subsections=None): if subsections is None: subsections = [] - subsections = [""] + subsections + subsections = ["", *subsections] subsection_keymap = self.get_data("keys") for subsection in subsections: diff --git a/Pythonwin/pywin/tools/TraceCollector.py b/Pythonwin/pywin/tools/TraceCollector.py index 97ac75f551..d45f0fb562 100644 --- a/Pythonwin/pywin/tools/TraceCollector.py +++ b/Pythonwin/pywin/tools/TraceCollector.py @@ -38,7 +38,7 @@ def CollectorThread(stopEvent, file): class WindowOutput(winout.WindowOutput): def __init__(self, *args): - winout.WindowOutput.__init__(*(self,) + args) + winout.WindowOutput.__init__(self, *args) self.hStopThread = win32event.CreateEvent(None, 0, 0, None) _thread.start_new(CollectorThread, (self.hStopThread, self)) diff --git a/com/win32com/client/__init__.py b/com/win32com/client/__init__.py index b4aae20a8c..9f06e4810c 100644 --- a/com/win32com/client/__init__.py +++ b/com/win32com/client/__init__.py @@ -597,7 +597,7 @@ def __setattr__(self, attr, value): args, defArgs = self._prop_map_put_[attr] except KeyError: raise AttributeError(f"'{self!r}' object has no attribute '{attr}'") - self._oleobj_.Invoke(*(args + (value,) + defArgs)) + self._oleobj_.Invoke(*args, value, *defArgs) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): return _get_good_single_object_(obj, obUserName, resultCLSID) diff --git a/com/win32com/client/dynamic.py b/com/win32com/client/dynamic.py index 3738da9031..1129a6c885 100644 --- a/com/win32com/client/dynamic.py +++ b/com/win32com/client/dynamic.py @@ -209,7 +209,7 @@ def __call__(self, *args): pythoncom.DISPID_VALUE, ) if invkind is not None: - allArgs = (dispid, LCID, invkind, 1) + args + allArgs = (dispid, LCID, invkind, 1, *args) return self._get_good_object_( self._oleobj_.Invoke(*allArgs), self._olerepr_.defaultDispatchName, None ) @@ -331,7 +331,7 @@ def __setitem__(self, index, *args): pythoncom.DISPID_VALUE, ) if invkind is not None: - allArgs = (dispid, LCID, invkind, 0, index) + args + allArgs = (dispid, LCID, invkind, 0, index, *args) return self._get_good_object_( self._oleobj_.Invoke(*allArgs), self._olerepr_.defaultDispatchName, None ) @@ -354,7 +354,7 @@ def _find_dispatch_type_(self, methodName): def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): result = self._oleobj_.InvokeTypes( - *(dispid, LCID, wFlags, retType, argTypes) + args + dispid, LCID, wFlags, retType, argTypes, *args ) return self._get_good_object_(result, user, resultCLSID) @@ -447,7 +447,7 @@ def _proc_(self, name, *args): item = self._olerepr_.mapFuncs[name] dispId = item.dispid return self._get_good_object_( - self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args)) + self._oleobj_.Invoke(dispId, LCID, item.desc[4], 0, *args) ) except KeyError: raise AttributeError(name) @@ -505,7 +505,7 @@ def _LazyAddAttr_(self, attr): r = olerepr._AddVar_(typeinfo, t, 0) else: # not found or TYPEDESC/IMPLICITAPP r = None - if not r is None: + if r is not None: key, map = r[0], r[1] item = map[key] if map == olerepr.propMapPut: diff --git a/com/win32com/demos/connect.py b/com/win32com/demos/connect.py index 6ae96768de..76e24c3797 100644 --- a/com/win32com/demos/connect.py +++ b/com/win32com/demos/connect.py @@ -20,8 +20,9 @@ class ConnectableServer(win32com.server.connect.ConnectableServer): _public_methods_ = [ - "DoIt" - ] + win32com.server.connect.ConnectableServer._public_methods_ + "DoIt", + *win32com.server.connect.ConnectableServer._public_methods_, + ] _connect_interfaces_ = [IID_IConnectDemoEvents] # The single public method that the client can call on us diff --git a/com/win32com/demos/ietoolbar.py b/com/win32com/demos/ietoolbar.py index af3ff836a9..ba2b2c21c8 100644 --- a/com/win32com/demos/ietoolbar.py +++ b/com/win32com/demos/ietoolbar.py @@ -96,7 +96,7 @@ def toparam(self): val = default vals.append(val) full_fmt += fmt - return struct.pack(*(full_fmt,) + tuple(vals)) + return struct.pack(full_fmt, *vals) class TBBUTTON(WIN32STRUCT): diff --git a/com/win32com/server/connect.py b/com/win32com/server/connect.py index 5d3cddf981..206b3aa9e5 100644 --- a/com/win32com/server/connect.py +++ b/com/win32com/server/connect.py @@ -77,7 +77,7 @@ def _BroadcastNotify(self, broadcaster, extraArgs): # Ignores clients that fail. for interface in self.connections.values(): try: - broadcaster(*(interface,) + extraArgs) + broadcaster(interface, *extraArgs) except pythoncom.com_error as details: self._OnNotifyFail(interface, details) diff --git a/com/win32com/server/register.py b/com/win32com/server/register.py index 817f3a28a2..d933187167 100644 --- a/com/win32com/server/register.py +++ b/com/win32com/server/register.py @@ -304,7 +304,7 @@ def RegisterServer( if addPyComCat is None: addPyComCat = pythoncom.frozen == 0 if addPyComCat: - catids = catids + [CATID_PythonCOMServer] + catids = [*catids, CATID_PythonCOMServer] # Set up the implemented categories if catids: diff --git a/com/win32com/test/testIterators.py b/com/win32com/test/testIterators.py index 2b2248edfd..339f9e2bc7 100644 --- a/com/win32com/test/testIterators.py +++ b/com/win32com/test/testIterators.py @@ -137,4 +137,4 @@ def suite(): if __name__ == "__main__": - unittest.main(argv=sys.argv + ["suite"]) + unittest.main(argv=[*sys.argv, "suite"]) diff --git a/com/win32comext/axdebug/debugger.py b/com/win32comext/axdebug/debugger.py index d0585b9b6f..1e8f1a3aa6 100644 --- a/com/win32comext/axdebug/debugger.py +++ b/com/win32comext/axdebug/debugger.py @@ -44,7 +44,7 @@ def BuildModule(module, built_nodes, rootNode, create_node_fn, create_node_args) # print("keeping", module.__name__) node = ModuleTreeNode(module) built_nodes[module] = node - realNode = create_node_fn(*(node,) + create_node_args) + realNode = create_node_fn(node, *create_node_args) node.realNode = realNode # Split into parent nodes. diff --git a/com/win32comext/axdebug/expressions.py b/com/win32comext/axdebug/expressions.py index 401b9a5996..8beff49a1a 100644 --- a/com/win32comext/axdebug/expressions.py +++ b/com/win32comext/axdebug/expressions.py @@ -149,7 +149,7 @@ class EnumDebugPropertyInfo(ListEnumeratorGateway): """ - _public_methods_ = ListEnumeratorGateway._public_methods_ + ["GetCount"] + _public_methods_ = [*ListEnumeratorGateway._public_methods_, "GetCount"] _com_interfaces_ = [axdebug.IID_IEnumDebugPropertyInfo] def GetCount(self): diff --git a/com/win32comext/axdebug/gateways.py b/com/win32comext/axdebug/gateways.py index beefab2e63..e40412ce6b 100644 --- a/com/win32comext/axdebug/gateways.py +++ b/com/win32comext/axdebug/gateways.py @@ -74,9 +74,10 @@ def GetDocumentClassId(self): class DebugDocumentProvider(DebugDocumentInfo): - _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"] - _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [ - axdebug.IID_IDebugDocumentProvider + _public_methods_ = [*DebugDocumentInfo._public_methods_, "GetDocument"] + _com_interfaces_ = [ + *DebugDocumentInfo._com_interfaces_, + axdebug.IID_IDebugDocumentProvider, ] def GetDocument(self): @@ -92,8 +93,9 @@ class DebugApplicationNode(DebugDocumentProvider): + DebugDocumentProvider._public_methods_ ) _com_interfaces_ = [ - axdebug.IID_IDebugDocumentProvider - ] + DebugDocumentProvider._com_interfaces_ + axdebug.IID_IDebugDocumentProvider, + *DebugDocumentProvider._com_interfaces_, + ] def __init__(self): DebugDocumentProvider.__init__(self) @@ -153,13 +155,13 @@ class DebugDocument(DebugDocumentInfo): """The base interface to all debug documents.""" _public_methods_ = DebugDocumentInfo._public_methods_ - _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_ + _com_interfaces_ = [axdebug.IID_IDebugDocument, *DebugDocumentInfo._com_interfaces_] class DebugDocumentText(DebugDocument): """The interface to a text only debug document.""" - _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + DebugDocument._com_interfaces_ + _com_interfaces_ = [axdebug.IID_IDebugDocumentText, *DebugDocument._com_interfaces_] _public_methods_ = [ "GetDocumentAttributes", "GetSize", @@ -168,7 +170,8 @@ class DebugDocumentText(DebugDocument): "GetText", "GetPositionOfContext", "GetContextOfPosition", - ] + DebugDocument._public_methods_ + *DebugDocument._public_methods_, + ] def __init__(self): pass diff --git a/com/win32comext/axscript/client/framework.py b/com/win32comext/axscript/client/framework.py index e7432947eb..daaa5495e6 100644 --- a/com/win32comext/axscript/client/framework.py +++ b/com/win32comext/axscript/client/framework.py @@ -53,7 +53,7 @@ def profile(fn, *args): try: # roll on 1.6 :-) # return prof.runcall(fn, *args) - return prof.runcall(*(fn,) + args) + return prof.runcall(fn, *args) finally: import pstats diff --git a/com/win32comext/shell/demos/servers/column_provider.py b/com/win32comext/shell/demos/servers/column_provider.py index eda603fcd2..96e1dcaeb2 100644 --- a/com/win32comext/shell/demos/servers/column_provider.py +++ b/com/win32comext/shell/demos/servers/column_provider.py @@ -18,7 +18,8 @@ from win32com.shell import shell, shellcon IPersist_Methods = ["GetClassID"] -IColumnProvider_Methods = IPersist_Methods + [ +IColumnProvider_Methods = [ + *IPersist_Methods, "Initialize", "GetColumnInfo", "GetItemData", diff --git a/com/win32comext/shell/shellcon.py b/com/win32comext/shell/shellcon.py index 44d4d0ada5..d630e80ce7 100644 --- a/com/win32comext/shell/shellcon.py +++ b/com/win32comext/shell/shellcon.py @@ -1210,10 +1210,11 @@ def EIRESID(x): "ContextSensitiveHelp", ] # XXX - this should be somewhere in win32com IPersist_Methods = ["GetClassID"] -IPersistFolder_Methods = IPersist_Methods + ["Initialize"] -IPersistFolder2_Methods = IPersistFolder_Methods + ["GetCurFolder"] +IPersistFolder_Methods = [*IPersist_Methods, "Initialize"] +IPersistFolder2_Methods = [*IPersistFolder_Methods, "GetCurFolder"] IShellExtInit_Methods = ["Initialize"] -IShellView_Methods = IOleWindow_Methods + [ +IShellView_Methods = [ + *IOleWindow_Methods, "TranslateAccelerator", "EnableModeless", "UIActivate", @@ -1239,7 +1240,8 @@ def EIRESID(x): "GetDisplayNameOf", "SetNameOf", ] -IShellFolder2_Methods = IShellFolder_Methods + [ +IShellFolder2_Methods = [ + *IShellFolder_Methods, "GetDefaultSearchGUID", "EnumSearches", "GetDefaultColumn", diff --git a/isapi/install.py b/isapi/install.py index c4c61fb76c..711b8ba619 100644 --- a/isapi/install.py +++ b/isapi/install.py @@ -531,7 +531,7 @@ def CheckLoaderModule(dll_name): def _CallHook(ob, hook_name, options, *extra_args): func = getattr(ob, hook_name, None) if func is not None: - args = (ob, options) + extra_args + args = (ob, options, *extra_args) func(*args) diff --git a/pyproject.toml b/pyproject.toml index 93e6776dcd..61b79b9c1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,9 +11,9 @@ checkers = [ # Keep these in sync with .pre-commit-config.yaml "ruff ==0.11.0", ] type-checkers = [ - "types-setuptools", + "types-setuptools >=80.9.0.20251221", "PyOpenGL", - "mypy ==1.16.*; python_version >='3.9'", + "mypy ==1.16.*", "pyright ==1.1.401", ] dev = [ diff --git a/ruff.toml b/ruff.toml index e96c2eafef..218359649e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -11,8 +11,10 @@ select = [ "C4", # flake8-comprehensions "F811", # redefined-while-unused "I", # isort + "PIE800", # unnecessary-spread "PLC", # Pylint Convention "PLE", # Pylint Error + "RUF005", # collection-literal-concatenation "RSE", # flake8-raise "W", # pycodestyle Warning "YTT", # flake8-2020 @@ -51,8 +53,7 @@ extend-ignore = [ # TODO: Make adodbapi changes in their own PRs "adodbapi/*" = [ "C4", - "UP031", - "UP032", + "RUF005", # Dropping Python 3.8 support "UP005", "UP006", diff --git a/setup.py b/setup.py index 4ca3671255..3b076b0038 100644 --- a/setup.py +++ b/setup.py @@ -121,7 +121,7 @@ def __init__( implib_name=None, delay_load_libraries="", ): - include_dirs = ["com/win32com/src/include", "win32/src"] + include_dirs + include_dirs = ["com/win32com/src/include", "win32/src", *include_dirs] libraries = libraries.split() self.delay_load_libraries = delay_load_libraries.split() libraries.extend(self.delay_load_libraries) @@ -468,7 +468,7 @@ def _build_scintilla(self): os.environ["LIB"] = os.pathsep.join(self.compiler.library_dirs) os.chdir(path) try: - cmd = [nmake, "/nologo", "/f", makefile] + makeargs + cmd = [nmake, "/nologo", "/f", makefile, *makeargs] self.compiler.spawn(cmd) finally: os.chdir(cwd) @@ -862,7 +862,7 @@ def swig_sources(self, sources, ext): fqsource = os.path.abspath(source) fqtarget = os.path.abspath(target) rebuild = self.force or ( - ext and newer_group(ext.swig_deps + [fqsource], fqtarget) + ext and newer_group([*ext.swig_deps, fqsource], fqtarget) ) # can remove once edklib is no longer used for 32-bit builds @@ -1852,7 +1852,7 @@ def expand_modules(module_dir: str | os.PathLike[str]): # will 'do the right thing' in terms of installing License.txt into # 'Lib/site-packages/pythonwin/License.txt'. We exploit this to # get 'com/win32com/whatever' installed to 'win32com/whatever' -def convert_data_files(files: Iterable[str]): +def convert_data_files(files: Iterable[str]) -> list[tuple[str, tuple[str]]]: ret: list[tuple[str, tuple[str]]] = [] for file in files: file = os.path.normpath(file) @@ -1875,8 +1875,8 @@ def convert_data_files(files: Iterable[str]): return ret -def convert_optional_data_files(files): - ret = [] +def convert_optional_data_files(files) -> list[tuple[str, tuple[str]]]: + ret: list[tuple[str, tuple[str]]] = [] for file in files: try: temp = convert_data_files([file]) @@ -2006,71 +2006,71 @@ def convert_optional_data_files(files): }, packages=packages, py_modules=py_modules, - data_files=convert_optional_data_files(["PyWin32.chm"]) - + convert_data_files( - [ - "Pythonwin/start_pythonwin.pyw", - "pythonwin/pywin/*.cfg", - "pythonwin/pywin/Demos/*.py", - "pythonwin/pywin/Demos/app/*.py", - "pythonwin/pywin/Demos/ocx/*.py", - "win32/scripts/*.py", - "win32/test/*.py", - "win32/test/win32rcparser/test.rc", - "win32/test/win32rcparser/test.h", - "win32/test/win32rcparser/python.ico", - "win32/test/win32rcparser/python.bmp", - "win32/Demos/*.py", - "win32/Demos/images/*.bmp", - "com/win32com/readme.html", - # Licenses - "com/win32comext/mapi/NOTICE.md", - "pythonwin/License.txt", - "pythonwin/pywin/idle/*.txt", - "win32/License.txt", - # win32com test utility files. - "com/win32com/test/*.idl", - "com/win32com/test/*.js", - "com/win32com/test/*.sct", - "com/win32com/test/*.txt", - "com/win32com/test/*.vbs", - "com/win32com/test/*.xsl", - # win32com docs - "com/win32com/HTML/*.html", - "com/win32com/HTML/image/*.gif", - "com/win32comext/adsi/demos/*.py", - # Active Scripting test and demos. - "com/win32comext/axscript/test/*.py", - "com/win32comext/axscript/test/*.pys", - "com/win32comext/axscript/test/*.vbs", - "com/win32comext/axscript/Demos/*.pys", - "com/win32comext/axscript/Demos/*.htm*", - "com/win32comext/axscript/Demos/*.gif", - "com/win32comext/axscript/Demos/*.asp", - "com/win32comext/mapi/demos/*.py", - "com/win32comext/propsys/test/*.py", - "com/win32comext/shell/test/*.py", - "com/win32comext/shell/demos/servers/*.py", - "com/win32comext/shell/demos/*.py", - "com/win32comext/taskscheduler/test/*.py", - "com/win32comext/ifilter/demo/*.py", - "com/win32comext/authorization/demos/*.py", - "com/win32comext/bits/test/*.py", - # ISAPI - "isapi/*.txt", - "isapi/samples/*.py", - "isapi/samples/*.txt", - "isapi/doc/*.html", - "isapi/test/*.py", - "isapi/test/*.txt", - # adodbapi - "adodbapi/*.txt", - "adodbapi/test/*.py", - "adodbapi/examples/*.py", - ] - ) - # The headers and .lib files - + [ + data_files=[ + *convert_optional_data_files(["PyWin32.chm"]), + *convert_data_files( + [ + "Pythonwin/start_pythonwin.pyw", + "pythonwin/pywin/*.cfg", + "pythonwin/pywin/Demos/*.py", + "pythonwin/pywin/Demos/app/*.py", + "pythonwin/pywin/Demos/ocx/*.py", + "win32/scripts/*.py", + "win32/test/*.py", + "win32/test/win32rcparser/test.rc", + "win32/test/win32rcparser/test.h", + "win32/test/win32rcparser/python.ico", + "win32/test/win32rcparser/python.bmp", + "win32/Demos/*.py", + "win32/Demos/images/*.bmp", + "com/win32com/readme.html", + # Licenses + "com/win32comext/mapi/NOTICE.md", + "pythonwin/License.txt", + "pythonwin/pywin/idle/*.txt", + "win32/License.txt", + # win32com test utility files. + "com/win32com/test/*.idl", + "com/win32com/test/*.js", + "com/win32com/test/*.sct", + "com/win32com/test/*.txt", + "com/win32com/test/*.vbs", + "com/win32com/test/*.xsl", + # win32com docs + "com/win32com/HTML/*.html", + "com/win32com/HTML/image/*.gif", + "com/win32comext/adsi/demos/*.py", + # Active Scripting test and demos. + "com/win32comext/axscript/test/*.py", + "com/win32comext/axscript/test/*.pys", + "com/win32comext/axscript/test/*.vbs", + "com/win32comext/axscript/Demos/*.pys", + "com/win32comext/axscript/Demos/*.htm*", + "com/win32comext/axscript/Demos/*.gif", + "com/win32comext/axscript/Demos/*.asp", + "com/win32comext/mapi/demos/*.py", + "com/win32comext/propsys/test/*.py", + "com/win32comext/shell/test/*.py", + "com/win32comext/shell/demos/servers/*.py", + "com/win32comext/shell/demos/*.py", + "com/win32comext/taskscheduler/test/*.py", + "com/win32comext/ifilter/demo/*.py", + "com/win32comext/authorization/demos/*.py", + "com/win32comext/bits/test/*.py", + # ISAPI + "isapi/*.txt", + "isapi/samples/*.py", + "isapi/samples/*.txt", + "isapi/doc/*.html", + "isapi/test/*.py", + "isapi/test/*.txt", + # adodbapi + "adodbapi/*.txt", + "adodbapi/test/*.py", + "adodbapi/examples/*.py", + ] + ), + # The headers and .lib files ("win32/include", ("win32/src/PyWinTypes.h",)), ( "win32com/include", @@ -2080,9 +2080,7 @@ def convert_optional_data_files(files): "com/win32com/src/include/PythonCOMServer.h", ), ), - ] - # And data files convert_data_files can't handle. - + [ + # And data files convert_data_files can't handle. ("", (str(version_file_path),)), ("pythonwin", (str(scintilla_licence_path),)), ("win32comext/mapi", (str(mapi_stubs_licence_path),)), diff --git a/win32/Demos/win32gui_dialog.py b/win32/Demos/win32gui_dialog.py index 956265a25e..4d31dcc01f 100644 --- a/win32/Demos/win32gui_dialog.py +++ b/win32/Demos/win32gui_dialog.py @@ -81,7 +81,7 @@ def toparam(self): val = default vals.append(val) full_fmt += fmt - return struct.pack(*(full_fmt,) + tuple(vals)) + return struct.pack(full_fmt, *vals) # NOTE: See the win32gui_struct module for an alternative way of dealing diff --git a/win32/Lib/win32gui_struct.py b/win32/Lib/win32gui_struct.py index a9f6a7e735..58c18bf9d4 100644 --- a/win32/Lib/win32gui_struct.py +++ b/win32/Lib/win32gui_struct.py @@ -872,7 +872,7 @@ def PackDEV_BROADCAST(devicetype, rest_fmt, rest_data, extra_data=b""): extra_data += b"\0" * (4 - len(extra_data) % 4) format = "iii" + rest_fmt full_size = struct.calcsize(format) + len(extra_data) - data = (full_size, devicetype, 0) + rest_data + data = (full_size, devicetype, 0, *rest_data) return struct.pack(format, *data) + extra_data diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index e356f89142..083f9ea47b 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -367,7 +367,7 @@ def __init__(self, *args, **namedargs): overhead of unpickling the class). """ self.volatilecounters = [] - BaseQuery.__init__(*(self,) + args, **namedargs) + BaseQuery.__init__(self, *args, **namedargs) def addperfcounter(self, object, counter, machine=None): """ @@ -465,7 +465,7 @@ def open(self, *args, **namedargs): There are currently no arguments to open. """ # do all the normal opening stuff, self._base is now the query object - BaseQuery.open(*(self,) + args, **namedargs) + BaseQuery.open(self, *args, **namedargs) # should rewrite getinstpaths to take a single tuple paths = [] for tup in self.volatilecounters: diff --git a/win32/Lib/win32timezone.py b/win32/Lib/win32timezone.py index 6c393aaf48..53663efa45 100644 --- a/win32/Lib/win32timezone.py +++ b/win32/Lib/win32timezone.py @@ -341,7 +341,8 @@ class TIME_ZONE_INFORMATION(_SimpleStruct): class DYNAMIC_TIME_ZONE_INFORMATION(TIME_ZONE_INFORMATION): - _fields_ = TIME_ZONE_INFORMATION._fields_ + [ + _fields_ = [ + *TIME_ZONE_INFORMATION._fields_, ("key_name", str), ("dynamic_daylight_time_disabled", bool), ] diff --git a/win32/scripts/ControlService.py b/win32/scripts/ControlService.py index b4d35685ce..167d338bbd 100644 --- a/win32/scripts/ControlService.py +++ b/win32/scripts/ControlService.py @@ -29,7 +29,6 @@ import win32con import win32service -import win32ui from pywin.mfc import dialog @@ -308,13 +307,7 @@ def ReloadData(self): # svc[2][2] control buttons pos = self.listCtrl.AddString(str(svc[1]) + "\t" + status + "\t" + startup) self.listCtrl.SetItemData(pos, i) - self.data.append( - tuple(svc[2]) - + ( - svc[1], - svc[0], - ) - ) + self.data.append((*svc[2], svc[1], svc[0])) i += 1 if service and service[1] == svc[0]: diff --git a/win32/scripts/pywin32_testall.py b/win32/scripts/pywin32_testall.py index 345d6413fe..cec6edb784 100644 --- a/win32/scripts/pywin32_testall.py +++ b/win32/scripts/pywin32_testall.py @@ -8,7 +8,7 @@ # locate the dirs based on where this script is - it may be either in the # source tree, or in an installed Python 'Scripts' tree. project_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) -site_packages = [site.getusersitepackages()] + site.getsitepackages() +site_packages = [site.getusersitepackages(), *site.getsitepackages()] failures = [] @@ -19,7 +19,7 @@ def run_test(script, cmdline_extras): dirname, scriptname = os.path.split(script) # some tests prefer to be run from their directory. - cmd = [sys.executable, "-u", scriptname] + cmdline_extras + cmd = [sys.executable, "-u", scriptname, *cmdline_extras] print("--- Running '%s' ---" % script) sys.stdout.flush() result = subprocess.run(cmd, check=False, cwd=dirname) @@ -43,7 +43,7 @@ def find_and_run(possible_locations, extras): def main(): import argparse - code_directories = [project_root] + site_packages + code_directories = [project_root, *site_packages] parser = argparse.ArgumentParser( description="A script to trigger tests in all subprojects of PyWin32." @@ -87,9 +87,9 @@ def main(): # win32com maybes = [ os.path.join(directory, "win32com", "test", "testall.py") - for directory in [os.path.join(project_root, "com")] + site_packages + for directory in [os.path.join(project_root, "com"), *site_packages] ] - extras = remains + ["1"] # only run "level 1" tests in CI + extras = [*remains, "1"] # only run "level 1" tests in CI find_and_run(maybes, extras) # adodbapi diff --git a/win32/test/test_pywintypes.py b/win32/test/test_pywintypes.py index cf679b7566..8383187aa5 100644 --- a/win32/test/test_pywintypes.py +++ b/win32/test/test_pywintypes.py @@ -63,7 +63,7 @@ def testTimeTuple(self): def testTimeTuplems(self): now = datetime.datetime.now() # has usec... - tt = now.timetuple() + (now.microsecond // 1000,) + tt = (*now.timetuple(), now.microsecond // 1000) pt = pywintypes.Time(tt) # we can't compare if using the old type, as it loses all sub-second res. if isinstance(pt, datetime.datetime): diff --git a/win32/test/testall.py b/win32/test/testall.py index 33c14afe43..43aa4fcfd9 100644 --- a/win32/test/testall.py +++ b/win32/test/testall.py @@ -118,8 +118,10 @@ def get_demo_tests(): # Skip any other files than .py and bad tests in any case if ext != ".py" or base in bad_demos: continue - argv = (sys.executable, os.path.join(demo_dir, base + ".py")) + argvs.get( - base, () + argv = ( + sys.executable, + os.path.join(demo_dir, base + ".py"), + *argvs.get(base, ()), ) ret.append( unittest.FunctionTestCase( @@ -218,6 +220,6 @@ def loadTestsFromModule(self, module): no_user_interaction = not parsed_args.user_interaction - sys.argv = [sys.argv[0]] + remains + sys.argv = [sys.argv[0], *remains] pywin32_testutil.testmain(testLoader=CustomLoader())