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

[pylint] Implement useless-exception-statement (W0133) #10176

Conversation

mikeleppane
Copy link
Contributor

@mikeleppane mikeleppane commented Feb 29, 2024

Summary

This review contains a new rule for handling useless exception statements (PLW0133). Is it based on the following pylint's rule: W0133

Note: this rule does not cover the case if an error is a custom exception class.

See: Rule request

Test Plan

cargo test & manually

Copy link
Contributor

github-actions bot commented Feb 29, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

DisnakeDev/disnake (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ disnake/state.py:456:13: PLW0133 Missing `raise` statement on exception
+ disnake/state.py:476:13: PLW0133 Missing `raise` statement on exception

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLW0133 2 2 0 0 0

Formatter (stable)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

openai/openai-cookbook (error)

warning: Detected debug build without --no-cache.
error: Failed to read examples/How_to_handle_rate_limits.ipynb: Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: trailing comma at line 47 column 4

Formatter (preview)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

openai/openai-cookbook (error)

ruff format --preview

warning: Detected debug build without --no-cache.
error: Failed to read examples/How_to_handle_rate_limits.ipynb: Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: trailing comma at line 47 column 4

@mikeleppane
Copy link
Contributor Author

mikeleppane commented Feb 29, 2024

@charliermarsh charliermarsh self-requested a review March 1, 2024 02:07
@charliermarsh charliermarsh self-assigned this Mar 1, 2024
@charliermarsh charliermarsh added rule Implementing or modifying a lint rule preview Related to preview mode features labels Mar 1, 2024
@charliermarsh charliermarsh changed the title rule(PLW0133): Implement useless exception statement [pylint] Implement useless-exception-statement (W0133) Mar 1, 2024
@charliermarsh
Copy link
Member

Reviewing now...

@charliermarsh charliermarsh merged commit 8e0a70c into astral-sh:main Mar 1, 2024
17 checks passed
nkxxll pushed a commit to nkxxll/ruff that referenced this pull request Mar 10, 2024
…sh#10176)

## Summary

This review contains a new rule for handling `useless exception
statements` (`PLW0133`). Is it based on the following pylint's rule:
[W0133](https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/pointless-exception-statement.html)


Note: this rule does not cover the case if an error is a custom
exception class.

See: [Rule request](astral-sh#10145)

## Test Plan

```bash
cargo test & manually
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants