From d8c7ee00a687ac369e62e2032514a93a9b413502 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 20 Jul 2020 13:35:21 -0400 Subject: [PATCH] ci: GHA basic format & pre-commit (#2309) --- .github/workflows/format.yml | 19 ++++++++++++++++++ .pre-commit-config.yaml | 28 +++++++++++++++++++++++++++ CONTRIBUTING.md | 9 +++++++-- docs/advanced/cast/index.rst | 1 - docs/advanced/classes.rst | 4 ++-- docs/advanced/misc.rst | 10 +++++----- docs/advanced/pycpp/object.rst | 8 ++++---- docs/benchmark.py | 1 + docs/benchmark.rst | 2 -- docs/conf.py | 4 ++-- docs/limitations.rst | 1 - pybind11/__init__.py | 1 + pybind11/__main__.py | 1 + pybind11/_version.py | 1 + setup.py | 1 + tests/conftest.py | 1 + tests/constructor_stats.h | 1 - tests/test_async.py | 1 + tests/test_buffers.py | 1 + tests/test_builtin_casters.py | 2 +- tests/test_call_policies.py | 1 + tests/test_callbacks.py | 1 + tests/test_chrono.py | 1 + tests/test_class.py | 1 + tests/test_cmake_build/test.py | 1 + tests/test_constants_and_functions.py | 1 + tests/test_copy_move.py | 1 + tests/test_custom_type_casters.py | 1 + tests/test_docstring_options.py | 1 + tests/test_eigen.py | 5 +++-- tests/test_embed/test_interpreter.py | 1 + tests/test_enum.py | 1 + tests/test_eval.py | 1 + tests/test_eval_call.py | 1 + tests/test_exceptions.py | 1 + tests/test_factory_constructors.py | 1 + tests/test_gil_scoped.py | 1 + tests/test_iostream.py | 1 + tests/test_kwargs_and_defaults.py | 1 + tests/test_local_bindings.py | 1 + tests/test_methods_and_attributes.py | 1 + tests/test_modules.py | 1 + tests/test_multiple_inheritance.py | 1 + tests/test_numpy_array.py | 1 + tests/test_numpy_dtypes.py | 1 + tests/test_numpy_vectorize.py | 1 + tests/test_opaque_types.py | 1 + tests/test_operator_overloading.py | 1 + tests/test_pickling.py | 1 + tests/test_pytypes.py | 1 + tests/test_sequences_and_iterators.py | 1 + tests/test_smart_ptr.py | 1 + tests/test_stl.py | 1 + tests/test_stl_binders.py | 8 +++++--- tests/test_tagbased_polymorphic.py | 1 + tests/test_union.py | 1 + tests/test_virtual_functions.py | 1 + tools/FindEigen3.cmake | 1 - tools/libsize.py | 2 +- tools/mkdoc.py | 1 + 60 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/format.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..e92f96e6e --- /dev/null +++ b/.github/workflows/format.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..63e4c6f7d --- /dev/null +++ b/.pre-commit-config.yaml @@ -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/.*)$ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01596d94f..099791812 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/docs/advanced/cast/index.rst b/docs/advanced/cast/index.rst index 54c10570b..724585c92 100644 --- a/docs/advanced/cast/index.rst +++ b/docs/advanced/cast/index.rst @@ -39,4 +39,3 @@ the last case of the above list. chrono eigen custom - diff --git a/docs/advanced/classes.rst b/docs/advanced/classes.rst index b3da0378c..031484c9d 100644 --- a/docs/advanced/classes.rst +++ b/docs/advanced/classes.rst @@ -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. diff --git a/docs/advanced/misc.rst b/docs/advanced/misc.rst index 5b38ec759..7798462df 100644 --- a/docs/advanced/misc.rst +++ b/docs/advanced/misc.rst @@ -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 diff --git a/docs/advanced/pycpp/object.rst b/docs/advanced/pycpp/object.rst index 117131edc..19a226a87 100644 --- a/docs/advanced/pycpp/object.rst +++ b/docs/advanced/pycpp/object.rst @@ -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 diff --git a/docs/benchmark.py b/docs/benchmark.py index 6dc0604ea..023477212 100644 --- a/docs/benchmark.py +++ b/docs/benchmark.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import random import os import time diff --git a/docs/benchmark.rst b/docs/benchmark.rst index 59d533df9..02c2ccde7 100644 --- a/docs/benchmark.rst +++ b/docs/benchmark.rst @@ -93,5 +93,3 @@ favor. .. only:: latex .. image:: pybind11_vs_boost_python2.png - - diff --git a/docs/conf.py b/docs/conf.py index 663a816d5..0946f30e2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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' ] } diff --git a/docs/limitations.rst b/docs/limitations.rst index a1a4f1aff..59474f82f 100644 --- a/docs/limitations.rst +++ b/docs/limitations.rst @@ -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. - diff --git a/pybind11/__init__.py b/pybind11/__init__.py index 4b1de3efa..5b2f83d5c 100644 --- a/pybind11/__init__.py +++ b/pybind11/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from ._version import version_info, __version__ # noqa: F401 imported but unused diff --git a/pybind11/__main__.py b/pybind11/__main__.py index 89b263a8a..5e393cc8f 100644 --- a/pybind11/__main__.py +++ b/pybind11/__main__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import print_function import argparse diff --git a/pybind11/_version.py b/pybind11/_version.py index d0eb659bd..1f2f254ce 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- version_info = (2, 5, 'dev1') __version__ = '.'.join(map(str, version_info)) diff --git a/setup.py b/setup.py index 668b56a5b..577a6b6c3 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- # Setup script for PyPI; use CMakeFile.txt to build extension modules diff --git a/tests/conftest.py b/tests/conftest.py index 58ebecaf9..d317c49db 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """pytest configuration Extends output capture as needed by pybind11: ignore constructors, optional unordered lines. diff --git a/tests/constructor_stats.h b/tests/constructor_stats.h index 431e5acef..abfaf9161 100644 --- a/tests/constructor_stats.h +++ b/tests/constructor_stats.h @@ -273,4 +273,3 @@ template void print_values(T *inst, Values &&...va print_constr_details(inst, ":", values...); track_values(inst, values...); } - diff --git a/tests/test_async.py b/tests/test_async.py index e1c959d60..e9292c9d9 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import asyncio import pytest from pybind11_tests import async_module as m diff --git a/tests/test_buffers.py b/tests/test_buffers.py index bf7aaed70..e264311d7 100644 --- a/tests/test_buffers.py +++ b/tests/test_buffers.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import io import struct import sys diff --git a/tests/test_builtin_casters.py b/tests/test_builtin_casters.py index 91422588c..9a49ffab5 100644 --- a/tests/test_builtin_casters.py +++ b/tests/test_builtin_casters.py @@ -1,4 +1,4 @@ -# Python < 3 needs this: coding=utf-8 +# -*- coding: utf-8 -*- import pytest from pybind11_tests import builtin_casters as m diff --git a/tests/test_call_policies.py b/tests/test_call_policies.py index 7c835599c..0e3230c57 100644 --- a/tests/test_call_policies.py +++ b/tests/test_call_policies.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import call_policies as m from pybind11_tests import ConstructorStats diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py index 6439c8e72..d5d0e045d 100644 --- a/tests/test_callbacks.py +++ b/tests/test_callbacks.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import callbacks as m from threading import Thread diff --git a/tests/test_chrono.py b/tests/test_chrono.py index 55c954406..f1817e44f 100644 --- a/tests/test_chrono.py +++ b/tests/test_chrono.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import chrono as m import datetime diff --git a/tests/test_class.py b/tests/test_class.py index 6fa5b157a..c38a5e8ce 100644 --- a/tests/test_class.py +++ b/tests/test_class.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import class_ as m diff --git a/tests/test_cmake_build/test.py b/tests/test_cmake_build/test.py index 1467a61dc..87ed5135f 100644 --- a/tests/test_cmake_build/test.py +++ b/tests/test_cmake_build/test.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys import test_cmake_build diff --git a/tests/test_constants_and_functions.py b/tests/test_constants_and_functions.py index 472682d61..36b1aa64b 100644 --- a/tests/test_constants_and_functions.py +++ b/tests/test_constants_and_functions.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import constants_and_functions as m diff --git a/tests/test_copy_move.py b/tests/test_copy_move.py index 0e671d969..6b53993a9 100644 --- a/tests/test_copy_move.py +++ b/tests/test_copy_move.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import copy_move_policies as m diff --git a/tests/test_custom_type_casters.py b/tests/test_custom_type_casters.py index d3daa2c39..9475c4516 100644 --- a/tests/test_custom_type_casters.py +++ b/tests/test_custom_type_casters.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import custom_type_casters as m diff --git a/tests/test_docstring_options.py b/tests/test_docstring_options.py index 0dbca609e..80ade0f15 100644 --- a/tests/test_docstring_options.py +++ b/tests/test_docstring_options.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import docstring_options as m diff --git a/tests/test_eigen.py b/tests/test_eigen.py index d836398a0..ae868da51 100644 --- a/tests/test_eigen.py +++ b/tests/test_eigen.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest 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)) 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_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 = counting_3d[::-1, ::-1, ::-1] 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_rm(ref_mat), 2.0 * ref_mat) diff --git a/tests/test_embed/test_interpreter.py b/tests/test_embed/test_interpreter.py index 26a047921..6174ede44 100644 --- a/tests/test_embed/test_interpreter.py +++ b/tests/test_embed/test_interpreter.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from widget_module import Widget diff --git a/tests/test_enum.py b/tests/test_enum.py index 7fe9b618d..bfaa193e9 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import enums as m diff --git a/tests/test_eval.py b/tests/test_eval.py index 94228e7d2..66bec55f8 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import pytest from pybind11_tests import eval_ as m diff --git a/tests/test_eval_call.py b/tests/test_eval_call.py index 53c7e721f..d42a0a6d3 100644 --- a/tests/test_eval_call.py +++ b/tests/test_eval_call.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # This file is called from 'test_eval.py' if 'call_test2' in locals(): diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index ac2b3603e..053e7d4a2 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import exceptions as m diff --git a/tests/test_factory_constructors.py b/tests/test_factory_constructors.py index 78a3910ad..49e6f4f33 100644 --- a/tests/test_factory_constructors.py +++ b/tests/test_factory_constructors.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest import re diff --git a/tests/test_gil_scoped.py b/tests/test_gil_scoped.py index 1548337cc..1307712ad 100644 --- a/tests/test_gil_scoped.py +++ b/tests/test_gil_scoped.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import multiprocessing import threading from pybind11_tests import gil_scoped as m diff --git a/tests/test_iostream.py b/tests/test_iostream.py index 27095b270..7ac4fcece 100644 --- a/tests/test_iostream.py +++ b/tests/test_iostream.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import iostream as m import sys diff --git a/tests/test_kwargs_and_defaults.py b/tests/test_kwargs_and_defaults.py index bad6636cb..6c72a9368 100644 --- a/tests/test_kwargs_and_defaults.py +++ b/tests/test_kwargs_and_defaults.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import kwargs_and_defaults as m diff --git a/tests/test_local_bindings.py b/tests/test_local_bindings.py index be841a70c..913cf0ee5 100644 --- a/tests/test_local_bindings.py +++ b/tests/test_local_bindings.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import local_bindings as m diff --git a/tests/test_methods_and_attributes.py b/tests/test_methods_and_attributes.py index 8bda7a8b2..25a01c718 100644 --- a/tests/test_methods_and_attributes.py +++ b/tests/test_methods_and_attributes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import methods_and_attributes as m from pybind11_tests import ConstructorStats diff --git a/tests/test_modules.py b/tests/test_modules.py index 2552838c2..7e2100524 100644 --- a/tests/test_modules.py +++ b/tests/test_modules.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import modules as m from pybind11_tests.modules import subsubmodule as ms from pybind11_tests import ConstructorStats diff --git a/tests/test_multiple_inheritance.py b/tests/test_multiple_inheritance.py index 7a6e4a085..bb602f84b 100644 --- a/tests/test_multiple_inheritance.py +++ b/tests/test_multiple_inheritance.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import ConstructorStats from pybind11_tests import multiple_inheritance as m diff --git a/tests/test_numpy_array.py b/tests/test_numpy_array.py index 55571964d..2c977cd62 100644 --- a/tests/test_numpy_array.py +++ b/tests/test_numpy_array.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import numpy_array as m diff --git a/tests/test_numpy_dtypes.py b/tests/test_numpy_dtypes.py index 2e6388517..d173435fe 100644 --- a/tests/test_numpy_dtypes.py +++ b/tests/test_numpy_dtypes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import re import pytest from pybind11_tests import numpy_dtypes as m diff --git a/tests/test_numpy_vectorize.py b/tests/test_numpy_vectorize.py index c078ee7cf..bd3c01347 100644 --- a/tests/test_numpy_vectorize.py +++ b/tests/test_numpy_vectorize.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import numpy_vectorize as m diff --git a/tests/test_opaque_types.py b/tests/test_opaque_types.py index 6b3802fdb..3f2392775 100644 --- a/tests/test_opaque_types.py +++ b/tests/test_opaque_types.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import opaque_types as m from pybind11_tests import ConstructorStats, UserType diff --git a/tests/test_operator_overloading.py b/tests/test_operator_overloading.py index 1cee29889..6c927228c 100644 --- a/tests/test_operator_overloading.py +++ b/tests/test_operator_overloading.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import operators as m from pybind11_tests import ConstructorStats diff --git a/tests/test_pickling.py b/tests/test_pickling.py index 5ae05aaa0..58d67a633 100644 --- a/tests/test_pickling.py +++ b/tests/test_pickling.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import pickling as m diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index a8b653a11..5d2ccf8fd 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import division import pytest import sys diff --git a/tests/test_sequences_and_iterators.py b/tests/test_sequences_and_iterators.py index d839dbef6..8f6c0c4bb 100644 --- a/tests/test_sequences_and_iterators.py +++ b/tests/test_sequences_and_iterators.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import sequences_and_iterators as m from pybind11_tests import ConstructorStats diff --git a/tests/test_smart_ptr.py b/tests/test_smart_ptr.py index d275b3dc9..c9267f687 100644 --- a/tests/test_smart_ptr.py +++ b/tests/test_smart_ptr.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import smart_ptr as m from pybind11_tests import ConstructorStats diff --git a/tests/test_stl.py b/tests/test_stl.py index 613796356..141b3e849 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import stl as m diff --git a/tests/test_stl_binders.py b/tests/test_stl_binders.py index c1264c01f..27b326f07 100644 --- a/tests/test_stl_binders.py +++ b/tests/test_stl_binders.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest import sys from pybind11_tests import stl_binders as m @@ -222,7 +223,8 @@ def test_noncopyable_containers(): for j in range(0, 5): 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): assert j.value == i @@ -233,7 +235,7 @@ def test_noncopyable_containers(): assert nmnc[i][j].value == 10 * j 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(): assert v_i.value == 10 * k_i vsum += v_i.value @@ -247,7 +249,7 @@ def test_noncopyable_containers(): assert numnc[i][j].value == 10 * j 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(): assert v_i.value == 10 * k_i vsum += v_i.value diff --git a/tests/test_tagbased_polymorphic.py b/tests/test_tagbased_polymorphic.py index 2574d7de7..94f374da9 100644 --- a/tests/test_tagbased_polymorphic.py +++ b/tests/test_tagbased_polymorphic.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import tagbased_polymorphic as m diff --git a/tests/test_union.py b/tests/test_union.py index e1866e701..2a2c12fb4 100644 --- a/tests/test_union.py +++ b/tests/test_union.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybind11_tests import union_ as m diff --git a/tests/test_virtual_functions.py b/tests/test_virtual_functions.py index 5ce9abd35..0f2d85fce 100644 --- a/tests/test_virtual_functions.py +++ b/tests/test_virtual_functions.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from pybind11_tests import virtual_functions as m diff --git a/tools/FindEigen3.cmake b/tools/FindEigen3.cmake index 9c546a05d..66ffe8e1e 100644 --- a/tools/FindEigen3.cmake +++ b/tools/FindEigen3.cmake @@ -78,4 +78,3 @@ else (EIGEN3_INCLUDE_DIR) mark_as_advanced(EIGEN3_INCLUDE_DIR) endif(EIGEN3_INCLUDE_DIR) - diff --git a/tools/libsize.py b/tools/libsize.py index 5dcb8b0d0..50f88bdb3 100644 --- a/tools/libsize.py +++ b/tools/libsize.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import print_function, division import os import sys @@ -35,4 +36,3 @@ else: with open(save, 'w') as sf: sf.write(str(libsize)) - diff --git a/tools/mkdoc.py b/tools/mkdoc.py index cd982e070..a22aacdef 100755 --- a/tools/mkdoc.py +++ b/tools/mkdoc.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- # # Syntax: mkdoc.py [-I ..] [.. a list of header files ..] #