Skip to content

Commit 97b2b50

Browse files
[CLIENT-2092] Add pre-commit hooks (#354)
* Formats the documentation * Fixes end of line issues for all files * Github Actions: now uses precommit hooks for lint job * BUILD.md: explains how to run pre-commit hooks
1 parent c378a69 commit 97b2b50

Some content is hidden

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

62 files changed

+285
-253
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,3 @@ WhitespaceSensitiveMacros:
164164
- NS_SWIFT_NAME
165165
- CF_SWIFT_NAME
166166
...
167-

.git-blame-ignore-revs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ c8e007035f6f99859313c790de69edcdae2c696c
66
# Python source code
77
8a36b7b0977ce4771077113923a9ae1888d22fbb
88
edc3d1af41e8851e927eb82ca6e915c4841732d3
9-

.github/workflows/tests.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,7 @@ jobs:
2121
with:
2222
python-version: '3.9'
2323
architecture: 'x64'
24-
- name: Install linting dependencies
25-
run: python -m pip install flake8
26-
- name: Lint Python code
27-
run: python -m flake8
28-
- name: Lint C wrapper code
29-
uses: jidicula/[email protected]
30-
with:
31-
check-path: 'src'
32-
clang-format-version: 14
24+
- uses: pre-commit/[email protected]
3325

3426
alpine:
3527
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
160+
#.idea/

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pycqa/flake8
3+
rev: '6.0.0' # pick a git hash / tag to point to
4+
hooks:
5+
- id: flake8
6+
# Only run on files specified in .flake8
7+
pass_filenames: false
8+
9+
- repo: https://github.com/pre-commit/mirrors-clang-format
10+
rev: v14.0.6
11+
hooks:
12+
- id: clang-format
13+
files: "^src/"
14+
types: ["file", "c"]
15+
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v4.4.0
18+
hooks:
19+
- id: check-yaml
20+
- id: check-added-large-files
21+
- id: check-case-conflict
22+
- id: check-toml
23+
- id: debug-statements
24+
# Only run on files specified in .flake8
25+
pass_filenames: false
26+
files: "^(aerospike_helpers|test)/"
27+
types: ["file", "python"]
28+
- id: end-of-file-fixer
29+
30+
- repo: https://github.com/PyCQA/doc8
31+
rev: v1.1.1
32+
hooks:
33+
- id: doc8
34+
args: ["doc/"]
35+
pass_filenames: false

BUILD.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ All C source code must be formatted with `clang-format`:
182182
clang-format -i <filename>
183183
```
184184

185+
### Precommit Hooks
186+
187+
All commits must pass precommit hook tests. To install precommit hooks:
188+
```
189+
pip install pre-commit
190+
pre-commit install
191+
```
192+
193+
See pre-commit's documentation for more usage explanations.
194+
185195
## License
186196

187197
The Aerospike Python Client is made availabled under the terms of the Apache License, Version 2, as stated in the file `LICENSE`.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@
199199
distributed under the License is distributed on an "AS IS" BASIS,
200200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201201
See the License for the specific language governing permissions and
202-
limitations under the License.
202+
limitations under the License.

Releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ CLIENT-1555 Remove dependency on c-client binary from python client source insta
147147
CLIENT-1566 Python-Client hangs intermittently in automation cluster
148148

149149
## Updates
150-
* Upgraded to [Aerospike C Client 5.2.6](https://download.aerospike.com/download/client/c/notes.html#5.2.6)
150+
* Upgraded to [Aerospike C Client 5.2.6](https://download.aerospike.com/download/client/c/notes.html#5.2.6)

api-changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Backward Incompatible API Changes
22

33
The documentation of backward incompatible API changes has been moved to
4-
<https://www.aerospike.com/docs/client/python/usage/incompatible.html>.
4+
<https://www.aerospike.com/docs/client/python/usage/incompatible.html>.

doc/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ Spelling check:
3434
```bash
3535
sphinx-build -b spelling . spelling
3636
```
37-

doc/_static/theme_overrides.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
.wy-table-responsive {
1111
overflow: visible !important;
1212
}
13-
}
13+
}

doc/aerospike.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ Policy Options
663663
Commit Level Policy Options
664664
^^^^^^^^^^^^^^^^^^^^^^^^^^^
665665
666-
Specifies the number of replicas required to be successfully committed before returning success in a write operation to provide the desired consistency guarantee.
666+
Specifies the number of replicas required to be successfully committed before returning success in a write operation to
667+
provide the desired consistency guarantee.
667668
668669
.. data:: POLICY_COMMIT_LEVEL_ALL
669670
@@ -1302,15 +1303,15 @@ Flags used by :class:`~aerospike_helpers.operations.expression_operations.expres
13021303
13031304
.. data:: EXP_WRITE_UPDATE_ONLY
13041305
1305-
If bin exists, the bin will be overwritten.
1306-
If bin does not exist, the operation will be denied.
1307-
If bin does not exist, fail with BinNotFound
1308-
when EXP_WRITE_POLICY_NO_FAIL is not set.
1306+
If bin exists, the bin will be overwritten.
1307+
If bin does not exist, the operation will be denied.
1308+
If bin does not exist, fail with BinNotFound
1309+
when EXP_WRITE_POLICY_NO_FAIL is not set.
13091310
13101311
.. data:: EXP_WRITE_ALLOW_DELETE
13111312
1312-
If expression results in nil value, then delete the bin. Otherwise, return
1313-
OpNotApplicable when EXP_WRITE_POLICY_NO_FAIL is not set.
1313+
If expression results in nil value, then delete the bin. Otherwise, return
1314+
OpNotApplicable when EXP_WRITE_POLICY_NO_FAIL is not set.
13141315
13151316
.. data:: EXP_WRITE_POLICY_NO_FAIL
13161317
@@ -1541,4 +1542,3 @@ See :ref:`aerospike_operation_helpers.expressions` for more information.
15411542
.. data:: REGEX_NEWLINE
15421543
15431544
Match-any-character operators don't match a newline.
1544-

doc/aerospike_helpers.batch.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ aerospike\_helpers\.batch package
66
aerospike\_helpers\.batch\.records module
77
-----------------------------------------
88

9-
Classes for the use with client batch APIs :meth:`~Client.batch_write`, :meth:`~Client.batch_operate`, :meth:`~Client.batch_apply`, :meth:`~Client.batch_remove`.
9+
Classes for the use with client batch APIs :meth:`~Client.batch_write`, :meth:`~Client.batch_operate`,
10+
:meth:`~Client.batch_apply`, :meth:`~Client.batch_remove`.
1011

1112
.. automodule:: aerospike_helpers.batch.records
1213
:members:

doc/aerospike_helpers.cdt_ctx.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ aerospike\_helpers\.cdt_ctx module
88
.. automodule:: aerospike_helpers.cdt_ctx
99
:members:
1010
:undoc-members:
11-
:show-inheritance:
11+
:show-inheritance:

doc/aerospike_helpers.expressions.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ allow for expanded functionality and customizability.
1919
In the Python client, Aerospike expressions are built using a series of classes that represent
2020
comparison and logical operators, bins, metadata operations, and bin operations.
2121
Expressions are constructed using a Lisp like syntax by instantiating an expression that yields a boolean,
22-
such as :meth:`~aerospike_helpers.expressions.base.Eq` or :meth:`~aerospike_helpers.expressions.base.And`,
22+
such as :meth:`~aerospike_helpers.expressions.base.Eq` or :meth:`~aerospike_helpers.expressions.base.And`,
2323
while passing them other expressions and constants as arguments, and finally calling the :meth:`compile` method.
2424

2525
Example::
@@ -65,7 +65,7 @@ For:
6565
The filtered out record's ``meta`` and ``bins`` are both set to :py:obj:`None` .
6666

6767
For:
68-
68+
6969
* :meth:`~aerospike.Client.batch_write` (records filtered out by a batch or batch record policy)
7070
* :meth:`~aerospike.Client.batch_operate` (records filtered out by a batch or batch write policy)
7171
* :meth:`~aerospike.Client.batch_apply` (records filtered out by a batch or batch apply policy)
@@ -90,7 +90,8 @@ When the following documentation says an expression returns a **list expression*
9090
it means that the expression returns a list during evaluation on the server side.
9191

9292
Expressions used with :meth:`~aerospike_helpers.operations.expression_operations.expression_read`
93-
or :meth:`~aerospike_helpers.operations.expression_operations.expression_write` do send their return values to the client or write them to the server.
93+
or :meth:`~aerospike_helpers.operations.expression_operations.expression_write` do send their return values to the
94+
client or write them to the server.
9495
These expressions are called **operation expressions**.
9596

9697
When these docs say that an expression parameter requires an integer or **integer expression**,

doc/aerospike_helpers.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
:mod:`aerospike\_helpers` --- Aerospike Helper Package for bin operations (list, map, bit, etc.)
55
************************************************************************************************
66

7-
This package contains helpers to be used by the operate and operate_ordered methods for bin operations. (list, map, bitwise, etc.)
7+
This package contains helpers to be used by the operate and operate_ordered methods for bin operations.
8+
(list, map, bitwise, etc.)
89

910
.. automodule:: aerospike_helpers
1011
:members:
@@ -20,7 +21,3 @@ Subpackages
2021
aerospike_helpers.expressions
2122
aerospike_helpers.cdt_ctx
2223
aerospike_helpers.batch
23-
24-
25-
26-

0 commit comments

Comments
 (0)