Skip to content

Commit ce009b3

Browse files
authored
pre-commit and clangformat (#21)
1 parent 881573a commit ce009b3

File tree

11 files changed

+370
-279
lines changed

11 files changed

+370
-279
lines changed

.clang-format

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlinesLeft: true
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: true
12+
AllowShortCaseLabelsOnASingleLine: true
13+
AllowShortFunctionsOnASingleLine: All
14+
AllowShortIfStatementsOnASingleLine: true
15+
AllowShortLoopsOnASingleLine: true
16+
AlwaysBreakAfterReturnType: None
17+
AlwaysBreakBeforeMultilineStrings: false
18+
AlwaysBreakTemplateDeclarations: true
19+
BinPackArguments: true
20+
BinPackParameters: true
21+
BraceWrapping:
22+
AfterClass: false
23+
AfterControlStatement: false
24+
AfterEnum: false
25+
AfterFunction: false
26+
AfterNamespace: false
27+
AfterObjCDeclaration: false
28+
AfterStruct: false
29+
AfterUnion: false
30+
BeforeCatch: false
31+
BeforeElse: false
32+
IndentBraces: false
33+
BreakBeforeBinaryOperators: None
34+
BreakBeforeBraces: Attach
35+
BreakBeforeTernaryOperators: true
36+
BreakConstructorInitializersBeforeComma: true
37+
# BreakInheritanceListBeforeComma: true
38+
ColumnLimit: 88
39+
CommentPragmas: '^ IWYU pragma:'
40+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
41+
ConstructorInitializerIndentWidth: 4
42+
ContinuationIndentWidth: 4
43+
Cpp11BracedListStyle: true
44+
DerivePointerAlignment: false
45+
DisableFormat: false
46+
ExperimentalAutoDetectBinPacking: false
47+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
48+
IncludeCategories:
49+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
50+
Priority: 2
51+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
52+
Priority: 3
53+
- Regex: '.*'
54+
Priority: 1
55+
IndentCaseLabels: true
56+
IndentWidth: 2
57+
IndentWrappedFunctionNames: false
58+
KeepEmptyLinesAtTheStartOfBlocks: true
59+
MacroBlockBegin: ''
60+
MacroBlockEnd: ''
61+
MaxEmptyLinesToKeep: 1
62+
NamespaceIndentation: None
63+
ObjCBlockIndentWidth: 2
64+
ObjCSpaceAfterProperty: false
65+
ObjCSpaceBeforeProtocolList: false
66+
PenaltyBreakBeforeFirstCallParameter: 1
67+
PenaltyBreakComment: 300
68+
PenaltyBreakFirstLessLess: 120
69+
PenaltyBreakString: 1000
70+
PenaltyExcessCharacter: 1000000
71+
PenaltyReturnTypeOnItsOwnLine: 200
72+
PointerAlignment: Left
73+
ReflowComments: true
74+
SortIncludes: true
75+
SpaceAfterCStyleCast: false
76+
SpaceBeforeAssignmentOperators: true
77+
SpaceBeforeParens: ControlStatements
78+
SpaceInEmptyParentheses: false
79+
SpacesBeforeTrailingComments: 1
80+
SpacesInAngles: false
81+
SpacesInContainerLiterals: true
82+
SpacesInCStyleCastParentheses: false
83+
SpacesInParentheses: false
84+
SpacesInSquareBrackets: false
85+
Standard: Auto
86+
TabWidth: 8
87+
UseTab: Never
88+
---
89+
Language: Json
90+
BasedOnStyle: llvm
91+
...

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ venv
1616
.coverage
1717
htmlcov
1818
src/pyhepmc/_version.py
19+
.vscode

.pre-commit-config.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
repos:
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v4.1.0
19+
hooks:
20+
- id: check-case-conflict
21+
- id: check-docstring-first
22+
- id: check-executables-have-shebangs
23+
- id: check-merge-conflict
24+
- id: check-symlinks
25+
- id: check-yaml
26+
args: ["--allow-multiple-documents"]
27+
- id: debug-statements
28+
- id: end-of-file-fixer
29+
- id: mixed-line-ending
30+
- id: sort-simple-yaml
31+
- id: file-contents-sorter
32+
- id: trailing-whitespace
33+
exclude: ^doc/_static/.*.svg
34+
35+
# Python formatting
36+
- repo: https://github.com/psf/black
37+
rev: 22.3.0
38+
hooks:
39+
- id: black
40+
41+
# Python docstring formatting
42+
- repo: https://github.com/pycqa/pydocstyle
43+
rev: 6.1.1
44+
hooks:
45+
- id: pydocstyle
46+
files: src/iminuit/[^_].*\.py
47+
48+
# Python linter (Flake8)
49+
- repo: https://github.com/pycqa/flake8
50+
rev: 4.0.1
51+
hooks:
52+
- id: flake8
53+
54+
# C++ formatting
55+
- repo: https://github.com/pre-commit/mirrors-clang-format
56+
rev: v13.0.1
57+
hooks:
58+
- id: clang-format
59+
60+
# CMake formatting
61+
- repo: https://github.com/cheshirekow/cmake-format-precommit
62+
rev: v0.6.13
63+
hooks:
64+
- id: cmake-format
65+
additional_dependencies: [pyyaml]
66+
types: [file]
67+
files: (\.cmake|CMakeLists.txt)(.in)?$
68+
69+
# Python type checking
70+
- repo: https://github.com/pre-commit/mirrors-mypy
71+
rev: 'v0.971'
72+
hooks:
73+
- id: mypy
74+
additional_dependencies: [numpy]
75+
args: [src]
76+
pass_filenames: false

CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
99
)
1010
endif()
1111

12-
set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ version selection")
12+
set(CMAKE_CXX_STANDARD
13+
11
14+
CACHE STRING "C++ version selection")
1315
set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported
1416
set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensions off
1517

@@ -32,11 +34,8 @@ if(MSVC)
3234
target_compile_options(_core PRIVATE /bigobj)
3335
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
3436
else()
35-
target_compile_options(_core PRIVATE
36-
-fvisibility=hidden
37-
-Wall
38-
-Wno-self-assign-overloaded
39-
)
37+
target_compile_options(_core PRIVATE -fvisibility=hidden -Wall
38+
-Wno-self-assign-overloaded)
4039
endif()
4140
set_target_properties(_core PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
42-
target_compile_definitions(_core PRIVATE HEPMC3_HEPEVT_NMXHEP=10000)
41+
target_compile_definitions(_core PRIVATE HEPMC3_HEPEVT_NMXHEP=10000)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ PIP_ONLY_BINARY = ":all:"
3535
# to match numpy, we use manylinux2010 for cp36 to cp39
3636
select = "cp3?-*"
3737
manylinux-x86_64-image = "manylinux2010"
38-
manylinux-i686-image = "manylinux2010"
38+
manylinux-i686-image = "manylinux2010"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ max-line-length = 90
3838
ignore = E203
3939

4040
[pydocstyle]
41-
convention = numpy
41+
convention = numpy

0 commit comments

Comments
 (0)