Skip to content

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

Merged
charliermarsh merged 5 commits into
astral-sh:mainfrom
mikeleppane:rule(pylint)/useless_exception_statement_PLW0133
Mar 1, 2024
Merged

[pylint] Implement useless-exception-statement (W0133)#10176
charliermarsh merged 5 commits into
astral-sh:mainfrom
mikeleppane:rule(pylint)/useless_exception_statement_PLW0133

Conversation

@mikeleppane
Copy link
Copy Markdown
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

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Reviewing now...

@charliermarsh charliermarsh merged commit 8e0a70c into astral-sh:main Mar 1, 2024
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