Skip to content

Commit 6e4f3bc

Browse files
committed
Manual fixes of nested unpacking \*\(.*\*.+\)
1 parent a64dc22 commit 6e4f3bc

14 files changed

Lines changed: 33 additions & 37 deletions

File tree

Pythonwin/pywin/Demos/ocx/ocxserialtest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import pythoncom
99
import win32con
1010
import win32ui
11-
import win32uiole
1211
from pywin.mfc import activex, dialog
1312
from win32com.client import gencache
1413

@@ -68,7 +67,7 @@ def OnComm(self):
6867

6968
class TestSerDialog(dialog.Dialog):
7069
def __init__(self, *args):
71-
dialog.Dialog.__init__(*(self, *args))
70+
dialog.Dialog.__init__(self, *args)
7271
self.olectl = None
7372

7473
def OnComm(self):

Pythonwin/pywin/docking/DockingBar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def CreateWindow(
9696
self._obj_.CreateWindow(wndClass, title, style, (0, 0, 0, 0), parent, id)
9797

9898
# Create the child dialog
99-
self.dialog = childCreator(*(self, *childCreatorArgs))
99+
self.dialog = childCreator(self, *childCreatorArgs)
100100

101101
# use the dialog dimensions as default base dimensions
102102
assert self.dialog.IsWindow(), (

Pythonwin/pywin/tools/TraceCollector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def CollectorThread(stopEvent, file):
3838

3939
class WindowOutput(winout.WindowOutput):
4040
def __init__(self, *args):
41-
winout.WindowOutput.__init__(*(self, *args))
41+
winout.WindowOutput.__init__(self, *args)
4242
self.hStopThread = win32event.CreateEvent(None, 0, 0, None)
4343
_thread.start_new(CollectorThread, (self.hStopThread, self))
4444

com/win32com/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def __setattr__(self, attr, value):
567567
args, defArgs = self._prop_map_put_[attr]
568568
except KeyError:
569569
raise AttributeError(f"'{self!r}' object has no attribute '{attr}'")
570-
self._oleobj_.Invoke(*((*args, value, *defArgs)))
570+
self._oleobj_.Invoke(*args, value, *defArgs)
571571

572572
def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None):
573573
return _get_good_single_object_(obj, obUserName, resultCLSID)

com/win32com/client/dynamic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _find_dispatch_type_(self, methodName):
354354

355355
def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args):
356356
result = self._oleobj_.InvokeTypes(
357-
*(dispid, LCID, wFlags, retType, argTypes, *args)
357+
dispid, LCID, wFlags, retType, argTypes, *args
358358
)
359359
return self._get_good_object_(result, user, resultCLSID)
360360

@@ -447,7 +447,7 @@ def _proc_(self, name, *args):
447447
item = self._olerepr_.mapFuncs[name]
448448
dispId = item.dispid
449449
return self._get_good_object_(
450-
self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0, *args))
450+
self._oleobj_.Invoke(dispId, LCID, item.desc[4], 0, *args)
451451
)
452452
except KeyError:
453453
raise AttributeError(name)
@@ -505,7 +505,7 @@ def _LazyAddAttr_(self, attr):
505505
r = olerepr._AddVar_(typeinfo, t, 0)
506506
else: # not found or TYPEDESC/IMPLICITAPP
507507
r = None
508-
if not r is None:
508+
if r is not None:
509509
key, map = r[0], r[1]
510510
item = map[key]
511511
if map == olerepr.propMapPut:

com/win32com/demos/ietoolbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def toparam(self):
9898
val = default
9999
vals.append(val)
100100
full_fmt += fmt
101-
return struct.pack(*(full_fmt, *tuple(vals)))
101+
return struct.pack(full_fmt, *vals)
102102

103103

104104
class TBBUTTON(WIN32STRUCT):
@@ -365,4 +365,4 @@ def DllUnregisterServer():
365365
DllRegisterServer()
366366
else:
367367
# import trace utility for remote debugging
368-
import win32traceutil
368+
pass

com/win32com/server/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _BroadcastNotify(self, broadcaster, extraArgs):
7777
# Ignores clients that fail.
7878
for interface in self.connections.values():
7979
try:
80-
broadcaster(*(interface, *extraArgs))
80+
broadcaster(interface, *extraArgs)
8181
except pythoncom.com_error as details:
8282
self._OnNotifyFail(interface, details)
8383

com/win32comext/axdebug/debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def BuildModule(module, built_nodes, rootNode, create_node_fn, create_node_args)
4444
# print("keeping", module.__name__)
4545
node = ModuleTreeNode(module)
4646
built_nodes[module] = node
47-
realNode = create_node_fn(*(node, *create_node_args))
47+
realNode = create_node_fn(node, *create_node_args)
4848
node.realNode = realNode
4949

5050
# Split into parent nodes.

com/win32comext/axscript/client/framework.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def profile(fn, *args):
5353
try:
5454
# roll on 1.6 :-)
5555
# return prof.runcall(fn, *args)
56-
return prof.runcall(*(fn, *args))
56+
return prof.runcall(fn, *args)
5757
finally:
5858
import pstats
5959

@@ -413,10 +413,10 @@ def GetCreateSubItem(self, parentItem, name, dispatch, flags):
413413
try:
414414
rc = self.subItems[keyName]
415415
# No changes allowed to existing flags.
416-
if not rc.flags is None and not flags is None and rc.flags != flags:
416+
if rc.flags is not None and flags is not None and rc.flags != flags:
417417
raise COMException(scode=winerror.E_INVALIDARG)
418418
# Existing item must not have a dispatch.
419-
if not rc.dispatch is None and not dispatch is None:
419+
if rc.dispatch is not None and dispatch is not None:
420420
raise COMException(scode=winerror.E_INVALIDARG)
421421
rc.flags = flags # Setup the real flags.
422422
rc.dispatch = dispatch

setup.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from distutils.command.install_data import install_data
4949

5050
build_id_patch = build_id
51-
if "." not in build_id_patch:
51+
if not "." in build_id_patch:
5252
build_id_patch += ".0"
5353
pywin32_version = "%d.%d.%s" % (
5454
sys.version_info.major,
@@ -304,7 +304,7 @@ def __init__(self, name, **kw):
304304

305305
# The stand-alone exchange SDK has these libs
306306
# Additional utility functions are only available for 32-bit builds.
307-
if platform.machine() not in ("AMD64", "ARM64"):
307+
if not platform.machine() in ("AMD64", "ARM64"):
308308
libs += " version user32 advapi32 Ex2KSdk sadapi netapi32"
309309
kw["libraries"] = libs
310310
WinExt_win32com.__init__(self, name, **kw)
@@ -1955,7 +1955,7 @@ def expand_modules(module_dir: str | os.PathLike[str]):
19551955
# will 'do the right thing' in terms of installing licence.txt into
19561956
# 'Lib/site-packages/pythonwin/licence.txt'. We exploit this to
19571957
# get 'com/win32com/whatever' installed to 'win32com/whatever'
1958-
def convert_data_files(files: Iterable[str]):
1958+
def convert_data_files(files: Iterable[str]) -> list[tuple[str, tuple[str]]]:
19591959
ret: list[tuple[str, tuple[str]]] = []
19601960
for file in files:
19611961
file = os.path.normpath(file)
@@ -1980,8 +1980,8 @@ def convert_data_files(files: Iterable[str]):
19801980
return ret
19811981

19821982

1983-
def convert_optional_data_files(files):
1984-
ret = []
1983+
def convert_optional_data_files(files) -> list[tuple[str, tuple[str]]]:
1984+
ret: list[tuple[str, tuple[str]]] = []
19851985
for file in files:
19861986
try:
19871987
temp = convert_data_files([file])
@@ -2087,13 +2087,10 @@ def convert_optional_data_files(files):
20872087
packages=packages,
20882088
py_modules=py_modules,
20892089
data_files=[
2090-
("", (os.path.join(gettempdir(), "pywin32.version.txt"),)),
2091-
*convert_optional_data_files(
2092-
[
2093-
"PyWin32.chm",
2094-
]
2095-
),
2096-
*convert_data_files(
2090+
# mypy list-item: This needs to be fixed in typeshed's types-setuptools stubs
2091+
("", (os.path.join(gettempdir(), "pywin32.version.txt"),)), # type: ignore[list-item]
2092+
*convert_optional_data_files(["PyWin32.chm"]), # type: ignore[list-item]
2093+
*convert_data_files( # type: ignore[list-item]
20972094
[
20982095
"Pythonwin/start_pythonwin.pyw",
20992096
"pythonwin/pywin/*.cfg",
@@ -2151,8 +2148,8 @@ def convert_optional_data_files(files):
21512148
]
21522149
),
21532150
# The headers and .lib files
2154-
("win32/include", ("win32/src/PyWinTypes.h",)),
2155-
(
2151+
("win32/include", ("win32/src/PyWinTypes.h",)), # type: ignore[list-item]
2152+
( # type: ignore[list-item]
21562153
"win32com/include",
21572154
(
21582155
"com/win32com/src/include/PythonCOM.h",
@@ -2161,11 +2158,11 @@ def convert_optional_data_files(files):
21612158
),
21622159
),
21632160
# And data files convert_data_files can't handle.
2164-
("win32com", ("com/License.txt",)),
2161+
("win32com", ("com/License.txt",)), # type: ignore[list-item]
21652162
# pythoncom.py doesn't quite fit anywhere else.
21662163
# Note we don't get an auto .pyc - but who cares?
2167-
("", ("com/pythoncom.py",)),
2168-
("", ("pywin32.pth",)),
2164+
("", ("com/pythoncom.py",)), # type: ignore[list-item]
2165+
("", ("pywin32.pth",)), # type: ignore[list-item]
21692166
],
21702167
)
21712168

0 commit comments

Comments
 (0)