Skip to content

Commit 21d5e1a

Browse files
authored
Upgrade clang-format to v22 and improve pylint pre-commit configuration (#2813)
## Summary - Migrate clang-format from `pocc/pre-commit-hooks` to `pre-commit/mirrors-clang-format` v22.1.0 - Update `.clang-format` config to maintain consistent code style across versions - Configure pylint to properly handle C extension modules (numpy, dpctl) - Remove manual clang-format-12 installation from GitHub workflow - Reformat all C++ files with clang-format v22 - Add reformatting commit to `.git-blame-ignore-revs` ## Changes ### Pre-commit configuration - Switch to `pre-commit/mirrors-clang-format` (v22.1.0) for better version pinning and consistency across environments - Add `--disable=c-extension-no-member` to pylint to avoid false positives on C extension objects ### Code style - Update `.clang-format`: Set `AfterControlStatement: Never` to preserve existing brace placement style - Reformat all C++ source files with clang-format v22 (net -159 lines due to template parameter formatting improvements) ### Pylint configuration - Add `extension-pkg-allow-list = ["numpy"]` to help pylint understand numpy better - Add `generated-members` patterns to handle dynamically created attributes on numpy types ### CI/CD - Remove obsolete `apt-get install clang-format-12` step from pre-commit workflow
1 parent cba3d51 commit 21d5e1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+241
-400
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BinPackParameters: false
1616
BraceWrapping:
1717
AfterCaseLabel: true
1818
AfterClass: true
19-
AfterControlStatement: MultiLine
19+
AfterControlStatement: Never
2020
AfterEnum: true
2121
AfterFunction: true
2222
AfterNamespace: true

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ c106d91b866f4acd30226b68519b12a73a881490
1717

1818
# Add pygrep-hooks to pre-commit config
1919
e62718415aa3660da5f607e352c991a063a54219
20+
21+
# Bump clang-format from 12.0.1 to 22.1.0 version
22+
c2d65bd451a7d8e5b6319147da95e9dabf7a382b

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ jobs:
1515
timeout-minutes: 10
1616

1717
steps:
18-
- name: Set up clang-format
19-
run: |
20-
sudo apt-get install -y clang-format-12
21-
sudo unlink /usr/bin/clang-format
22-
sudo ln -s /usr/bin/clang-format-12 /usr/bin/clang-format
23-
clang-format --version
24-
2518
- name: Set up pip packages
2619
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
2720
with:

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ repos:
8888
additional_dependencies:
8989
- flake8-docstrings==1.7.0
9090
- flake8-bugbear==24.12.12
91-
- repo: https://github.com/pocc/pre-commit-hooks
92-
rev: v1.3.5
91+
- repo: https://github.com/pre-commit/mirrors-clang-format
92+
rev: v22.1.0
9393
hooks:
9494
- id: clang-format
9595
args: ["-i"]
@@ -114,7 +114,8 @@ repos:
114114
"-sn", # Don't display the score
115115
"--disable=import-error",
116116
"--disable=redefined-builtin",
117-
"--disable=unused-wildcard-import"
117+
"--disable=unused-wildcard-import",
118+
"--disable=c-extension-no-member"
118119
]
119120
files: '^dpnp/(dpnp_iface.*|fft|linalg|scipy|dpnp_array)'
120121
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks

benchmarks/asv.conf.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
// List of branches to benchmark. If not provided, defaults to "master"
1717
// (for git) or "tip" (for mercurial).
18-
"branches": ["HEAD"],
18+
"branches": [
19+
"HEAD"
20+
],
1921

2022
// The DVCS being used. If not set, it will be automatically
2123
// determined from "repo" by looking at the protocol in the URL
@@ -35,7 +37,9 @@
3537

3638
// The Pythons you'd like to test against. If not provided, defaults
3739
// to the current version of Python used to run `asv`.
38-
"pythons": ["3.7"],
40+
"pythons": [
41+
"3.7"
42+
],
3943

4044
// The matrix of dependencies to test. Each key is the name of a
4145
// package (in PyPI) and the values are version numbers. An empty
@@ -53,7 +57,6 @@
5357
// environments in. If not provided, defaults to "env"
5458
"env_dir": "env",
5559

56-
5760
// The directory (relative to the current directory) that raw benchmark
5861
// results are stored in. If not provided, defaults to "results".
5962
"results_dir": "results",
@@ -79,7 +82,8 @@
7982
// skipped for the matching benchmark.
8083
//
8184
// "regressions_first_commits": {
82-
// "some_benchmark": "352cdf", // Consider regressions only after this commit
85+
// "some_benchmark": "352cdf", // Consider regressions only after this
86+
// commit
8387
// "another_benchmark": null, // Skip regression detection altogether
8488
// }
8589
}

dpnp/backend/extensions/blas/dot_common.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ std::pair<sycl::event, sycl::event>
9797

9898
if (!dpctl::utils::queues_are_compatible(
9999
exec_q,
100-
{vectorX.get_queue(), vectorY.get_queue(), result.get_queue()}))
101-
{
100+
{vectorX.get_queue(), vectorY.get_queue(), result.get_queue()})) {
102101
throw py::value_error(
103102
"USM allocations are not compatible with the execution queue.");
104103
}
@@ -120,8 +119,8 @@ std::pair<sycl::event, sycl::event>
120119
const int vectorY_typenum = vectorY.get_typenum();
121120
const int result_typenum = result.get_typenum();
122121

123-
if (result_typenum != vectorX_typenum || result_typenum != vectorY_typenum)
124-
{
122+
if (result_typenum != vectorX_typenum ||
123+
result_typenum != vectorY_typenum) {
125124
throw py::value_error("Given arrays must be of the same type.");
126125
}
127126

dpnp/backend/extensions/blas/gemm.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ std::tuple<sycl::event, sycl::event, bool>
181181

182182
if (!dpctl::utils::queues_are_compatible(
183183
exec_q,
184-
{matrixA.get_queue(), matrixB.get_queue(), resultC.get_queue()}))
185-
{
184+
{matrixA.get_queue(), matrixB.get_queue(), resultC.get_queue()})) {
186185
throw py::value_error(
187186
"USM allocations are not compatible with the execution queue.");
188187
}

dpnp/backend/extensions/blas/gemm_batch.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ std::tuple<sycl::event, sycl::event, bool>
237237

238238
if (!dpctl::utils::queues_are_compatible(
239239
exec_q,
240-
{matrixA.get_queue(), matrixB.get_queue(), resultC.get_queue()}))
241-
{
240+
{matrixA.get_queue(), matrixB.get_queue(), resultC.get_queue()})) {
242241
throw py::value_error(
243242
"USM allocations are not compatible with the execution queue.");
244243
}

dpnp/backend/extensions/blas/gemv.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ std::pair<sycl::event, sycl::event>
169169

170170
if (!dpctl::utils::queues_are_compatible(
171171
exec_q,
172-
{matrixA.get_queue(), vectorX.get_queue(), vectorY.get_queue()}))
173-
{
172+
{matrixA.get_queue(), vectorX.get_queue(), vectorY.get_queue()})) {
174173
throw py::value_error(
175174
"USM allocations are not compatible with the execution queue.");
176175
}

dpnp/backend/extensions/blas/syrk.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ std::pair<sycl::event, sycl::event>
248248
}
249249

250250
if (!dpctl::utils::queues_are_compatible(
251-
exec_q, {matrixA.get_queue(), resultC.get_queue()}))
252-
{
251+
exec_q, {matrixA.get_queue(), resultC.get_queue()})) {
253252
throw py::value_error(
254253
"USM allocations are not compatible with the execution queue.");
255254
}

0 commit comments

Comments
 (0)