Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into adodb…
Browse files Browse the repository at this point in the history
…api-odd-docstrings-and-triple-quotes
  • Loading branch information
Avasam committed Oct 18, 2024
2 parents 2df9e97 + 5a46a21 commit 2ed2473
Show file tree
Hide file tree
Showing 54 changed files with 232 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 @@ -395,9 +395,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 @@ -634,9 +632,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 @@ -774,9 +771,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 @@ -907,9 +903,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
4 changes: 1 addition & 3 deletions adodbapi/process_connect_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def process(
dsn, dict
): # as a convenience the first argument may be django settings
kwargs.update(dsn)
elif (
dsn
): # the connection string is passed to the connection as part of the keyword dictionary
elif dsn: # the connection string is passed to the connection as part of the keyword dictionary
kwargs["connection_string"] = dsn
try:
a1 = args[1]
Expand Down
31 changes: 16 additions & 15 deletions adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,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 @@ -343,9 +344,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 @@ -487,7 +488,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 @@ -692,9 +693,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
12 changes: 6 additions & 6 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.
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.15.0 $"[11:-2]
Expand Down
1 change: 1 addition & 0 deletions adodbapi/test/setuptestframework.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python2
# Configure this in order to run the testcases.
"setuptestframework.py v 2.6.0.8"

import os
import shutil
import tempfile
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
Loading

0 comments on commit 2ed2473

Please sign in to comment.