Skip to content

Commit d8c7ee0

Browse files
authored
ci: GHA basic format & pre-commit (#2309)
1 parent e248869 commit d8c7ee0

Some content is hidden

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

60 files changed

+121
-28
lines changed

.github/workflows/format.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Format
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
- stable
10+
- "v*"
11+
12+
jobs:
13+
pre-commit:
14+
name: Format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-python@v2
19+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.1.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-symlinks
9+
- id: check-yaml
10+
- id: debug-statements
11+
- id: end-of-file-fixer
12+
- id: mixed-line-ending
13+
- id: requirements-txt-fixer
14+
- id: trailing-whitespace
15+
- id: fix-encoding-pragma
16+
17+
- repo: https://github.com/Lucas-C/pre-commit-hooks
18+
rev: v1.1.7
19+
hooks:
20+
- id: remove-tabs
21+
exclude: (Makefile|debian/rules|.gitmodules)(\.in)?$
22+
23+
- repo: https://gitlab.com/pycqa/flake8
24+
rev: 3.8.2
25+
hooks:
26+
- id: flake8
27+
additional_dependencies: [flake8-bugbear]
28+
exclude: ^(docs/.*|tools/.*)$

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions

docs/advanced/cast/index.rst

Lines changed: 0 additions & 1 deletion

docs/advanced/classes.rst

Lines changed: 2 additions & 2 deletions

docs/advanced/misc.rst

Lines changed: 5 additions & 5 deletions

docs/advanced/pycpp/object.rst

Lines changed: 4 additions & 4 deletions

docs/benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import random
23
import os
34
import time

docs/benchmark.rst

Lines changed: 0 additions & 2 deletions

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@
130130
else:
131131
html_context = {
132132
'css_files': [
133-
'//media.readthedocs.org/css/sphinx_rtd_theme.css',
134-
'//media.readthedocs.org/css/readthedocs-doc-embed.css',
133+
'//media.readthedocs.org/css/sphinx_rtd_theme.css',
134+
'//media.readthedocs.org/css/readthedocs-doc-embed.css',
135135
'_static/theme_overrides.css'
136136
]
137137
}

docs/limitations.rst

Lines changed: 0 additions & 1 deletion

pybind11/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from ._version import version_info, __version__ # noqa: F401 imported but unused
23

34

pybind11/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import print_function
23

34
import argparse

pybind11/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# -*- coding: utf-8 -*-
12
version_info = (2, 5, 'dev1')
23
__version__ = '.'.join(map(str, version_info))

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
23

34
# Setup script for PyPI; use CMakeFile.txt to build extension modules
45

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""pytest configuration
23
34
Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.

tests/constructor_stats.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,3 @@ template <class T, typename... Values> void print_values(T *inst, Values &&...va
273273
print_constr_details(inst, ":", values...);
274274
track_values(inst, values...);
275275
}
276-

tests/test_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import asyncio
23
import pytest
34
from pybind11_tests import async_module as m

tests/test_buffers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import io
23
import struct
34
import sys

tests/test_builtin_casters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Python < 3 needs this: coding=utf-8
1+
# -*- coding: utf-8 -*-
22
import pytest
33

44
from pybind11_tests import builtin_casters as m

tests/test_call_policies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import call_policies as m
34
from pybind11_tests import ConstructorStats

tests/test_callbacks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import callbacks as m
34
from threading import Thread

tests/test_chrono.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from pybind11_tests import chrono as m
23
import datetime
34

tests/test_class.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23

34
from pybind11_tests import class_ as m

tests/test_cmake_build/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import sys
23
import test_cmake_build
34

tests/test_constants_and_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from pybind11_tests import constants_and_functions as m
23

34

tests/test_copy_move.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import copy_move_policies as m
34

tests/test_custom_type_casters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import custom_type_casters as m
34

tests/test_docstring_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from pybind11_tests import docstring_options as m
23

34

tests/test_eigen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import ConstructorStats
34

@@ -143,7 +144,7 @@ def test_nonunit_stride_from_python():
143144

144145
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
145146
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
146-
for slice_idx, ref_mat in enumerate(slices):
147+
for ref_mat in slices:
147148
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
148149
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
149150

@@ -172,7 +173,7 @@ def test_negative_stride_from_python(msg):
172173
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
173174
counting_3d = counting_3d[::-1, ::-1, ::-1]
174175
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
175-
for slice_idx, ref_mat in enumerate(slices):
176+
for ref_mat in slices:
176177
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
177178
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
178179

tests/test_embed/test_interpreter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from widget_module import Widget
23

34

tests/test_enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import enums as m
34

tests/test_eval.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import os
23
import pytest
34
from pybind11_tests import eval_ as m

tests/test_eval_call.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# This file is called from 'test_eval.py'
23

34
if 'call_test2' in locals():

tests/test_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23

34
from pybind11_tests import exceptions as m

tests/test_factory_constructors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
import re
34

tests/test_gil_scoped.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import multiprocessing
23
import threading
34
from pybind11_tests import gil_scoped as m

tests/test_iostream.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from pybind11_tests import iostream as m
23
import sys
34

tests/test_kwargs_and_defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import kwargs_and_defaults as m
34

tests/test_local_bindings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23

34
from pybind11_tests import local_bindings as m

tests/test_methods_and_attributes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import methods_and_attributes as m
34
from pybind11_tests import ConstructorStats

tests/test_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from pybind11_tests import modules as m
23
from pybind11_tests.modules import subsubmodule as ms
34
from pybind11_tests import ConstructorStats

tests/test_multiple_inheritance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import ConstructorStats
34
from pybind11_tests import multiple_inheritance as m

tests/test_numpy_array.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import numpy_array as m
34

tests/test_numpy_dtypes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import re
23
import pytest
34
from pybind11_tests import numpy_dtypes as m

tests/test_numpy_vectorize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import numpy_vectorize as m
34

tests/test_opaque_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import opaque_types as m
34
from pybind11_tests import ConstructorStats, UserType

tests/test_operator_overloading.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import operators as m
34
from pybind11_tests import ConstructorStats

tests/test_pickling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import pickling as m
34

tests/test_pytypes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import division
23
import pytest
34
import sys

tests/test_sequences_and_iterators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
from pybind11_tests import sequences_and_iterators as m
34
from pybind11_tests import ConstructorStats

0 commit comments

Comments
 (0)