Skip to content

Commit d5d7d32

Browse files
authored
Consistent usage of end-of-statement marker with macros (better clang-format out of the box) & Make the CI step actually fail on failure (#2405)
1 parent 877a2c2 commit d5d7d32

File tree

13 files changed

+487
-284
lines changed

13 files changed

+487
-284
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ max_line_length = 88 # Same as Ruff's default
1414
[*.md]
1515
trim_trailing_whitespace = false
1616
17-
[*.{yaml,yml,json,toml}]
17+
[*.{yaml,yml,json,toml,clang-format}]
1818
indent_size = 2

.github/workflows/main.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
python-version: "3.8"
118118
cache: pip
119119
cache-dependency-path: .github/workflows/main.yml
120-
- run: pip install clang-format pycln
120+
- run: pip install clang-format==18.1.* pycln
121121
- run: pycln . --config=pycln.toml --check
122122
- uses: astral-sh/ruff-action@v1
123123
with:
@@ -127,8 +127,10 @@ jobs:
127127
version: "0.4.9"
128128
args: "format --check"
129129
- run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
130-
clang-format --Werror --dry-run $(git ls-files '*.cpp')
130+
clang-format --Werror --dry-run $(git ls-files '*.cpp' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
131+
if ($LastExitCode -ne 0) { exit $LastExitCode }
131132
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
133+
if ($LastExitCode -ne 0) { exit $LastExitCode }
132134
133135
mypy:
134136
runs-on: windows-2019

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
args: [--fix]
3232
- id: ruff-format
3333
- repo: https://github.com/pre-commit/mirrors-clang-format
34-
rev: v18.1.5
34+
rev: v18.1.8
3535
hooks:
3636
- id: clang-format
3737
# Supports a lot more filetypes, but only tagging those we use

com/TestSources/PyCOMTest/PyCOMImpl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,7 @@ HRESULT CPyCOMTest::VerifyArrayOfStructs(TestStruct2 *prec, VARIANT_BOOL *is_ok)
637637
return E_FAIL;
638638
}
639639
*is_ok = VARIANT_TRUE;
640-
for (i = 0; i < prec->rec_count; i++)
641-
{
640+
for (i = 0; i < prec->rec_count; i++) {
642641
if (_wcsicmp(pdata[i].str_value, L"This is record number") != 0 || pdata[i].int_value != i + 1) {
643642
*is_ok = VARIANT_FALSE;
644643
break;

com/win32com/src/include/PythonCOM.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ class PYCOM_EXPORT PyOleNothing : public PyObject {
425425
// The other 2 wrap directly around the underlying method call.
426426
#define PY_INTERFACE_METHOD
427427
// Identical to Py_BEGIN_ALLOW_THREADS except no { !!!
428-
#define PY_INTERFACE_PRECALL PyThreadState *_save = PyEval_SaveThread();
429-
#define PY_INTERFACE_POSTCALL PyEval_RestoreThread(_save);
428+
#define PY_INTERFACE_PRECALL PyThreadState *_save = PyEval_SaveThread()
429+
#define PY_INTERFACE_POSTCALL PyEval_RestoreThread(_save)
430430

431431
/////////////////////////////////////////////////////////////////////////////
432432
// class PyIUnknown

com/win32com/src/oleargs.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var)
288288
// them as VARIANT elements but put them directly into the SAFEARRAY.
289289
if (is_record_item) {
290290
if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_RECORD))
291-
return FALSE;
291+
return FALSE;
292292
V_VT(var) = VT_ARRAY | VT_RECORD;
293293
}
294294
else {
@@ -1597,7 +1597,7 @@ BOOL PythonOleArgHelper::MakeObjToVariant(PyObject *obj, VARIANT *var, PyObject
15971597
// Nothing else to do - the code below sets the VT up correctly.
15981598
break;
15991599
case VT_RECORD:
1600-
case VT_RECORD | VT_BYREF:
1600+
case VT_RECORD | VT_BYREF:
16011601
rc = PyObject_AsVARIANTRecordInfo(obj, var);
16021602
break;
16031603
case VT_CY:

com/win32comext/ifilter/src/PyIFilter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ static int AddIID(PyObject *dict, const char *key, REFGUID guid)
260260

261261
#define ADD_CONSTANT(tok) \
262262
if (0 != AddConstant(dict, #tok, tok)) \
263-
PYWIN_MODULE_INIT_RETURN_ERROR
263+
PYWIN_MODULE_INIT_RETURN_ERROR;
264264
#define ADD_IID(tok) \
265265
if (0 != AddIID(dict, #tok, tok)) \
266-
PYWIN_MODULE_INIT_RETURN_ERROR
266+
PYWIN_MODULE_INIT_RETURN_ERROR;
267267

268268
// @object PyIFilter|Wraps the interfaces used with Indexing Service filtering
269269
static struct PyMethodDef PyIFilter_methods[] = {

com/win32comext/shell/src/shell.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ void PyObject_CleanupDEFCONTEXTMENU(DEFCONTEXTMENU *dcm)
859859
PyObject_FreePIDL(dcm->pidlFolder);
860860
if (dcm->apidl)
861861
PyObject_FreePIDLArray(dcm->cidl, dcm->apidl);
862-
PY_INTERFACE_POSTCALL
862+
PY_INTERFACE_POSTCALL;
863863
}
864864

865865
// @object DEFCONTENTMENU|A tuple representing a DEFCONTEXTMENU structure.

win32/src/PyWinTypes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
#define PYWIN_MODULE_INIT_FUNC(module_name) extern "C" __declspec(dllexport) PyObject *PyInit_##module_name(void)
3333

3434
// If the module needs to early-exit on an error condition.
35-
#define PYWIN_MODULE_INIT_RETURN_ERROR return NULL;
35+
#define PYWIN_MODULE_INIT_RETURN_ERROR return NULL
3636

3737
// When the module has successfully initialized.
38-
#define PYWIN_MODULE_INIT_RETURN_SUCCESS return module;
38+
#define PYWIN_MODULE_INIT_RETURN_SUCCESS return module
3939

4040
// To setup the module object itself and the module's dictionary.
4141
#define PYWIN_MODULE_INIT_PREPARE(module_name, functions, docstring) \

win32/src/timermodule.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ PYWIN_MODULE_INIT_FUNC(timer)
146146

147147
timer_id_callback_map = PyDict_New();
148148
if (!timer_id_callback_map)
149-
PYWIN_MODULE_INIT_RETURN_ERROR
149+
PYWIN_MODULE_INIT_RETURN_ERROR;
150150

151151
if (PyDict_SetItemString(dict, "error", PyWinExc_ApiError) == -1)
152152
PYWIN_MODULE_INIT_RETURN_ERROR;

0 commit comments

Comments
 (0)