Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into remov…
Browse files Browse the repository at this point in the history
…e-adodbapi-only-obsolete-python-code
  • Loading branch information
Avasam committed Oct 18, 2024
2 parents d63cc33 + 5a46a21 commit 485e163
Show file tree
Hide file tree
Showing 54 changed files with 233 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_size = 4
max_line_length = 120 # Same as .clang-format

[*.py]
max_line_length = 88 # Same as Black
max_line_length = 88 # Same as Ruff's default
[*.md]
trim_trailing_whitespace = false
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# 2024-05-28 formatted c++ source with clang-format
637448f8252ab142eedd539ddf9b08259b73eecc

# 2024-10-14 formatted Python source with Ruff format
2b5191d8fc6f1d1fbde01481b49278c1957ef8f1
13 changes: 6 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,22 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# This job only needs to target the oldest version supported by our checkers
# (black>=24.10.0 supports Python >=3.9)
python-version: "3.9"
# This job only needs to target the oldest supported version
python-version: "3.8"
cache: pip
cache-dependency-path: .github/workflows/main.yml
- run: pip install clang-format pycln
- run: pycln . --config=pycln.toml --check
- uses: astral-sh/ruff-action@v1
with:
version: "0.4.5"
- uses: psf/black@stable
version: "0.4.9"
- uses: astral-sh/ruff-action@v1
with:
options: "--fast --check --diff --verbose"
version: "0.4.9"
args: "format --check"
- run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
clang-format --Werror --dry-run $(git ls-files '*.cpp')
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
shell: powershell
mypy:
runs-on: windows-2019
Expand Down
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ repos:
hooks:
- id: ruff # Run the linter.
args: [--fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
verbose: true
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.5
hooks:
Expand Down
28 changes: 7 additions & 21 deletions AutoDuck/Dump2HHC.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1):
<param name="ImageNumber" value="1">
<param name="Local" value="{CHM}{context}">
</OBJECT>
""".format(
**locals()
)
""".format(**locals())
)
if not do_children:
continue
Expand Down Expand Up @@ -339,9 +337,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{target}.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)

for cat in cats:
Expand All @@ -355,9 +351,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
# Next write the overviews for this category
output.write(
Expand All @@ -368,9 +362,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_overview.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.overviewTopics, cat, output, target)
_genItemsFromDict(cat.extOverviewTopics, cat, output, target)
Expand All @@ -387,9 +379,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_modules.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.modules, cat, output, target)
output.write(
Expand All @@ -404,9 +394,7 @@ def genTOC(cats, output, title, target):
<param name="ImageNumber" value="1">
<param name="Local" value="{CHM}{cat_id}_objects.html">
</OBJECT>
<UL>""".format(
**locals()
)
<UL>""".format(**locals())
)
# Don't show 'children' for objects - params etc don't need their own child nodes!
_genItemsFromDict(cat.objects, cat, output, target, do_children=0)
Expand All @@ -423,9 +411,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_constants.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.constants, cat, output, target)
output.write(
Expand Down
19 changes: 11 additions & 8 deletions Pythonwin/pywin/dialogs/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ def OnListClick(self, id, code):
return 1

def OnListItemChange(self, std, extra):
(hwndFrom, idFrom, code), (
itemNotify,
sub,
newState,
oldState,
change,
point,
lparam,
(
(hwndFrom, idFrom, code),
(
itemNotify,
sub,
newState,
oldState,
change,
point,
lparam,
),
) = (std, extra)
oldSel = (oldState & commctrl.LVIS_SELECTED) != 0
newSel = (newState & commctrl.LVIS_SELECTED) != 0
Expand Down
3 changes: 2 additions & 1 deletion Pythonwin/pywin/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# The application is responsible for managing the main frame window.
#
# We also grab the FileOpen command, to invoke our Python editor
" The PythonWin application code. Manages most aspects of MDI, etc "
"The PythonWin application code. Manages most aspects of MDI, etc"

from __future__ import annotations

import os
Expand Down
4 changes: 1 addition & 3 deletions Pythonwin/pywin/framework/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
debugging_options = """No debugging
Step-through in the debugger
Run in the debugger
Post-Mortem of unhandled exceptions""".split(
"\n"
)
Post-Mortem of unhandled exceptions""".split("\n")

byte_cr = b"\r"
byte_lf = b"\n"
Expand Down
1 change: 1 addition & 0 deletions Pythonwin/pywin/framework/stdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
sys.stdin = sys.stdin.real_file
"""

import sys

get_input_line = input
Expand Down
3 changes: 1 addition & 2 deletions Pythonwin/pywin/mfc/activex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Support for ActiveX control hosting in Pythonwin.
"""
"""Support for ActiveX control hosting in Pythonwin."""

import win32ui
import win32uiole
Expand Down
19 changes: 7 additions & 12 deletions adodbapi/adodbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,7 @@ def _rollback(self):
# If attributes has adXactAbortRetaining it performs retaining aborts that is,
# calling RollbackTrans automatically starts a new transaction. Not all providers support this.
# If not, we will have to start a new transaction by this command:
if (
not self.transaction_level
): # if self.transaction_level == 0 or self.transaction_level is None:
if not self.transaction_level:
self.transaction_level = self.connector.BeginTrans()
except Exception as e:
self._raiseConnectionError(api.ProgrammingError, e)
Expand Down Expand Up @@ -625,9 +623,8 @@ def _makeDescriptionFromRS(self):
if self.rs.EOF or self.rs.BOF:
display_size = None
else:
display_size = (
f.ActualSize
) # TODO: Is this the correct defintion according to the DB API 2 Spec ?
# TODO: Is this the correct defintion according to the DB API 2 Spec ?
display_size = f.ActualSize
null_ok = bool(f.Attributes & adc.adFldMayBeNull) # v2.1 Cole
desc.append(
(
Expand Down Expand Up @@ -765,9 +762,8 @@ def get_returned_parameters(self):
after the last recordset has been read. In that case, you must coll nextset() until it
returns None, then call this method to get your returned information."""

retLst = (
[]
) # store procedures may return altered parameters, including an added "return value" item
# store procedures may return altered parameters, including an added "return value" item
retLst = []
for p in tuple(self.cmd.Parameters):
if verbose > 2:
print(
Expand Down Expand Up @@ -898,9 +894,8 @@ def _buildADOparameterList(self, parameters, sproc=False):
)
i += 1
else: # -- build own parameter list
if (
self._parameter_names
): # we expect a dictionary of parameters, this is the list of expected names
# we expect a dictionary of parameters, this is the list of expected names
if self._parameter_names:
for parm_name in self._parameter_names:
elem = parameters[parm_name]
adotype = api.pyTypeToADOType(elem)
Expand Down
2 changes: 1 addition & 1 deletion adodbapi/examples/db_print.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" db_print.py -- a simple demo for ADO database reads."""
"""db_print.py -- a simple demo for ADO database reads."""

import sys

Expand Down
2 changes: 1 addition & 1 deletion adodbapi/examples/db_table_names.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" db_table_names.py -- a simple demo for ADO database table listing."""
"""db_table_names.py -- a simple demo for ADO database table listing."""

import sys

Expand Down
31 changes: 16 additions & 15 deletions adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ def helpTestDataType(
rs = crsr.fetchone()
if allowedReturnValues:
allowedTypes = tuple([type(aRV) for aRV in allowedReturnValues])
assert isinstance(
rs[0], allowedTypes
), 'result type "%s" must be one of %s' % (type(rs[0]), allowedTypes)
assert isinstance(rs[0], allowedTypes), (
'result type "%s" must be one of %s' % (type(rs[0]), allowedTypes)
)
else:
assert isinstance(
rs[0], type(pyData)
), 'result type "%s" must be instance of %s' % (
type(rs[0]),
type(pyData),
assert isinstance(rs[0], type(pyData)), (
'result type "%s" must be instance of %s'
% (
type(rs[0]),
type(pyData),
)
)

if compareAlmostEqual and DBAPIDataTypeString == "DATETIME":
Expand All @@ -299,9 +300,9 @@ def helpTestDataType(
elif compareAlmostEqual:
s = float(pyData)
v = float(rs[0])
assert (
abs(v - s) / s < 0.00001
), "Values not almost equal recvd=%s, expected=%f" % (rs[0], s)
assert abs(v - s) / s < 0.00001, (
"Values not almost equal recvd=%s, expected=%f" % (rs[0], s)
)
else:
if allowedReturnValues:
ok = False
Expand Down Expand Up @@ -443,7 +444,7 @@ def testDataTypeDate(self):
)

def testDataTypeBinary(self):
binfld = b"\x07\x00\xE2\x40*"
binfld = b"\x07\x00\xe2\x40*"
arv = [binfld, adodbapi.Binary(binfld), bytes(binfld)]
if self.getEngine() == "PostgreSQL":
self.helpTestDataType(
Expand Down Expand Up @@ -648,9 +649,9 @@ def testRowIterator(self):
rec = crsr.fetchone()
# check that stepping through an emulated row works
for j in range(len(inParam)):
assert (
rec[j] == inParam[j]
), 'returned value:"%s" != test value:"%s"' % (rec[j], inParam[j])
assert rec[j] == inParam[j], (
'returned value:"%s" != test value:"%s"' % (rec[j], inParam[j])
)
# check that we can get a complete tuple from a row
assert (
tuple(rec) == inParam
Expand Down
14 changes: 7 additions & 7 deletions adodbapi/test/dbapi20.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python
""" Python DB API 2.0 driver compliance unit test suite.
"""Python DB API 2.0 driver compliance unit test suite.
This software is Public Domain and may be used without restrictions.
This software is Public Domain and may be used without restrictions.
"Now we have booze and barflies entering the discussion, plus rumours of
DBAs on drugs... and I won't tell you what flashes through my mind each
time I read the subject line with 'Anal Compliance' in it. All around
this is turning out to be a thoroughly unwholesome unit test."
"Now we have booze and barflies entering the discussion, plus rumours of
DBAs on drugs... and I won't tell you what flashes through my mind each
time I read the subject line with 'Anal Compliance' in it. All around
this is turning out to be a thoroughly unwholesome unit test."
-- Ian Bicking
-- Ian Bicking
"""

__version__ = "$Revision: 1.16.0 $"[11:-2]
Expand Down
27 changes: 13 additions & 14 deletions com/win32com/client/combrowse.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
"""A utility for browsing COM objects.
Usage:
Usage:
Command Prompt
Command Prompt
Use the command *"python.exe combrowse.py"*. This will display
display a fairly small, modal dialog.
Use the command *"python.exe combrowse.py"*. This will display
display a fairly small, modal dialog.
Pythonwin
Pythonwin
Use the "Run Script" menu item, and this will create the browser in an
MDI window. This window can be fully resized.
Use the "Run Script" menu item, and this will create the browser in an
MDI window. This window can be fully resized.
Details
Details
This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
browser, and displays the objects in a hierarchical window.
This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
browser, and displays the objects in a hierarchical window.
Note that this module requires the win32ui (ie, Pythonwin) distribution to
work.
Note that this module requires the win32ui (ie, Pythonwin) distribution to
work.
"""

Expand Down Expand Up @@ -581,7 +581,6 @@ def GetSubList(self):


def main(modal=True, mdi=False):

root = HLIRoot("COM Browser")
if mdi and "pywin.framework.app" in sys.modules:
# do it in a MDI window
Expand Down
7 changes: 4 additions & 3 deletions com/win32com/client/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ def _get_good_object_(self, ob, userName=None, ReturnCLSID=None):
elif isinstance(ob, tuple):
return tuple(
map(
lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(
o, oun, rc
),
lambda o,
s=self,
oun=userName,
rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc),
ob,
)
)
Expand Down
Loading

0 comments on commit 485e163

Please sign in to comment.