Skip to content

Commit

Permalink
Appease new flake8 B028 error: (#4513)
Browse files Browse the repository at this point in the history
```
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!")
            ^
```
  • Loading branch information
Ralf W. Grosse-Kunstleve authored Feb 17, 2023
1 parent 08a4a47 commit d1956ea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pybind11/setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def cxx_std(self) -> int:
@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.
Expand Down

0 comments on commit d1956ea

Please sign in to comment.