mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
ci: GHA basic format & pre-commit (#2309)
This commit is contained in:
parent
e248869893
commit
d8c7ee00a6
19
.github/workflows/format.yml
vendored
Normal file
19
.github/workflows/format.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Format
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- stable
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pre-commit:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
- uses: pre-commit/action@v2.0.0
|
28
.pre-commit-config.yaml
Normal file
28
.pre-commit-config.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.1.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-yaml
|
||||||
|
- id: debug-statements
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- id: requirements-txt-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: fix-encoding-pragma
|
||||||
|
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
|
rev: v1.1.7
|
||||||
|
hooks:
|
||||||
|
- id: remove-tabs
|
||||||
|
exclude: (Makefile|debian/rules|.gitmodules)(\.in)?$
|
||||||
|
|
||||||
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
rev: 3.8.2
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
additional_dependencies: [flake8-bugbear]
|
||||||
|
exclude: ^(docs/.*|tools/.*)$
|
@ -27,11 +27,16 @@ adhere to the following rules to make the process as smooth as possible:
|
|||||||
do add value by themselves.
|
do add value by themselves.
|
||||||
* Add tests for any new functionality and run the test suite (``make pytest``)
|
* Add tests for any new functionality and run the test suite (``make pytest``)
|
||||||
to ensure that no existing features break.
|
to ensure that no existing features break.
|
||||||
* Please run ``flake8`` and ``tools/check-style.sh`` to check your code matches
|
* Please run [``pre-commit``][pre-commit] and ``tools/check-style.sh`` to check
|
||||||
the project style. (Note that ``check-style.sh`` requires ``gawk``.)
|
your code matches the project style. (Note that ``check-style.sh`` requires
|
||||||
|
``gawk``.) Use `pre-commit run --all-files` before committing (or use
|
||||||
|
installed-mode, check pre-commit docs) to verify your code passes before
|
||||||
|
pushing to save time.
|
||||||
* This project has a strong focus on providing general solutions using a
|
* This project has a strong focus on providing general solutions using a
|
||||||
minimal amount of code, thus small pull requests are greatly preferred.
|
minimal amount of code, thus small pull requests are greatly preferred.
|
||||||
|
|
||||||
|
[pre-commit]: https://pre-commit.com
|
||||||
|
|
||||||
### Licensing of contributions
|
### Licensing of contributions
|
||||||
|
|
||||||
pybind11 is provided under a BSD-style license that can be found in the
|
pybind11 is provided under a BSD-style license that can be found in the
|
||||||
|
@ -39,4 +39,3 @@ the last case of the above list.
|
|||||||
chrono
|
chrono
|
||||||
eigen
|
eigen
|
||||||
custom
|
custom
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -93,5 +93,3 @@ favor.
|
|||||||
.. only:: latex
|
.. only:: latex
|
||||||
|
|
||||||
.. image:: pybind11_vs_boost_python2.png
|
.. image:: pybind11_vs_boost_python2.png
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,4 +17,3 @@ These features could be implemented but would lead to a significant increase in
|
|||||||
complexity. I've decided to draw the line here to keep this project simple and
|
complexity. I've decided to draw the line here to keep this project simple and
|
||||||
compact. Users who absolutely require these features are encouraged to fork
|
compact. Users who absolutely require these features are encouraged to fork
|
||||||
pybind11.
|
pybind11.
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from ._version import version_info, __version__ # noqa: F401 imported but unused
|
from ._version import version_info, __version__ # noqa: F401 imported but unused
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
version_info = (2, 5, 'dev1')
|
version_info = (2, 5, 'dev1')
|
||||||
__version__ = '.'.join(map(str, version_info))
|
__version__ = '.'.join(map(str, version_info))
|
||||||
|
1
setup.py
1
setup.py
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Setup script for PyPI; use CMakeFile.txt to build extension modules
|
# Setup script for PyPI; use CMakeFile.txt to build extension modules
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""pytest configuration
|
"""pytest configuration
|
||||||
|
|
||||||
Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
|
Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
|
||||||
|
@ -273,4 +273,3 @@ template <class T, typename... Values> void print_values(T *inst, Values &&...va
|
|||||||
print_constr_details(inst, ":", values...);
|
print_constr_details(inst, ":", values...);
|
||||||
track_values(inst, values...);
|
track_values(inst, values...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import asyncio
|
import asyncio
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import async_module as m
|
from pybind11_tests import async_module as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import io
|
import io
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Python < 3 needs this: coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import builtin_casters as m
|
from pybind11_tests import builtin_casters as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import call_policies as m
|
from pybind11_tests import call_policies as m
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import callbacks as m
|
from pybind11_tests import callbacks as m
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import chrono as m
|
from pybind11_tests import chrono as m
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import class_ as m
|
from pybind11_tests import class_ as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
import test_cmake_build
|
import test_cmake_build
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import constants_and_functions as m
|
from pybind11_tests import constants_and_functions as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import copy_move_policies as m
|
from pybind11_tests import copy_move_policies as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import custom_type_casters as m
|
from pybind11_tests import custom_type_casters as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import docstring_options as m
|
from pybind11_tests import docstring_options as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ def test_nonunit_stride_from_python():
|
|||||||
|
|
||||||
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
|
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
|
||||||
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
|
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
|
||||||
for slice_idx, ref_mat in enumerate(slices):
|
for ref_mat in slices:
|
||||||
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
|
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
|
||||||
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
|
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ def test_negative_stride_from_python(msg):
|
|||||||
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
|
counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
|
||||||
counting_3d = counting_3d[::-1, ::-1, ::-1]
|
counting_3d = counting_3d[::-1, ::-1, ::-1]
|
||||||
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
|
slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
|
||||||
for slice_idx, ref_mat in enumerate(slices):
|
for ref_mat in slices:
|
||||||
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
|
np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
|
||||||
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
|
np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from widget_module import Widget
|
from widget_module import Widget
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import enums as m
|
from pybind11_tests import enums as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import eval_ as m
|
from pybind11_tests import eval_ as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# This file is called from 'test_eval.py'
|
# This file is called from 'test_eval.py'
|
||||||
|
|
||||||
if 'call_test2' in locals():
|
if 'call_test2' in locals():
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import exceptions as m
|
from pybind11_tests import exceptions as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import threading
|
import threading
|
||||||
from pybind11_tests import gil_scoped as m
|
from pybind11_tests import gil_scoped as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import iostream as m
|
from pybind11_tests import iostream as m
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import kwargs_and_defaults as m
|
from pybind11_tests import kwargs_and_defaults as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import local_bindings as m
|
from pybind11_tests import local_bindings as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import methods_and_attributes as m
|
from pybind11_tests import methods_and_attributes as m
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import modules as m
|
from pybind11_tests import modules as m
|
||||||
from pybind11_tests.modules import subsubmodule as ms
|
from pybind11_tests.modules import subsubmodule as ms
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
from pybind11_tests import multiple_inheritance as m
|
from pybind11_tests import multiple_inheritance as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import numpy_array as m
|
from pybind11_tests import numpy_array as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import numpy_dtypes as m
|
from pybind11_tests import numpy_dtypes as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import numpy_vectorize as m
|
from pybind11_tests import numpy_vectorize as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import opaque_types as m
|
from pybind11_tests import opaque_types as m
|
||||||
from pybind11_tests import ConstructorStats, UserType
|
from pybind11_tests import ConstructorStats, UserType
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import operators as m
|
from pybind11_tests import operators as m
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import pickling as m
|
from pybind11_tests import pickling as m
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import sequences_and_iterators as m
|
from pybind11_tests import sequences_and_iterators as m
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import smart_ptr as m
|
from pybind11_tests import smart_ptr as m
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import stl as m
|
from pybind11_tests import stl as m
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
from pybind11_tests import stl_binders as m
|
from pybind11_tests import stl_binders as m
|
||||||
@ -222,7 +223,8 @@ def test_noncopyable_containers():
|
|||||||
for j in range(0, 5):
|
for j in range(0, 5):
|
||||||
assert nvnc[i][j].value == j + 1
|
assert nvnc[i][j].value == j + 1
|
||||||
|
|
||||||
for k, v in nvnc.items():
|
# Note: maps do not have .values()
|
||||||
|
for _, v in nvnc.items():
|
||||||
for i, j in enumerate(v, start=1):
|
for i, j in enumerate(v, start=1):
|
||||||
assert j.value == i
|
assert j.value == i
|
||||||
|
|
||||||
@ -233,7 +235,7 @@ def test_noncopyable_containers():
|
|||||||
assert nmnc[i][j].value == 10 * j
|
assert nmnc[i][j].value == 10 * j
|
||||||
|
|
||||||
vsum = 0
|
vsum = 0
|
||||||
for k_o, v_o in nmnc.items():
|
for _, v_o in nmnc.items():
|
||||||
for k_i, v_i in v_o.items():
|
for k_i, v_i in v_o.items():
|
||||||
assert v_i.value == 10 * k_i
|
assert v_i.value == 10 * k_i
|
||||||
vsum += v_i.value
|
vsum += v_i.value
|
||||||
@ -247,7 +249,7 @@ def test_noncopyable_containers():
|
|||||||
assert numnc[i][j].value == 10 * j
|
assert numnc[i][j].value == 10 * j
|
||||||
|
|
||||||
vsum = 0
|
vsum = 0
|
||||||
for k_o, v_o in numnc.items():
|
for _, v_o in numnc.items():
|
||||||
for k_i, v_i in v_o.items():
|
for k_i, v_i in v_o.items():
|
||||||
assert v_i.value == 10 * k_i
|
assert v_i.value == 10 * k_i
|
||||||
vsum += v_i.value
|
vsum += v_i.value
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import tagbased_polymorphic as m
|
from pybind11_tests import tagbased_polymorphic as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import union_ as m
|
from pybind11_tests import union_ as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import virtual_functions as m
|
from pybind11_tests import virtual_functions as m
|
||||||
|
@ -78,4 +78,3 @@ else (EIGEN3_INCLUDE_DIR)
|
|||||||
mark_as_advanced(EIGEN3_INCLUDE_DIR)
|
mark_as_advanced(EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
endif(EIGEN3_INCLUDE_DIR)
|
endif(EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function, division
|
from __future__ import print_function, division
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -35,4 +36,3 @@ else:
|
|||||||
|
|
||||||
with open(save, 'w') as sf:
|
with open(save, 'w') as sf:
|
||||||
sf.write(str(libsize))
|
sf.write(str(libsize))
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Syntax: mkdoc.py [-I<path> ..] [.. a list of header files ..]
|
# Syntax: mkdoc.py [-I<path> ..] [.. a list of header files ..]
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user