mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +00:00

## Summary As a heuristic, we now ignore function calls that "look like" method calls (e.g., `future.exception()`). Closes https://github.com/astral-sh/ruff/issues/10205.
107 lines
1.1 KiB
Python
107 lines
1.1 KiB
Python
try:
|
|
y = 6 + "7"
|
|
except TypeError:
|
|
# RSE102
|
|
raise ValueError()
|
|
|
|
try:
|
|
x = 1 / 0
|
|
except ZeroDivisionError:
|
|
raise
|
|
|
|
# RSE102
|
|
raise TypeError()
|
|
|
|
# RSE102
|
|
raise TypeError ()
|
|
|
|
# RSE102
|
|
raise TypeError \
|
|
()
|
|
|
|
# RSE102
|
|
raise TypeError \
|
|
();
|
|
|
|
# RSE102
|
|
raise TypeError(
|
|
|
|
)
|
|
|
|
# RSE102
|
|
raise (TypeError) (
|
|
|
|
)
|
|
|
|
# RSE102
|
|
raise TypeError(
|
|
# Hello, world!
|
|
)
|
|
|
|
# OK
|
|
raise AssertionError
|
|
|
|
# OK
|
|
raise AttributeError("test message")
|
|
|
|
|
|
def return_error():
|
|
return ValueError("Something")
|
|
|
|
|
|
# OK
|
|
raise return_error()
|
|
|
|
|
|
class Class:
|
|
@staticmethod
|
|
def error():
|
|
return ValueError("Something")
|
|
|
|
|
|
# OK
|
|
raise Class.error()
|
|
|
|
|
|
import ctypes
|
|
|
|
|
|
# OK
|
|
raise ctypes.WinError(1)
|
|
|
|
|
|
# RSE102
|
|
raise IndexError()from ZeroDivisionError
|
|
|
|
raise IndexError()\
|
|
from ZeroDivisionError
|
|
|
|
raise IndexError() from ZeroDivisionError
|
|
|
|
raise IndexError();
|
|
|
|
# RSE102
|
|
raise Foo()
|
|
|
|
# OK
|
|
raise ctypes.WinError()
|
|
|
|
|
|
def func():
|
|
pass
|
|
|
|
|
|
# OK
|
|
raise func()
|
|
|
|
|
|
# OK
|
|
future = executor.submit(float, "a")
|
|
if future.exception():
|
|
raise future.exception()
|
|
|
|
|
|
# RSE102
|
|
future = executor.submit(float, "a")
|
|
if future.exception():
|
|
raise future.Exception()
|