mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Mark typing.assert_never
as no return (#3121)
This function always raises, so RET503 shouldn't trigger for it.
This commit is contained in:
parent
48005d87f8
commit
bc3a9ce003
3 changed files with 72 additions and 56 deletions
|
@ -3,6 +3,8 @@ import os
|
||||||
import posix
|
import posix
|
||||||
from posix import abort
|
from posix import abort
|
||||||
import sys as std_sys
|
import sys as std_sys
|
||||||
|
import typing
|
||||||
|
import typing_extensions
|
||||||
import _thread
|
import _thread
|
||||||
import _winapi
|
import _winapi
|
||||||
|
|
||||||
|
@ -211,6 +213,18 @@ def noreturn_sys_exit():
|
||||||
std_sys.exit(0)
|
std_sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def noreturn_typing_assert_never():
|
||||||
|
if x > 0:
|
||||||
|
return 1
|
||||||
|
typing.assert_never(0)
|
||||||
|
|
||||||
|
|
||||||
|
def noreturn_typing_extensions_assert_never():
|
||||||
|
if x > 0:
|
||||||
|
return 1
|
||||||
|
typing_extensions.assert_never(0)
|
||||||
|
|
||||||
|
|
||||||
def noreturn__thread_exit():
|
def noreturn__thread_exit():
|
||||||
if x > 0:
|
if x > 0:
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -179,6 +179,8 @@ const NORETURN_FUNCS: &[&[&str]] = &[
|
||||||
&["posix", "_exit"],
|
&["posix", "_exit"],
|
||||||
&["posix", "abort"],
|
&["posix", "abort"],
|
||||||
&["sys", "exit"],
|
&["sys", "exit"],
|
||||||
|
&["typing", "assert_never"],
|
||||||
|
&["typing_extensions", "assert_never"],
|
||||||
&["_thread", "exit"],
|
&["_thread", "exit"],
|
||||||
&["_winapi", "ExitProcess"],
|
&["_winapi", "ExitProcess"],
|
||||||
// third-party modules
|
// third-party modules
|
||||||
|
|
|
@ -5,239 +5,239 @@ expression: diagnostics
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 18
|
row: 20
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 19
|
row: 21
|
||||||
column: 16
|
column: 16
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 19
|
row: 21
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 19
|
row: 21
|
||||||
column: 16
|
column: 16
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 25
|
row: 27
|
||||||
column: 8
|
column: 8
|
||||||
end_location:
|
end_location:
|
||||||
row: 25
|
row: 27
|
||||||
column: 15
|
column: 15
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 25
|
row: 27
|
||||||
column: 15
|
column: 15
|
||||||
end_location:
|
end_location:
|
||||||
row: 25
|
row: 27
|
||||||
column: 15
|
column: 15
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 34
|
row: 36
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 34
|
row: 36
|
||||||
column: 11
|
column: 11
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 34
|
row: 36
|
||||||
column: 11
|
column: 11
|
||||||
end_location:
|
end_location:
|
||||||
row: 34
|
row: 36
|
||||||
column: 11
|
column: 11
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 39
|
row: 41
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 41
|
row: 43
|
||||||
column: 20
|
column: 20
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 41
|
row: 43
|
||||||
column: 20
|
column: 20
|
||||||
end_location:
|
end_location:
|
||||||
row: 41
|
row: 43
|
||||||
column: 20
|
column: 20
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 8
|
column: 8
|
||||||
end_location:
|
end_location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 15
|
column: 15
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 15
|
column: 15
|
||||||
end_location:
|
end_location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 15
|
column: 15
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 57
|
row: 59
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 57
|
row: 59
|
||||||
column: 22
|
column: 22
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 57
|
row: 59
|
||||||
column: 22
|
column: 22
|
||||||
end_location:
|
end_location:
|
||||||
row: 57
|
row: 59
|
||||||
column: 22
|
column: 22
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 64
|
row: 66
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 64
|
row: 66
|
||||||
column: 21
|
column: 21
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 64
|
row: 66
|
||||||
column: 21
|
column: 21
|
||||||
end_location:
|
end_location:
|
||||||
row: 64
|
row: 66
|
||||||
column: 21
|
column: 21
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 80
|
row: 82
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 83
|
row: 85
|
||||||
column: 14
|
column: 14
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 83
|
row: 85
|
||||||
column: 14
|
column: 14
|
||||||
end_location:
|
end_location:
|
||||||
row: 83
|
row: 85
|
||||||
column: 14
|
column: 14
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 111
|
row: 113
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 114
|
row: 116
|
||||||
column: 16
|
column: 16
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 114
|
row: 116
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 114
|
row: 116
|
||||||
column: 16
|
column: 16
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 118
|
row: 120
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 124
|
row: 126
|
||||||
column: 19
|
column: 19
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 124
|
row: 126
|
||||||
column: 19
|
column: 19
|
||||||
end_location:
|
end_location:
|
||||||
row: 124
|
row: 126
|
||||||
column: 19
|
column: 19
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 128
|
row: 130
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 131
|
row: 133
|
||||||
column: 16
|
column: 16
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 131
|
row: 133
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 131
|
row: 133
|
||||||
column: 16
|
column: 16
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 135
|
row: 137
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 141
|
row: 143
|
||||||
column: 19
|
column: 19
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 141
|
row: 143
|
||||||
column: 19
|
column: 19
|
||||||
end_location:
|
end_location:
|
||||||
row: 141
|
row: 143
|
||||||
column: 19
|
column: 19
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 260
|
row: 274
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 261
|
row: 275
|
||||||
column: 20
|
column: 20
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 261
|
row: 275
|
||||||
column: 20
|
column: 20
|
||||||
end_location:
|
end_location:
|
||||||
row: 261
|
row: 275
|
||||||
column: 20
|
column: 20
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ImplicitReturn: ~
|
ImplicitReturn: ~
|
||||||
location:
|
location:
|
||||||
row: 277
|
row: 291
|
||||||
column: 12
|
column: 12
|
||||||
end_location:
|
end_location:
|
||||||
row: 277
|
row: 291
|
||||||
column: 19
|
column: 19
|
||||||
fix:
|
fix:
|
||||||
content: "\n return None"
|
content: "\n return None"
|
||||||
location:
|
location:
|
||||||
row: 277
|
row: 291
|
||||||
column: 19
|
column: 19
|
||||||
end_location:
|
end_location:
|
||||||
row: 277
|
row: 291
|
||||||
column: 19
|
column: 19
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue