Skip to content

Commit 678f9ea

Browse files
authored
Add style checking with pre-commit + black, and a CI job (#684)
Signed-off-by: nstarman <[email protected]>
1 parent 2e07238 commit 678f9ea

Some content is hidden

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

50 files changed

+767
-165
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# Move special cases to notes sections
55
816fba3b75c38cbb1bb6fe5b1342adc5eab694f3
66
0a2fa71a32b924cc92718db29910a6cbbc5e9341
7-
931144e7d7d5c8b23393aa730ef28962a35b113b
7+
931144e7d7d5c8b23393aa730ef28962a35b113b

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#/
2+
# @license MIT
3+
#
4+
# Copyright (c) 2022 Python Data APIs Consortium.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#/
24+
25+
# Workflow name:
26+
name: ci
27+
28+
# Workflow triggers:
29+
on:
30+
pull_request:
31+
push:
32+
branches: [main,]
33+
34+
# Workflow jobs:
35+
jobs:
36+
37+
main:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v3
41+
- uses: actions/setup-python@v4
42+
with:
43+
python-version: 3.8
44+
- uses: pre-commit/[email protected]
45+
- uses: pre-commit-ci/[email protected]
46+
if: always()

.github/workflows/pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ jobs:
4545

4646
# Avoid running this workflow for forks and allow skipping CI:
4747
if: "github.repository == 'data-apis/array-api' && !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip github]')"
48-
48+
4949
# Define a sequence of job steps...
5050
steps:
51-
51+
5252
# Checkout the repository:
5353
- name: 'Checkout repository'
5454
uses: actions/checkout@v2

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-added-large-files
6+
# Prevent giant files from being committed.
7+
- id: check-ast
8+
# Simply check whether files parse as valid python.
9+
- id: check-case-conflict
10+
# Check for files with names that would conflict on a case-insensitive
11+
# filesystem like MacOS HFS+ or Windows FAT.
12+
- id: check-json
13+
# Attempts to load all json files to verify syntax.
14+
- id: check-merge-conflict
15+
# Check for files that contain merge conflict strings.
16+
- id: check-symlinks
17+
# Checks for symlinks which do not point to anything.
18+
- id: check-toml
19+
# Attempts to load all TOML files to verify syntax.
20+
- id: check-xml
21+
# Attempts to load all xml files to verify syntax.
22+
- id: check-yaml
23+
# Attempts to load all yaml files to verify syntax.
24+
exclude: ".*(.github.*)$"
25+
- id: debug-statements
26+
# Check for debugger imports and py37+ breakpoint() calls in python
27+
# source.
28+
- id: detect-private-key
29+
# Checks for the existence of private keys.
30+
- id: end-of-file-fixer
31+
# Makes sure files end in a newline and only a newline.
32+
- id: trailing-whitespace
33+
# Trims trailing whitespace.
34+
exclude_types: [python]
35+
36+
- repo: https://github.com/pre-commit/pygrep-hooks
37+
rev: v1.10.0
38+
hooks:
39+
- id: python-check-mock-methods
40+
# Prevent common mistakes of assert mck.not_called(), assert
41+
# mck.called_once_with(...) and mck.assert_called.
42+
- id: text-unicode-replacement-char
43+
# Forbid files which have a UTF-8 Unicode replacement character.
44+
- id: python-check-blanket-noqa
45+
# Enforce that all noqa annotations always occur with specific codes.
46+
47+
- repo: https://github.com/psf/black-pre-commit-mirror
48+
rev: 23.7.0
49+
hooks:
50+
- id: black

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ The following is a list of fixes and points of clarification with regard to the
196196
- `linspace`: conversion of `start` and `stop` should follow type promotion rules ([gh-568](https://github.com/data-apis/array-api/pull/568))
197197
- `nonzero`: clarify that, for arrays having a boolean data type, non-zero elements are those elements which equal `True` ([gh-441](https://github.com/data-apis/array-api/pull/441))
198198
- `trunc`: fix description ([gh-511](https://github.com/data-apis/array-api/pull/511))
199-
- `vecdot`: clarify broadcasting behavior ([gh-417](https://github.com/data-apis/array-api/pull/417) and [gh-473](https://github.com/data-apis/array-api/pull/473))
199+
- `vecdot`: clarify broadcasting behavior ([gh-417](https://github.com/data-apis/array-api/pull/417) and [gh-473](https://github.com/data-apis/array-api/pull/473))

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Please note that the Consortium for Python Data API Standards has a Code of
22
Conduct that we ask everyone to respect, see:
3-
https://github.com/data-apis/.github/blob/master/CODE_OF_CONDUCT.md
3+
https://github.com/data-apis/.github/blob/master/CODE_OF_CONDUCT.md

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
244244

245245
<!-- ALL-CONTRIBUTORS-LIST:END -->
246246

247-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
247+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ doc = [
2929
[build-system]
3030
requires = ["setuptools"]
3131
build-backend = "setuptools.build_meta"
32+
33+
[tool.black]
34+
line-length = 88

spec/2021.12/benchmark_suite.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Benchmark suite
22

3-
Adding a benchmark suite is planned in the future.
3+
Adding a benchmark suite is planned in the future.

spec/2021.12/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
from pathlib import Path
3+
34
sys.path.insert(0, str(Path(__file__).parents[2] / "src"))
45

56
from array_api_stubs import _2021_12 as stubs_mod

0 commit comments

Comments
 (0)