Skip to content

Commit f46adee

Browse files
authored
Adiabatically turn on pre-commit (fastmachinelearning#678)
* pre-commit * update p-clang-format * update p-clang-format * update manifest * update manifest * add citation * update format * add null clang formats * file-level * style file * global exclude * try without file-level clang-format * add pre-commit to PR template
1 parent 9551b58 commit f46adee

File tree

7 files changed

+324
-33
lines changed

7 files changed

+324
-33
lines changed

.clang-format

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignArrayOfStructures: None
7+
AlignConsecutiveMacros: None
8+
AlignConsecutiveAssignments: None
9+
AlignConsecutiveBitFields: None
10+
AlignConsecutiveDeclarations: None
11+
AlignEscapedNewlines: Right
12+
AlignOperands: Align
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortEnumsOnASingleLine: true
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: All
20+
AllowShortLambdasOnASingleLine: All
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: MultiLine
27+
AttributeMacros:
28+
- __capability
29+
BinPackArguments: true
30+
BinPackParameters: true
31+
BraceWrapping:
32+
AfterCaseLabel: false
33+
AfterClass: false
34+
AfterControlStatement: Never
35+
AfterEnum: false
36+
AfterFunction: false
37+
AfterNamespace: false
38+
AfterObjCDeclaration: false
39+
AfterStruct: false
40+
AfterUnion: false
41+
AfterExternBlock: false
42+
BeforeCatch: false
43+
BeforeElse: false
44+
BeforeLambdaBody: false
45+
BeforeWhile: false
46+
IndentBraces: false
47+
SplitEmptyFunction: true
48+
SplitEmptyRecord: true
49+
SplitEmptyNamespace: true
50+
BreakBeforeBinaryOperators: None
51+
BreakBeforeConceptDeclarations: true
52+
BreakBeforeBraces: Attach
53+
BreakBeforeInheritanceComma: false
54+
BreakInheritanceList: BeforeColon
55+
BreakBeforeTernaryOperators: true
56+
BreakConstructorInitializersBeforeComma: false
57+
BreakConstructorInitializers: BeforeColon
58+
BreakAfterJavaFieldAnnotations: false
59+
BreakStringLiterals: true
60+
ColumnLimit: 125
61+
CommentPragmas: '^ IWYU pragma:'
62+
QualifierAlignment: Leave
63+
CompactNamespaces: false
64+
ConstructorInitializerIndentWidth: 4
65+
ContinuationIndentWidth: 4
66+
Cpp11BracedListStyle: true
67+
DeriveLineEnding: true
68+
DerivePointerAlignment: false
69+
DisableFormat: false
70+
EmptyLineAfterAccessModifier: Never
71+
EmptyLineBeforeAccessModifier: LogicalBlock
72+
ExperimentalAutoDetectBinPacking: false
73+
PackConstructorInitializers: BinPack
74+
BasedOnStyle: ''
75+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
76+
AllowAllConstructorInitializersOnNextLine: true
77+
FixNamespaceComments: true
78+
ForEachMacros:
79+
- foreach
80+
- Q_FOREACH
81+
- BOOST_FOREACH
82+
IfMacros:
83+
- KJ_IF_MAYBE
84+
IncludeBlocks: Preserve
85+
IncludeCategories:
86+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
87+
Priority: 2
88+
SortPriority: 0
89+
CaseSensitive: false
90+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
91+
Priority: 3
92+
SortPriority: 0
93+
CaseSensitive: false
94+
- Regex: '.*'
95+
Priority: 1
96+
SortPriority: 0
97+
CaseSensitive: false
98+
IncludeIsMainRegex: '(Test)?$'
99+
IncludeIsMainSourceRegex: ''
100+
IndentAccessModifiers: false
101+
IndentCaseLabels: false
102+
IndentCaseBlocks: false
103+
IndentGotoLabels: true
104+
IndentPPDirectives: None
105+
IndentExternBlock: AfterExternBlock
106+
IndentRequires: false
107+
IndentWidth: 4
108+
IndentWrappedFunctionNames: false
109+
InsertTrailingCommas: None
110+
JavaScriptQuotes: Leave
111+
JavaScriptWrapImports: true
112+
KeepEmptyLinesAtTheStartOfBlocks: true
113+
LambdaBodyIndentation: Signature
114+
MacroBlockBegin: ''
115+
MacroBlockEnd: ''
116+
MaxEmptyLinesToKeep: 1
117+
NamespaceIndentation: None
118+
ObjCBinPackProtocolList: Auto
119+
ObjCBlockIndentWidth: 2
120+
ObjCBreakBeforeNestedBlockParam: true
121+
ObjCSpaceAfterProperty: false
122+
ObjCSpaceBeforeProtocolList: true
123+
PenaltyBreakAssignment: 2
124+
PenaltyBreakBeforeFirstCallParameter: 19
125+
PenaltyBreakComment: 300
126+
PenaltyBreakFirstLessLess: 120
127+
PenaltyBreakOpenParenthesis: 0
128+
PenaltyBreakString: 1000
129+
PenaltyBreakTemplateDeclaration: 10
130+
PenaltyExcessCharacter: 1000000
131+
PenaltyReturnTypeOnItsOwnLine: 60
132+
PenaltyIndentedWhitespace: 0
133+
PointerAlignment: Right
134+
PPIndentWidth: -1
135+
ReferenceAlignment: Pointer
136+
ReflowComments: true
137+
RemoveBracesLLVM: false
138+
SeparateDefinitionBlocks: Leave
139+
ShortNamespaceLines: 1
140+
SortIncludes: CaseSensitive
141+
SortJavaStaticImport: Before
142+
SortUsingDeclarations: true
143+
SpaceAfterCStyleCast: false
144+
SpaceAfterLogicalNot: false
145+
SpaceAfterTemplateKeyword: true
146+
SpaceBeforeAssignmentOperators: true
147+
SpaceBeforeCaseColon: false
148+
SpaceBeforeCpp11BracedList: false
149+
SpaceBeforeCtorInitializerColon: true
150+
SpaceBeforeInheritanceColon: true
151+
SpaceBeforeParens: ControlStatements
152+
SpaceBeforeParensOptions:
153+
AfterControlStatements: true
154+
AfterForeachMacros: true
155+
AfterFunctionDefinitionName: false
156+
AfterFunctionDeclarationName: false
157+
AfterIfMacros: true
158+
AfterOverloadedOperator: false
159+
BeforeNonEmptyParentheses: false
160+
SpaceAroundPointerQualifiers: Default
161+
SpaceBeforeRangeBasedForLoopColon: true
162+
SpaceInEmptyBlock: false
163+
SpaceInEmptyParentheses: false
164+
SpacesBeforeTrailingComments: 1
165+
SpacesInAngles: Never
166+
SpacesInConditionalStatement: false
167+
SpacesInContainerLiterals: true
168+
SpacesInCStyleCastParentheses: false
169+
SpacesInLineCommentPrefix:
170+
Minimum: 1
171+
Maximum: -1
172+
SpacesInParentheses: false
173+
SpacesInSquareBrackets: false
174+
SpaceBeforeSquareBrackets: false
175+
BitFieldColonSpacing: Both
176+
Standard: Latest
177+
StatementAttributeLikeMacros:
178+
- Q_EMIT
179+
StatementMacros:
180+
- Q_UNUSED
181+
- QT_REQUIRE_VERSION
182+
TabWidth: 8
183+
UseCRLF: false
184+
UseTab: Never
185+
WhitespaceSensitiveMacros:
186+
- STRINGIZE
187+
- PP_STRINGIZE
188+
- BOOST_PP_STRINGIZE
189+
- NS_SWIFT_NAME
190+
- CF_SWIFT_NAME
191+
...

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
A# Description
22

3-
> :memo: Please include a summary of the change.
4-
>
5-
> * Please also include relevant motivation and context.
6-
> * List any dependencies that are required for this change.
3+
> :memo: Please include a summary of the change.
4+
>
5+
> * Please also include relevant motivation and context.
6+
> * List any dependencies that are required for this change.
77
88
## Type of change
99

@@ -22,9 +22,9 @@ Note: Please delete options that are not relevant.
2222
## Tests
2323

2424
> :memo: Please describe the tests that you ran to verify your changes.
25-
>
26-
> * Provide instructions so we can reproduce.
27-
> * Please also list any relevant details for your test configuration.
25+
>
26+
> * Provide instructions so we can reproduce.
27+
> * Please also list any relevant details for your test configuration.
2828
2929
**Test Configuration**:
3030

@@ -34,4 +34,5 @@ Note: Please delete options that are not relevant.
3434
- [ ] I have commented my code, particularly in hard-to-understand areas.
3535
- [ ] I have made corresponding changes to the documentation.
3636
- [ ] My changes generate no new warnings.
37-
- [ ] I have added tests that prove my fix is effective or that my feature works.B
37+
- [ ] I have installed and run `pre-commit` on the files I edited or added.
38+
- [ ] I have added tests that prove my fix is effective or that my feature works.

.github/workflows/pre-commit.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run pre-commit
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
pre-commit:
11+
name: Format
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.7]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
submodules: recursive
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Pre-commit
29+
uses: pre-commit/[email protected]
30+
with:
31+
extra_args: --hook-stage manual

.pre-commit-config.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
exclude: ^hls4ml\/templates\/(vivado|quartus)\/(ap_types|ac_types)\/
2+
3+
repos:
4+
- repo: https://github.com/psf/black
5+
rev: 22.10.0
6+
hooks:
7+
- id: black
8+
language_version: python3
9+
args: ['--line-length=125',
10+
'--skip-string-normalization']
11+
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.3.0
14+
hooks:
15+
- id: check-added-large-files
16+
- id: check-case-conflict
17+
- id: check-merge-conflict
18+
- id: check-symlinks
19+
- id: check-yaml
20+
- id: debug-statements
21+
- id: end-of-file-fixer
22+
- id: mixed-line-ending
23+
- id: requirements-txt-fixer
24+
- id: trailing-whitespace
25+
26+
- repo: https://github.com/PyCQA/isort
27+
rev: 5.10.1
28+
hooks:
29+
- id: isort
30+
31+
- repo: https://github.com/asottile/pyupgrade
32+
rev: v3.1.0
33+
hooks:
34+
- id: pyupgrade
35+
args: ["--py36-plus"]
36+
37+
- repo: https://github.com/asottile/setup-cfg-fmt
38+
rev: v2.1.0
39+
hooks:
40+
- id: setup-cfg-fmt
41+
42+
- repo: https://github.com/pycqa/flake8
43+
rev: 5.0.4
44+
hooks:
45+
- id: flake8
46+
exclude: docs/conf.py
47+
additional_dependencies: [flake8-bugbear, flake8-print]
48+
args: ['--max-line-length=125', # github viewer width
49+
'--extend-ignore=E203'] # E203 is not PEP8 compliant
50+
51+
- repo: https://github.com/mgedmin/check-manifest
52+
rev: "0.48"
53+
hooks:
54+
- id: check-manifest
55+
stages: [manual]
56+
57+
- repo: https://github.com/jmduarte/p-clang-format
58+
rev: "v1.0.3"
59+
hooks:
60+
- id: p-clang-format
61+
types_or: [c++, c, cuda]

CONTRIBUTING.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
# How to Contribute
22

3-
We'd love to accept your patches and contributions to this project.
3+
We'd love to accept your patches and contributions to this project.
44
There are just a few small guidelines you need to follow.
55

66
## Discussion
77

8-
Share your proposal via [Github Issues](https://github.com/fastmachinelearning/hls4ml/issues).
9-
If you are looking for some issues to get started with, we have a list of [good first issues](https://github.com/fastmachinelearning/hls4ml/labels/good%20first%20issue) in the issue tracker.
8+
Share your proposal via [GitHub Issues](https://github.com/fastmachinelearning/hls4ml/issues).
9+
If you are looking for some issues to get started with, we have a list of [good first issues](https://github.com/fastmachinelearning/hls4ml/labels/good%20first%20issue) in the issue tracker.
1010
We also welcome submissions to improve the documentation.
1111

1212
## Pull Request
1313

14-
All submissions, including submissions by project members, require review.
15-
We use GitHub pull requests for this purpose.
14+
All submissions, including submissions by project members, require review.
15+
We use GitHub pull requests for this purpose.
1616
Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more information on using pull requests.
1717

1818
1. In the pull request description, clearly document all changes made and the expected behavior.
1919
1. If you are introducing new functionality, add at least one unit test under the `test` folder and make sure it passes before you submit the pull request.
2020
1. Similarly, if you are fixing a bug, add at least one unit test under the `test` folder such that the master branch fails the test and your branch passes the test.
21+
1. Install and run `pre-commit` on the files that you have edited. We are adiabatically turning on linting for the full repository (see [#678](https://github.com/fastmachinelearning/hls4ml/pull/678)).
2122
1. Submit the pull request to the [main](https://github.com/fastmachinelearning/hls4ml) branch.
2223

2324
## Code Reviews
2425

25-
We will review your contribution and, if any additional fixes or modifications are necessary, may provide feedback to guide you.
26-
When accepted, your pull request will be merged to the repository.
26+
We will review your contribution and, if any additional fixes or modifications are necessary, may provide feedback to guide you.
27+
When accepted, your pull request will be merged to the repository.
2728

2829
## Code of Conduct
2930

MANIFEST.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
include LICENSE
2-
include README.md
3-
graft example-prjs
1+
include LICENSE README.md CONTRIBUTING.md CITATION.cff pyproject.toml setup.py setup.cfg .clang-format
42
graft example-models
53
graft test
64
recursive-include hls4ml/templates *
5+
global-exclude .git .gitmodules .gitlab-ci.yml
76
include hls4ml/backends/vivado_accelerator/supported_boards.json

0 commit comments

Comments
 (0)