ci: GHA basic format & pre-commit (#2309)
diff --git a/tests/conftest.py b/tests/conftest.py
index 58ebeca..d317c49 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 431e5ac..abfaf91 100644
--- a/tests/constructor_stats.h
+++ b/tests/constructor_stats.h
@@ -273,4 +273,3 @@
print_constr_details(inst, ":", values...);
track_values(inst, values...);
}
-
diff --git a/tests/test_async.py b/tests/test_async.py
index e1c959d..e9292c9 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 bf7aaed..e264311 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 9142258..9a49ffa 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 7c83559..0e3230c 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 6439c8e..d5d0e04 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 55c9544..f1817e4 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 6fa5b15..c38a5e8 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 1467a61..87ed513 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 472682d..36b1aa6 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 0e671d9..6b53993 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 d3daa2c..9475c45 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 0dbca60..80ade0f 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 d836398..ae868da 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 @@
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 @@
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 26a0479..6174ede 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 7fe9b61..bfaa193 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 94228e7..66bec55 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 53c7e72..d42a0a6 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 ac2b360..053e7d4 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 78a3910..49e6f4f 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 1548337..1307712 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 27095b2..7ac4fce 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 bad6636..6c72a93 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 be841a7..913cf0e 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 8bda7a8..25a01c7 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 2552838..7e21005 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 7a6e4a0..bb602f8 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 5557196..2c977cd 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 2e63885..d173435 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 c078ee7..bd3c013 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 6b3802f..3f23927 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 1cee298..6c92722 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 5ae05aa..58d67a6 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 a8b653a..5d2ccf8 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 d839dbe..8f6c0c4 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 d275b3d..c9267f6 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 6137963..141b3e8 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 c1264c0..27b326f 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 @@
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 @@
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 @@
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 2574d7d..94f374d 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 e1866e7..2a2c12f 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 5ce9abd..0f2d85f 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