Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ max_line_length = 88 # Same as Ruff's default
[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml,json,toml}]
[*.{yaml,yml,json,toml,clang-format}]
indent_size = 2
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
python-version: "3.8"
cache: pip
cache-dependency-path: .github/workflows/main.yml
- run: pip install clang-format pycln
- run: pip install clang-format==18.1.* pycln
- run: pycln . --config=pycln.toml --check
- uses: astral-sh/ruff-action@v1
with:
Expand All @@ -124,8 +124,10 @@ jobs:
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 '*.cpp' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
if ($LastExitCode -ne 0) { exit $LastExitCode }
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
if ($LastExitCode -ne 0) { exit $LastExitCode }

mypy:
runs-on: windows-2019
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.5
rev: v18.1.8
hooks:
- id: clang-format
# Supports a lot more filetypes, but only tagging those we use
Expand Down
3 changes: 1 addition & 2 deletions com/TestSources/PyCOMTest/PyCOMImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ HRESULT CPyCOMTest::VerifyArrayOfStructs(TestStruct2 *prec, VARIANT_BOOL *is_ok)
return E_FAIL;
}
*is_ok = VARIANT_TRUE;
for (i = 0; i < prec->rec_count; i++)
{
for (i = 0; i < prec->rec_count; i++) {
if (_wcsicmp(pdata[i].str_value, L"This is record number") != 0 || pdata[i].int_value != i + 1) {
*is_ok = VARIANT_FALSE;
break;
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/src/include/PythonCOM.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ class PYCOM_EXPORT PyOleNothing : public PyObject {
// The other 2 wrap directly around the underlying method call.
#define PY_INTERFACE_METHOD
// Identical to Py_BEGIN_ALLOW_THREADS except no { !!!
#define PY_INTERFACE_PRECALL PyThreadState *_save = PyEval_SaveThread();
#define PY_INTERFACE_POSTCALL PyEval_RestoreThread(_save);
#define PY_INTERFACE_PRECALL PyThreadState *_save = PyEval_SaveThread()
#define PY_INTERFACE_POSTCALL PyEval_RestoreThread(_save)

/////////////////////////////////////////////////////////////////////////////
// class PyIUnknown
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/src/oleargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var)
// them as VARIANT elements but put them directly into the SAFEARRAY.
if (is_record_item) {
if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_RECORD))
return FALSE;
return FALSE;
V_VT(var) = VT_ARRAY | VT_RECORD;
}
else {
Expand Down Expand Up @@ -1597,7 +1597,7 @@ BOOL PythonOleArgHelper::MakeObjToVariant(PyObject *obj, VARIANT *var, PyObject
// Nothing else to do - the code below sets the VT up correctly.
break;
case VT_RECORD:
case VT_RECORD | VT_BYREF:
case VT_RECORD | VT_BYREF:
rc = PyObject_AsVARIANTRecordInfo(obj, var);
break;
case VT_CY:
Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/ifilter/src/PyIFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ static int AddIID(PyObject *dict, const char *key, REFGUID guid)

#define ADD_CONSTANT(tok) \
if (0 != AddConstant(dict, #tok, tok)) \
PYWIN_MODULE_INIT_RETURN_ERROR
PYWIN_MODULE_INIT_RETURN_ERROR;
#define ADD_IID(tok) \
if (0 != AddIID(dict, #tok, tok)) \
PYWIN_MODULE_INIT_RETURN_ERROR
PYWIN_MODULE_INIT_RETURN_ERROR;

// @object PyIFilter|Wraps the interfaces used with Indexing Service filtering
static struct PyMethodDef PyIFilter_methods[] = {
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/shell/src/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ void PyObject_CleanupDEFCONTEXTMENU(DEFCONTEXTMENU *dcm)
PyObject_FreePIDL(dcm->pidlFolder);
if (dcm->apidl)
PyObject_FreePIDLArray(dcm->cidl, dcm->apidl);
PY_INTERFACE_POSTCALL
PY_INTERFACE_POSTCALL;
}

// @object DEFCONTENTMENU|A tuple representing a DEFCONTEXTMENU structure.
Expand Down
4 changes: 2 additions & 2 deletions win32/src/PyWinTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#define PYWIN_MODULE_INIT_FUNC(module_name) extern "C" __declspec(dllexport) PyObject *PyInit_##module_name(void)

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

// When the module has successfully initialized.
#define PYWIN_MODULE_INIT_RETURN_SUCCESS return module;
#define PYWIN_MODULE_INIT_RETURN_SUCCESS return module

// To setup the module object itself and the module's dictionary.
#define PYWIN_MODULE_INIT_PREPARE(module_name, functions, docstring) \
Expand Down
2 changes: 1 addition & 1 deletion win32/src/timermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ PYWIN_MODULE_INIT_FUNC(timer)

timer_id_callback_map = PyDict_New();
if (!timer_id_callback_map)
PYWIN_MODULE_INIT_RETURN_ERROR
PYWIN_MODULE_INIT_RETURN_ERROR;

if (PyDict_SetItemString(dict, "error", PyWinExc_ApiError) == -1)
PYWIN_MODULE_INIT_RETURN_ERROR;
Expand Down
Loading
Loading