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-considerations-for-pychecker
  • Loading branch information
Avasam committed Oct 25, 2024
2 parents 04ed60f + 30e3a75 commit d650015
Show file tree
Hide file tree
Showing 123 changed files with 694 additions and 717 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
12 changes: 6 additions & 6 deletions .github/workflows/download-arm64-libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
VERSION += f"-rc{sys.version_info.serial}"

URL = f"https://www.nuget.org/api/v2/package/pythonarm64/{VERSION}"
PATH = dest / f"pythonarm64.{VERSION}.zip"
DEST_PATH = dest / f"pythonarm64.{VERSION}.zip"

if PATH.is_file():
print("Skipping download because", PATH, "exists")
if DEST_PATH.is_file():
print("Skipping download because", DEST_PATH, "exists")
else:
print("Downloading", URL)
urlretrieve(URL, PATH)
print("Downloaded", PATH)
urlretrieve(URL, DEST_PATH)
print("Downloaded", DEST_PATH)

with ZipFile(PATH, "r") as zf:
with ZipFile(DEST_PATH, "r") as zf:
for name in zf.namelist():
zip_path = pathlib.PurePath(name)
if zip_path.parts[:2] == ("tools", "libs"):
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
architecture: ["x64", "x86"]

steps:
Expand All @@ -37,7 +37,7 @@ jobs:
run: |
python --version
pip --version
pip install --upgrade setuptools wheel
pip install --upgrade setuptools>=74 wheel
- name: Build and install
run: |
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
run: |
python --version
pip --version
pip install --upgrade setuptools wheel
pip install --upgrade setuptools>=74 wheel
- name: Obtain ARM64 library files
run: |
Expand All @@ -110,31 +110,29 @@ 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: chartboost/ruff-action@v1
- 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
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# mypy 1.5 dropped support for Python 3.7
# mypy won't understand "3.13-dev", keeping the CI simple by just omitting it
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
Expand All @@ -145,7 +143,7 @@ jobs:
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true
- run: pip install types-regex types-setuptools PyOpenGL mypy==1.11
- run: pip install types-setuptools PyOpenGL mypy==1.11
- run: mypy . --python-version=${{ matrix.python-version }}

pyright:
Expand All @@ -154,7 +152,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -164,7 +162,7 @@ jobs:
cache-dependency-path: .github/workflows/main.yml
check-latest: true
# pyright vendors typeshed, but let's make sure we have the most up to date stubs
- run: pip install types-regex types-setuptools PyOpenGL
- run: pip install types-setuptools PyOpenGL
- uses: jakebailey/pyright-action@v2
with:
python-version: ${{ matrix.python-version }}
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
2 changes: 1 addition & 1 deletion AutoDuck/makedfromi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def GetComments(line, lineNo, lines):
if len(data) != 2:
break
if data[0].strip():
break # Not a continutation!
break # Not a continuation!
if data[1].strip().startswith("@"):
# new command
break
Expand Down
2 changes: 1 addition & 1 deletion AutoDuck/py2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def format_desc(desc):
# 'first_para_of_docstring'
# '@comm next para of docstring'
# '@comm next para of docstring' ... etc
# BUT - also handling enbedded doctests, where we write
# BUT - also handling embedded doctests, where we write
# '@iex >>> etc.'
if not desc:
return ""
Expand Down
13 changes: 10 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ https://mhammond.github.io/pywin32_installers.html.
Coming in build 309, as yet unreleased
--------------------------------------

* Removed Pythonwin's mdi_pychecker module as PyChecker can't be installed on Python 3
* Removed Pythonwin's `mdi_pychecker` module as PyChecker can't be installed on Python 3 (#2412, @Avasam)
* Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam)
* Last error wrongly set by some modules (#2302, @CristiFati)
* Dropped support for Python 3.7 (#2207, @Avasam)
* Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317, @geppi)
* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2304, #2310, @geppi)
* Fix memory leak converting to PyObject from some SAFEARRAY elements (#2316)
* Fix bug where makepy support was unnecessarily generated (#2354, #2353, @geppi)
* Fail sooner on invalid `win32timezone.TimeZoneInfo` creation (#2338, @Avasam)
* Removed temporary `win32com.server.policy` reexports hack (#2344, @Avasam)
Import `DispatcherWin32trace` and `DispatcherTrace` from `win32com.server.dispatcher` instead.
Expand Down Expand Up @@ -64,7 +71,7 @@ as the .chm file, certain MAPI libraries etc, and .exe installers.
* `win32com.client.build.error`
* `win32com.client.genpy.error`
* Add EnumDesktopWindows (#2219, @CristiFati)
* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236 , @Avasam)
* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236, @Avasam)
They are now unused and all information is taken from the `exc_value` parameter.
* Fixed non-overriden `pywin.scintilla.formatter.Formatter.ColorizeString` raising `TypeError` instead of `RuntimeError` due to too many parameters (#2216, @Avasam)
* Fixed broken since Python 3 tokenization in `win32comext.axdebug.codecontainer.pySourceCodeContainer.GetSyntaxColorAttributes` (#2216, @Avasam)
Expand Down Expand Up @@ -185,7 +192,7 @@ as the .chm file, certain MAPI libraries etc, and .exe installers.
* Use byte-string (`b""`) for constant bytes values instead of superfluous `.encode` calls (#2046, @Avasam)
* Cleaned up unused imports (#1986, #2051, #1990, #2124, #2126, @Avasam)
* Removed duplicated declarations, constants and definitions (#2050, #1950, #1990, @Avasam)
* Small generalized optimization by using augmented assignements (in-place operators) where possible (#2274, @Avasam)
* Small generalized optimization by using augmented assignments (in-place operators) where possible (#2274, @Avasam)
* General speed and size improvements due to all the removed code. (#2046, #1986, #2050, #1950, #2085, #2087, #2051, #1990, #2106, #2127, #2124, #2126, #2177, #2218, #2202, #2205, #2217)

### adodbapi
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/contents.d
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ it uses overrides the default. Thus, regardless of your preferences, if the fir
indent in the file is a tab, Pythonwin uses tabs for the entire file (and
similarly, uses spaces if the first block is indented with spaces)
<nl>
Things can appear to get wierd when editing a file with mixed tabs and spaces.
Things can appear to get weird when editing a file with mixed tabs and spaces.
Although mixed tabs and spaces in the same indent is evil, there are a number
of source files that have certain classes/functions indented with spaces, and others
that use tabs. The editor will not correctly adjust to the current block - whatever
Expand Down
14 changes: 7 additions & 7 deletions Pythonwin/pythondoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ BOOL CPythonDocTemp<P>::OnSaveDocument(const TCHAR *fileName)
// @pyparm string|fileName||The name of the file being saved.
// @xref <om PyCDocument.OnSaveDocument>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("OnSaveDocument", this);
if (helper.call(fileName)) {
int ret;
Expand All @@ -131,7 +131,7 @@ BOOL CPythonDocTemp<P>::OnOpenDocument(const TCHAR *fileName)
// @pyvirtual int|PyCDocument|OnOpenDocument|Called by the MFC architecture.
// @xref <om PyCDocument.OnOpenDocument>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("OnOpenDocument", this);
if (!helper.HaveHandler()) {
PyErr_SetString(ui_module_error, "PyCDocument::OnOpenDocument handler does not exist.");
Expand All @@ -155,7 +155,7 @@ BOOL CPythonDocTemp<P>::OnNewDocument()
// @pyvirtual int|PyCDocument|OnNewDocument|Called by the MFC architecture.
// @xref <om PyCDocument.OnNewDocument>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("OnNewDocument", this);
if (!helper.HaveHandler()) {
helper.release_full();
Expand All @@ -182,7 +182,7 @@ void CPythonDocTemp<P>::OnCloseDocument()
// @pyvirtual |PyCDocument|OnCloseDocument|Called by the MFC architecture.
// @xref <om PyCDocument.OnCloseDocument>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("OnCloseDocument", this);
if (helper.HaveHandler()) {
helper.call();
Expand Down Expand Up @@ -215,15 +215,15 @@ void CPythonDocTemp<P>::DeleteContents()
P::DeleteContents();
}
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
}
template <class P>
BOOL CPythonDocTemp<P>::SaveModified()
{
// @pyvirtual int|PyCDocument|SaveModified|Called by the MFC architecture when a document is closed.
// @xref <om PyCDocument.SaveModified>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("SaveModified", this);
if (!helper.HaveHandler()) {
helper.release_full();
Expand All @@ -244,7 +244,7 @@ void CPythonDocTemp<P>::OnChangedViewList()
// @pyvirtual int|PyCDocument|OnChangedViewList|Called by the MFC architecture when after a view is attached.
// @xref <om PyCDocument.OnChangedViewList>
// @comm If a handler is defined for this function, the base (MFC) function will not
// be called. If necessary, the handler must call this function explicitely.
// be called. If necessary, the handler must call this function explicitly.
CVirtualHelper helper("OnChangedViewList", this);
if (helper.HaveHandler() && helper.call()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/debugger/fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def b():
b = 1
pywin.debugger.set_trace()
# After importing or running this module, you are likely to be
# sitting at the next line. This is because we explicitely
# sitting at the next line. This is because we explicitly
# broke into the debugger using the "set_trace() function
# "pywin.debugger.brk()" is a shorter alias for this.
c()
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
Loading

0 comments on commit d650015

Please sign in to comment.