Skip to content

Appease new flake8 B028 error #4513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2023
Merged

Appease new flake8 B028 error #4513

merged 1 commit into from
Feb 17, 2023

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Feb 17, 2023

Description

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!")
            ^

Suggested changelog entry:

```
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!")
            ^
```
@rwgk rwgk marked this pull request as ready for review February 17, 2023 07:40
@rwgk rwgk requested a review from henryiii as a code owner February 17, 2023 07:40
@rwgk
Copy link
Collaborator Author

rwgk commented Feb 17, 2023

@henryiii What do you think about this simple tweak to make flake8 happy?

@rwgk
Copy link
Collaborator Author

rwgk commented Feb 17, 2023

Thanks Aaron!

@rwgk rwgk merged commit d1956ea into pybind:master Feb 17, 2023
@rwgk rwgk deleted the flake8_B028 branch February 17, 2023 20:31
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Feb 17, 2023
@rwgk rwgk removed the needs changelog Possibly needs a changelog entry label Feb 17, 2023
@henryiii
Copy link
Collaborator

I think we need to move to Ruff, so these updates won't happen behind the scenes. :) Yes, I think this is fine. Though this is almost always =2, and I think that's true there - the problem is in the user using the cxx_std setter (=2), not inside the setter itself (=1). But this does just formalize the current (wrong) behavior, which is why the check exists.

@rwgk
Copy link
Collaborator Author

rwgk commented Feb 17, 2023

I think we need to move to Ruff,

What I saw looked exciting to me, but I see there are a lot of GHA failures. Do we need to pull together to migrate to Ruff? (The sooner the better.)

the problem is in the user using the cxx_std setter (=2)

Thanks! I'll send another PR to change the value to 2.

henryiii pushed a commit that referenced this pull request Feb 24, 2023
```
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!")
            ^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants