From d1956eabb50d93428097a8a564cef4fc8b0ded82 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 17 Feb 2023 12:31:08 -0800 Subject: [PATCH 1/3] Appease new flake8 B028 error: (#4513) ``` flake8...................................................................Failed - hook id: flake8 - exit code: 1 pybind11/setup_helpers.py:177:13: B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user. warnings.warn("You cannot safely change the cxx_level after setting it!") ^ ``` --- pybind11/setup_helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 1db479532..4c14498f6 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -174,7 +174,9 @@ class Pybind11Extension(_Extension): # type: ignore[misc] @cxx_std.setter def cxx_std(self, level: int) -> None: if self._cxx_level: - warnings.warn("You cannot safely change the cxx_level after setting it!") + warnings.warn( + "You cannot safely change the cxx_level after setting it!", stacklevel=1 + ) # MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so # force a valid flag here. From 6a5e6007cdfa9441fc05a589d7b819c6c37eb489 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 17 Feb 2023 12:58:35 -0800 Subject: [PATCH 2/3] Make warning suppressions MINGW-specific again. (#4515) Background: https://github.com/pybind/pybind11/pull/4285#issuecomment-1435066554 --- include/pybind11/eigen/matrix.h | 2 ++ include/pybind11/eigen/tensor.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/pybind11/eigen/matrix.h b/include/pybind11/eigen/matrix.h index 34fe329a8..bd533bed3 100644 --- a/include/pybind11/eigen/matrix.h +++ b/include/pybind11/eigen/matrix.h @@ -19,7 +19,9 @@ PYBIND11_WARNING_PUSH PYBIND11_WARNING_DISABLE_MSVC(5054) // https://github.com/pybind/pybind11/pull/3741 // C5054: operator '&': deprecated between enumerations of different types +#if defined(__MINGW32__) PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") +#endif #include #include diff --git a/include/pybind11/eigen/tensor.h b/include/pybind11/eigen/tensor.h index 0877da895..de7dcba89 100644 --- a/include/pybind11/eigen/tensor.h +++ b/include/pybind11/eigen/tensor.h @@ -17,7 +17,9 @@ static_assert(__GNUC__ > 5, "Eigen Tensor support in pybind11 requires GCC > 5.0 PYBIND11_WARNING_PUSH PYBIND11_WARNING_DISABLE_MSVC(4554) PYBIND11_WARNING_DISABLE_MSVC(4127) +#if defined(__MINGW32__) PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") +#endif #include From 68211d41c1ef94fa65ef27ea2a6cdd8677996635 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Feb 2023 14:13:29 -0800 Subject: [PATCH 3/3] fix: nicer stack level for warning (#4516) Signed-off-by: Henry Schreiner --- pybind11/setup_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 4c14498f6..b9b433b65 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -175,7 +175,7 @@ class Pybind11Extension(_Extension): # type: ignore[misc] def cxx_std(self, level: int) -> None: if self._cxx_level: warnings.warn( - "You cannot safely change the cxx_level after setting it!", stacklevel=1 + "You cannot safely change the cxx_level after setting it!", stacklevel=2 ) # MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so