Skip to content

Commit d1956ea

Browse files
authored
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!") ^ ```
1 parent 08a4a47 commit d1956ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pybind11/setup_helpers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ def cxx_std(self) -> int:
174174
@cxx_std.setter
175175
def cxx_std(self, level: int) -> None:
176176
if self._cxx_level:
177-
warnings.warn("You cannot safely change the cxx_level after setting it!")
177+
warnings.warn(
178+
"You cannot safely change the cxx_level after setting it!", stacklevel=1
179+
)
178180

179181
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so
180182
# force a valid flag here.

0 commit comments

Comments
 (0)