Unverified Commit d8c7ee00 authored by Henry Schreiner's avatar Henry Schreiner Committed by GitHub
Browse files

ci: GHA basic format & pre-commit (#2309)

parent e2488698
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
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.
* Add tests for any new functionality and run the test suite (``make pytest``)
to ensure that no existing features break.
* Please run ``flake8`` and ``tools/check-style.sh`` to check your code matches
the project style. (Note that ``check-style.sh`` requires ``gawk``.)
* Please run [``pre-commit``][pre-commit] and ``tools/check-style.sh`` to check
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
minimal amount of code, thus small pull requests are greatly preferred.
[pre-commit]: https://pre-commit.com
### Licensing of contributions
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
eigen
custom
......@@ -82,7 +82,7 @@ helper class that is defined as follows:
The macro :c:macro:`PYBIND11_OVERLOAD_PURE` should be used for pure virtual
functions, and :c:macro:`PYBIND11_OVERLOAD` should be used for functions which have
a default implementation. There are also two alternate macros
a default implementation. There are also two alternate macros
:c:macro:`PYBIND11_OVERLOAD_PURE_NAME` and :c:macro:`PYBIND11_OVERLOAD_NAME` which
take a string-valued name argument between the *Parent class* and *Name of the
function* slots, which defines the name of function in Python. This is required
......@@ -1088,7 +1088,7 @@ Binding final classes
Some classes may not be appropriate to inherit from. In C++11, classes can
use the ``final`` specifier to ensure that a class cannot be inherited from.
The ``py::is_final`` attribute can be used to ensure that Python classes
The ``py::is_final`` attribute can be used to ensure that Python classes
cannot inherit from a specified type. The underlying C++ type does not need
to be declared final.
......
......@@ -218,7 +218,7 @@ collected:
Both approaches also expose a potentially dangerous ``_cleanup`` attribute in
Python, which may be undesirable from an API standpoint (a premature explicit
call from Python might lead to undefined behavior). Yet another approach that
call from Python might lead to undefined behavior). Yet another approach that
avoids this issue involves weak reference with a cleanup callback:
.. code-block:: cpp
......@@ -283,9 +283,9 @@ work, it is important that all lines are indented consistently, i.e.:
----------
)mydelimiter");
By default, pybind11 automatically generates and prepends a signature to the docstring of a function
By default, pybind11 automatically generates and prepends a signature to the docstring of a function
registered with ``module::def()`` and ``class_::def()``. Sometimes this
behavior is not desirable, because you want to provide your own signature or remove
behavior is not desirable, because you want to provide your own signature or remove
the docstring completely to exclude the function from the Sphinx documentation.
The class ``options`` allows you to selectively suppress auto-generated signatures:
......@@ -298,8 +298,8 @@ The class ``options`` allows you to selectively suppress auto-generated signatur
m.def("add", [](int a, int b) { return a + b; }, "A function which adds two numbers");
}
Note that changes to the settings affect only function bindings created during the
lifetime of the ``options`` instance. When it goes out of scope at the end of the module's init function,
Note that changes to the settings affect only function bindings created during the
lifetime of the ``options`` instance. When it goes out of scope at the end of the module's init function,
the default settings are restored to prevent unwanted side effects.
.. [#f4] http://www.sphinx-doc.org
......
......@@ -60,7 +60,7 @@ This example obtains a reference to the Python ``Decimal`` class.
Calling Python functions
========================
It is also possible to call Python classes, functions and methods
It is also possible to call Python classes, functions and methods
via ``operator()``.
.. code-block:: cpp
......@@ -75,7 +75,7 @@ via ``operator()``.
py::object makedirs = os.attr("makedirs");
makedirs("/tmp/path/to/somewhere");
One can convert the result obtained from Python to a pure C++ version
One can convert the result obtained from Python to a pure C++ version
if a ``py::class_`` or type conversion is defined.
.. code-block:: cpp
......@@ -99,8 +99,8 @@ Python method.
py::print(py::str(exp_pi));
In the example above ``pi.attr("exp")`` is a *bound method*: it will always call
the method for that same instance of the class. Alternately one can create an
*unbound method* via the Python class (instead of instance) and pass the ``self``
the method for that same instance of the class. Alternately one can create an
*unbound method* via the Python class (instead of instance) and pass the ``self``
object explicitly, followed by other arguments.
.. code-block:: cpp
......
# -*- coding: utf-8 -*-
import random
import os
import time
......
......@@ -93,5 +93,3 @@ favor.
.. only:: latex
.. image:: pybind11_vs_boost_python2.png
......@@ -130,8 +130,8 @@ if not on_rtd: # only import and set the theme if we're building docs locally
else:
html_context = {
'css_files': [
'//media.readthedocs.org/css/sphinx_rtd_theme.css',
'//media.readthedocs.org/css/readthedocs-doc-embed.css',
'//media.readthedocs.org/css/sphinx_rtd_theme.css',
'//media.readthedocs.org/css/readthedocs-doc-embed.css',
'_static/theme_overrides.css'
]
}
......
......@@ -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
compact. Users who absolutely require these features are encouraged to fork
pybind11.
# -*- coding: utf-8 -*-
from ._version import version_info, __version__ # noqa: F401 imported but unused
......
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
......
# -*- coding: utf-8 -*-
version_info = (2, 5, 'dev1')
__version__ = '.'.join(map(str, version_info))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Setup script for PyPI; use CMakeFile.txt to build extension modules
......
# -*- coding: utf-8 -*-
"""pytest configuration
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...);
track_values(inst, values...);
}
# -*- coding: utf-8 -*-
import asyncio
import pytest
from pybind11_tests import async_module as m
......
# -*- coding: utf-8 -*-
import io
import struct
import sys
......
# Python < 3 needs this: coding=utf-8
# -*- coding: utf-8 -*-
import pytest
from pybind11_tests import builtin_casters as m
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment