Skip to content
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

[flake8-bandit] Add Rule S110 (try/except/pass) #2197

Merged
merged 5 commits into from
Jan 27, 2023

Conversation

sciyoshi
Copy link
Contributor

Check for flake8-bandit B110: blank pass in exception handler. Just getting my feet wet with implementing checkers in Ruff, so let me know if anything is missing. I used the add_rule.py script which has a slightly different convention than the other flake8-bandit checkers.

ref: #1646

@edgarrmondragon
Copy link
Contributor

I think there's some overlap between this rule and SIM105: Use contextlib.suppress({exception}) instead of try-except-pass.

@andersk
Copy link
Contributor

andersk commented Jan 26, 2023

SIM105 is intentionally restricted because contextlib.suppress is confusing in all but the simplest cases.

@sciyoshi
Copy link
Contributor Author

@andersk's link doesn't seem to resolve so I'm not sure what SIM105 being restricted means in this context, but the point about overlapping rules is a good one - I'm not sure what the best approach would be for that.

(Also - it's a small world, I remember Anders from my USAMO days!)

@andersk
Copy link
Contributor

andersk commented Jan 27, 2023

(Oops, fixed the link.)

@charliermarsh charliermarsh merged commit dd15c69 into astral-sh:main Jan 27, 2023
@charliermarsh
Copy link
Member

Thank you!

renovate bot referenced this pull request in ixm-one/pytest-cmake-presets Jan 28, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.236` ->
`^0.0.237` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.237/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.237/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.237/compatibility-slim/0.0.236)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.237/confidence-slim/0.0.236)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.237`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.237)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.236...v0.0.237)

#### What's Changed

##### Breaking Changes

`--explain`, `--clean`, and `--generate-shell-completion` are now
implemented as subcommands
([#&#8203;2190](https://togithub.com/charliermarsh/ruff/pull/2190)):

    ruff .         # Still works! And will always work.
    ruff check .   # New! Also works.

    ruff --explain E402   # Still works.
    ruff rule E402        # New! Also works. (And preferred.)

### Oops! The command has to come first.

    ruff --format json --explain E402   # No longer works.
    ruff --explain E402 --format json   # Still works!
    ruff rule E402   --format json      # Works! (And preferred.)

This change is largely backwards compatible -- most users should
experience no change in behavior. For exceptions, see
[`BREAKING_CHANGES.md`](https://togithub.com/charliermarsh/ruff/blob/main/BREAKING_CHANGES.md#--explain---clean-and---generate-shell-completion-are-now-subcommands-2190).

##### Rules

- feat: pylint `PLE0604` and `PLE0605` by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/charliermarsh/ruff/pull/2241](https://togithub.com/charliermarsh/ruff/pull/2241)
- feat: include os.getcwdb (bytes) into flake8-use-pathlib by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[https://github.com/charliermarsh/ruff/pull/2276](https://togithub.com/charliermarsh/ruff/pull/2276)
- \[`flake8-bandit`] Add Rule S110 (try/except/pass) by
[@&#8203;sciyoshi](https://togithub.com/sciyoshi) in
[https://github.com/charliermarsh/ruff/pull/2197](https://togithub.com/charliermarsh/ruff/pull/2197)

##### Settings

- Omit typing module from flake8-type-checking by default by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/2277](https://togithub.com/charliermarsh/ruff/pull/2277)

##### Bug Fixes

- Fix SIM300 to take Python constants into account by
[@&#8203;frenck](https://togithub.com/frenck) in
[https://github.com/charliermarsh/ruff/pull/2255](https://togithub.com/charliermarsh/ruff/pull/2255)
- Treat constant tuples as constants for yoda-conditions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/2265](https://togithub.com/charliermarsh/ruff/pull/2265)
- Treat attribute constants as constant for yoda-conditions by
[@&#8203;frenck](https://togithub.com/frenck) in
[https://github.com/charliermarsh/ruff/pull/2266](https://togithub.com/charliermarsh/ruff/pull/2266)
- flake8-annotations: Move has_any_typed_arg into correct nested `if` by
[@&#8203;akx](https://togithub.com/akx) in
[https://github.com/charliermarsh/ruff/pull/2269](https://togithub.com/charliermarsh/ruff/pull/2269)
- Expand heuristic for detecting logging calls by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/2279](https://togithub.com/charliermarsh/ruff/pull/2279)
- Preserve global binding kind during reassignments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/2297](https://togithub.com/charliermarsh/ruff/pull/2297)
- Fix typo in typing_extensions by
[@&#8203;Jonxslays](https://togithub.com/Jonxslays) in
[https://github.com/charliermarsh/ruff/pull/2298](https://togithub.com/charliermarsh/ruff/pull/2298)

#### New Contributors

- [@&#8203;frenck](https://togithub.com/frenck) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/2255](https://togithub.com/charliermarsh/ruff/pull/2255)
- [@&#8203;sladyn98](https://togithub.com/sladyn98) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/2141](https://togithub.com/charliermarsh/ruff/pull/2141)
- [@&#8203;the-matt-morris](https://togithub.com/the-matt-morris) made
their first contribution in
[https://github.com/charliermarsh/ruff/pull/2291](https://togithub.com/charliermarsh/ruff/pull/2291)
- [@&#8203;Jonxslays](https://togithub.com/Jonxslays) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/2298](https://togithub.com/charliermarsh/ruff/pull/2298)

**Full Changelog**:
astral-sh/ruff@v0.0.236...v0.0.237

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMTYuMSIsInVwZGF0ZWRJblZlciI6IjM0LjExNi4xIn0=-->

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@sciyoshi sciyoshi deleted the s110 branch November 22, 2023 20:21
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.

4 participants