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

Make unnecessary-paren-on-raise-exception an unsafe edit #8231

Merged
merged 1 commit into from Oct 26, 2023

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Oct 25, 2023

Summary

This rule is now unsafe if we can't verify that the obj in raise obj() is a class or builtin. (If we verify that it's a function, we don't raise at all, as before.)

See the documentation change for motivation behind the unsafe edit.

Closes #8228.

@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label Oct 25, 2023
@charliermarsh
Copy link
Member Author

Ah, we can mark it as safe if we know it's a class or a builtin, I think.

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

PR Check Results

Ecosystem

ℹ️ ecosystem check detected changes. (+22, -22, 0 error(s))

airflow (+18, -18)

+ [*] 16237 fixable with the `--fix` option (6278 hidden fixes can be enabled with the `--unsafe-fixes` option).
- [*] 16254 fixable with the `--fix` option (6261 hidden fixes can be enabled with the `--unsafe-fixes` option).
+ airflow/api_connexion/security.py:92:27: RSE102 Unnecessary parentheses on raised exception
- airflow/api_connexion/security.py:92:27: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/auth/managers/fab/decorators/auth.py:59:35: RSE102 Unnecessary parentheses on raised exception
- airflow/auth/managers/fab/decorators/auth.py:59:35: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/exceptions.py:230:22: RSE102 Unnecessary parentheses on raised exception
- airflow/exceptions.py:230:22: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/models/dagcode.py:198:34: RSE102 Unnecessary parentheses on raised exception
- airflow/models/dagcode.py:198:34: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/models/taskinstance.py:424:41: RSE102 Unnecessary parentheses on raised exception
- airflow/models/taskinstance.py:424:41: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/models/taskinstance.py:907:38: RSE102 Unnecessary parentheses on raised exception
- airflow/models/taskinstance.py:907:38: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/operators/python.py:418:43: RSE102 Unnecessary parentheses on raised exception
- airflow/operators/python.py:418:43: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/providers/dbt/cloud/sensors/dbt.py:143:35: RSE102 Unnecessary parentheses on raised exception
- airflow/providers/dbt/cloud/sensors/dbt.py:143:35: RSE102 [*] Unnecessary parentheses on raised exception
+ airflow/timetables/_cron.py:69:38: RSE102 Unnecessary parentheses on raised exception
- airflow/timetables/_cron.py:69:38: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/dags/test_on_failure_callback.py:44:31: RSE102 Unnecessary parentheses on raised exception
- tests/dags/test_on_failure_callback.py:44:31: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/decorators/test_python.py:815:39: RSE102 Unnecessary parentheses on raised exception
- tests/decorators/test_python.py:815:39: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/decorators/test_python.py:854:39: RSE102 Unnecessary parentheses on raised exception
- tests/decorators/test_python.py:854:39: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/models/test_taskinstance.py:1019:39: RSE102 Unnecessary parentheses on raised exception
- tests/models/test_taskinstance.py:1019:39: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/models/test_taskinstance.py:533:35: RSE102 Unnecessary parentheses on raised exception
- tests/models/test_taskinstance.py:533:35: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/models/test_taskinstance.py:757:39: RSE102 Unnecessary parentheses on raised exception
- tests/models/test_taskinstance.py:757:39: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/models/test_taskinstance.py:854:39: RSE102 Unnecessary parentheses on raised exception
- tests/models/test_taskinstance.py:854:39: RSE102 [*] Unnecessary parentheses on raised exception
+ tests/models/test_taskinstance.py:953:39: RSE102 Unnecessary parentheses on raised exception
- tests/models/test_taskinstance.py:953:39: RSE102 [*] Unnecessary parentheses on raised exception

bokeh (+2, -2)

+ [*] 17799 fixable with the `--fix` option (4405 hidden fixes can be enabled with the `--unsafe-fixes` option).
- [*] 17800 fixable with the `--fix` option (4404 hidden fixes can be enabled with the `--unsafe-fixes` option).
+ tests/unit/bokeh/server/views/test_ws.py:46:39: RSE102 Unnecessary parentheses on raised exception
- tests/unit/bokeh/server/views/test_ws.py:46:39: RSE102 [*] Unnecessary parentheses on raised exception

content (+2, -2)

+ Packs/SplunkPyPreRelease/Integrations/SplunkPyPreRelease/SplunkPyPreRelease_test.py:1445:34: RSE102 Unnecessary parentheses on raised exception
- Packs/SplunkPyPreRelease/Integrations/SplunkPyPreRelease/SplunkPyPreRelease_test.py:1445:34: RSE102 [*] Unnecessary parentheses on raised exception
+ [*] 12923 fixable with the `--fix` option (5492 hidden fixes can be enabled with the `--unsafe-fixes` option).
- [*] 12924 fixable with the `--fix` option (5491 hidden fixes can be enabled with the `--unsafe-fixes` option).

Rules changed: 1
Rule Changes Additions Removals
RSE102 38 19 19

@charliermarsh charliermarsh added the bug Something isn't working label Oct 25, 2023
@charliermarsh
Copy link
Member Author

@zanieb - Gonna merge this, it's strictly safer (marking some cases as unsafe).

@charliermarsh charliermarsh merged commit be3307e into main Oct 26, 2023
17 checks passed
@charliermarsh charliermarsh deleted the charlie/rse branch October 26, 2023 15:33
/// Parentheses can only be omitted if the exception is a class, as opposed to
/// a function call. This rule isn't always capable of distinguishing between
/// the two. For example, if you define a method `get_exception` that itself
/// returns an exception object, this rule will falsy mark the parentheses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// returns an exception object, this rule will falsy mark the parentheses
/// returns an exception object, this rule will incorrectly mark the parentheses

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also a little confused as I thought function definitions were excluded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved in #8256, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid autofix for RSE102
2 participants