@neralabs/rerail-pack-python 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +36 -0
  4. package/licenses/bandit/LICENSE +175 -0
  5. package/licenses/bandit/UPSTREAM.md +100 -0
  6. package/licenses/ruff/LICENSE +430 -0
  7. package/licenses/ruff/UPSTREAM.md +338 -0
  8. package/pack.json +912 -0
  9. package/package.json +30 -0
  10. package/rules/bandit-b101-assert-used.json +38 -0
  11. package/rules/bandit-b102-exec-used.json +125 -0
  12. package/rules/bandit-b110-try-except-pass.json +109 -0
  13. package/rules/bandit-b112-try-except-continue.json +109 -0
  14. package/rules/bandit-b113-request-without-timeout.json +138 -0
  15. package/rules/bandit-b301-pickle.json +58 -0
  16. package/rules/bandit-b302-marshal.json +48 -0
  17. package/rules/bandit-b303-md5.json +79 -0
  18. package/rules/bandit-b305-cipher-modes.json +47 -0
  19. package/rules/bandit-b306-mktemp-q.json +54 -0
  20. package/rules/bandit-b307-eval.json +125 -0
  21. package/rules/bandit-b308-mark-safe.json +47 -0
  22. package/rules/bandit-b310-urllib-urlopen.json +54 -0
  23. package/rules/bandit-b311-random.json +57 -0
  24. package/rules/bandit-b312-telnetlib.json +47 -0
  25. package/rules/bandit-b313-xml-bad-celementtree.json +50 -0
  26. package/rules/bandit-b314-xml-bad-elementtree.json +50 -0
  27. package/rules/bandit-b315-xml-bad-expatreader.json +47 -0
  28. package/rules/bandit-b316-xml-bad-expatbuilder.json +48 -0
  29. package/rules/bandit-b317-xml-bad-sax.json +58 -0
  30. package/rules/bandit-b318-xml-bad-minidom.json +48 -0
  31. package/rules/bandit-b319-xml-bad-pulldom.json +48 -0
  32. package/rules/bandit-b321-ftplib.json +47 -0
  33. package/rules/bandit-b323-unverified-context.json +47 -0
  34. package/rules/bandit-b401-import-telnetlib.json +48 -0
  35. package/rules/bandit-b402-import-ftplib.json +48 -0
  36. package/rules/bandit-b405-import-xml-etree.json +69 -0
  37. package/rules/bandit-b406-import-xml-sax.json +73 -0
  38. package/rules/bandit-b407-import-xml-expat.json +54 -0
  39. package/rules/bandit-b408-import-xml-minidom.json +54 -0
  40. package/rules/bandit-b409-import-xml-pulldom.json +54 -0
  41. package/rules/bandit-b411-import-xmlrpclib.json +48 -0
  42. package/rules/bandit-b413-import-pycrypto.json +159 -0
  43. package/rules/bandit-b415-import-pyghmi.json +48 -0
  44. package/rules/bandit-b502-ssl-with-bad-version.json +90 -0
  45. package/rules/bandit-b505-weak-cryptographic-key.json +166 -0
  46. package/rules/bandit-b507-ssh-no-host-key-verification.json +210 -0
  47. package/rules/bandit-b606-start-process-with-no-shell.json +63 -0
  48. package/rules/bandit-b610-django-extra-used.json +268 -0
  49. package/rules/bandit-b615-huggingface-unsafe-download.json +1152 -0
  50. package/rules/ruff-async100-cancel-scope-no-checkpoint.json +357 -0
  51. package/rules/ruff-async105-trio-sync-call.json +199 -0
  52. package/rules/ruff-async115-async-zero-sleep.json +264 -0
  53. package/rules/ruff-async116-long-sleep-not-forever.json +267 -0
  54. package/rules/ruff-async210-blocking-http-call-in-async-function.json +161 -0
  55. package/rules/ruff-async221-run-process-in-async-function.json +342 -0
  56. package/rules/ruff-async222-wait-for-process-in-async-function.json +144 -0
  57. package/rules/ruff-async230-blocking-open-call-in-async-function.json +339 -0
  58. package/rules/ruff-async250-blocking-input-in-async-function.json +143 -0
  59. package/rules/ruff-async251-blocking-sleep-in-async-function.json +140 -0
  60. package/rules/ruff-b002-unary-prefix-increment-decrement.json +54 -0
  61. package/rules/ruff-b003-assignment-to-os-environ.json +54 -0
  62. package/rules/ruff-b004-unreliable-callable-check.json +171 -0
  63. package/rules/ruff-b005-strip-with-multi-characters.json +131 -0
  64. package/rules/ruff-b007-unused-loop-control-variable.json +368 -0
  65. package/rules/ruff-b009-get-attr-with-constant.json +190 -0
  66. package/rules/ruff-b010-set-attr-with-constant.json +219 -0
  67. package/rules/ruff-b011-assert-false.json +62 -0
  68. package/rules/ruff-b013-redundant-tuple-in-exception-handler.json +94 -0
  69. package/rules/ruff-b014-duplicate-handler-exception.json +126 -0
  70. package/rules/ruff-b016-raise-literal.json +47 -0
  71. package/rules/ruff-b020-loop-variable-overrides-iterator.json +341 -0
  72. package/rules/ruff-b021-f-string-docstring.json +48 -0
  73. package/rules/ruff-b022-useless-contextlib-suppress.json +95 -0
  74. package/rules/ruff-b023-function-uses-loop-variable.json +560 -0
  75. package/rules/ruff-b025-duplicate-try-block-exception.json +182 -0
  76. package/rules/ruff-b026-star-arg-unpacking-after-keyword-arg.json +57 -0
  77. package/rules/ruff-b028-no-explicit-stacklevel.json +177 -0
  78. package/rules/ruff-b029-except-with-empty-tuple.json +102 -0
  79. package/rules/ruff-b032-unintentional-type-annotation.json +157 -0
  80. package/rules/ruff-b033-duplicate-value.json +129 -0
  81. package/rules/ruff-b034-re-sub-positional-args.json +159 -0
  82. package/rules/ruff-b039-mutable-contextvar-default.json +281 -0
  83. package/rules/ruff-b904-raise-without-from-inside-except.json +194 -0
  84. package/rules/ruff-b905-zip-without-explicit-strict.json +429 -0
  85. package/rules/ruff-e711-none-comparison.json +199 -0
  86. package/rules/ruff-e721-type-comparison.json +293 -0
  87. package/rules/ruff-e722-bare-except.json +57 -0
  88. package/rules/ruff-e742-ambiguous-class-name.json +47 -0
  89. package/rules/ruff-e743-ambiguous-function-name.json +47 -0
  90. package/rules/ruff-f403-undefined-local-with-import-star.json +73 -0
  91. package/rules/ruff-f405-undefined-local-with-import-star-usage.json +87 -0
  92. package/rules/ruff-f406-undefined-local-with-nested-import-star-usage.json +39 -0
  93. package/rules/ruff-f407-future-feature-not-defined.json +56 -0
  94. package/rules/ruff-f501-percent-format-invalid-format.json +88 -0
  95. package/rules/ruff-f502-percent-format-expected-mapping.json +127 -0
  96. package/rules/ruff-f503-percent-format-expected-sequence.json +127 -0
  97. package/rules/ruff-f504-percent-format-extra-named-arguments.json +46 -0
  98. package/rules/ruff-f505-percent-format-missing-argument.json +49 -0
  99. package/rules/ruff-f506-percent-format-mixed-positional-and-named.json +114 -0
  100. package/rules/ruff-f507-percent-format-positional-count-mismatch.json +78 -0
  101. package/rules/ruff-f508-percent-format-star-requires-sequence.json +112 -0
  102. package/rules/ruff-f509-percent-format-unsupported-format-character.json +86 -0
  103. package/rules/ruff-f521-string-dot-format-invalid-format.json +83 -0
  104. package/rules/ruff-f522-string-dot-format-extra-named-arguments.json +46 -0
  105. package/rules/ruff-f523-string-dot-format-extra-positional-arguments.json +48 -0
  106. package/rules/ruff-f524-string-dot-format-missing-arguments.json +46 -0
  107. package/rules/ruff-f525-string-dot-format-mixing-automatic.json +99 -0
  108. package/rules/ruff-f541-f-string-missing-placeholders.json +52 -0
  109. package/rules/ruff-f601-multi-value-repeated-key-literal.json +215 -0
  110. package/rules/ruff-f602-multi-value-repeated-key-variable.json +123 -0
  111. package/rules/ruff-f622-multiple-starred-expressions.json +57 -0
  112. package/rules/ruff-f632-is-literal.json +232 -0
  113. package/rules/ruff-f633-invalid-print-syntax.json +299 -0
  114. package/rules/ruff-f701-break-outside-loop.json +64 -0
  115. package/rules/ruff-f702-continue-outside-loop.json +64 -0
  116. package/rules/ruff-f706-return-outside-function.json +61 -0
  117. package/rules/ruff-f707-default-except-not-last.json +50 -0
  118. package/rules/ruff-f722-forward-annotation-syntax-error.json +654 -0
  119. package/rules/ruff-f822-undefined-export.json +55 -0
  120. package/rules/ruff-f823-undefined-local.json +42 -0
  121. package/rules/ruff-f842-unused-annotation.json +51 -0
  122. package/rules/ruff-f901-raise-not-implemented.json +97 -0
  123. package/rules/ruff-pie794-duplicate-class-field-definition.json +157 -0
  124. package/rules/ruff-pie796-non-unique-enums.json +460 -0
  125. package/rules/ruff-pie800-unnecessary-spread.json +62 -0
  126. package/rules/ruff-pie804-unnecessary-dict-kwargs.json +179 -0
  127. package/rules/ruff-pie807-reimplemented-container-builtin.json +100 -0
  128. package/rules/ruff-pie810-multiple-starts-ends-with.json +585 -0
  129. package/rules/ruff-ret501-unnecessary-return-none.json +256 -0
  130. package/rules/ruff-ret502-implicit-return-value.json +163 -0
  131. package/rules/ruff-ret505-superfluous-else-return.json +211 -0
  132. package/rules/ruff-ret506-superfluous-else-raise.json +211 -0
  133. package/rules/ruff-ret507-superfluous-else-continue.json +211 -0
  134. package/rules/ruff-ret508-superfluous-else-break.json +211 -0
  135. package/rules/ruff-sim101-duplicate-isinstance-call.json +384 -0
  136. package/rules/ruff-sim107-return-in-try-except-finally.json +82 -0
  137. package/rules/ruff-sim109-compare-with-tuple.json +205 -0
  138. package/rules/ruff-sim112-uncapitalized-environment-variables.json +168 -0
  139. package/rules/ruff-sim113-enumerate-for-loop.json +562 -0
  140. package/rules/ruff-sim208-double-negation.json +58 -0
  141. package/rules/ruff-sim210-if-expr-with-true-false.json +90 -0
  142. package/rules/ruff-sim211-if-expr-with-false-true.json +90 -0
  143. package/rules/ruff-sim212-if-expr-with-twisted-arms.json +95 -0
  144. package/rules/ruff-sim300-yoda-conditions.json +487 -0
  145. package/rules/ruff-sim905-split-static-string.json +579 -0
  146. package/rules/ruff-sim910-dict-get-with-none-default.json +518 -0
  147. package/rules/ruff-t100-debugger.json +197 -0
@@ -0,0 +1,219 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-b010-set-attr-with-constant",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's B010 (set-attr-with-constant): `setattr(obj, \"name\", value)` used as an expression statement, with exactly three positional arguments and no keyword arguments, `obj` not starred, the name a str literal (not bytes, an f- or t-string; escapes decoded, implicit concatenations joined) whose value is a Python identifier (Unicode XID, not a keyword), not `__debug__` and not a mangled private name. The callee (parentheses transparent) resolves to the builtin `setattr` (Ruff's `match_builtin_expr`): the unshadowed name, or `setattr` of the `builtins` module through the file's imports. Reported on the call.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "set-attr-with-constant",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "python",
19
+ "utils": {
20
+ "ref-setattr": {
21
+ "any": [
22
+ {
23
+ "kind": "identifier"
24
+ },
25
+ {
26
+ "kind": "attribute"
27
+ }
28
+ ],
29
+ "resolves": {
30
+ "global": [
31
+ "setattr"
32
+ ],
33
+ "import": [
34
+ "builtins.setattr"
35
+ ]
36
+ }
37
+ },
38
+ "callee": {
39
+ "any": [
40
+ {
41
+ "matches": "ref-setattr"
42
+ },
43
+ {
44
+ "kind": "parenthesized_expression",
45
+ "has": {
46
+ "stopBy": "neighbor",
47
+ "matches": "callee"
48
+ }
49
+ }
50
+ ]
51
+ },
52
+ "identifier-literal": {
53
+ "any": [
54
+ {
55
+ "any": [
56
+ {
57
+ "kind": "string",
58
+ "regex": "^[rRuU]{0,2}['\"]"
59
+ },
60
+ {
61
+ "kind": "concatenated_string",
62
+ "not": {
63
+ "has": {
64
+ "stopBy": "neighbor",
65
+ "kind": "string",
66
+ "not": {
67
+ "regex": "^[rRuU]{0,2}['\"]"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ],
73
+ "value": {
74
+ "regex": "^[\\p{XID_Start}_]\\p{XID_Continue}*$"
75
+ },
76
+ "not": {
77
+ "any": [
78
+ {
79
+ "value": {
80
+ "regex": "^(False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)$"
81
+ }
82
+ },
83
+ {
84
+ "all": [
85
+ {
86
+ "value": {
87
+ "regex": "^__"
88
+ }
89
+ },
90
+ {
91
+ "not": {
92
+ "value": {
93
+ "regex": "__$"
94
+ }
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "value": {
101
+ "eq": "__debug__"
102
+ }
103
+ }
104
+ ]
105
+ }
106
+ },
107
+ {
108
+ "kind": "parenthesized_expression",
109
+ "has": {
110
+ "stopBy": "neighbor",
111
+ "matches": "identifier-literal"
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ "positional": {
117
+ "not": {
118
+ "any": [
119
+ {
120
+ "kind": "keyword_argument"
121
+ },
122
+ {
123
+ "kind": "dictionary_splat"
124
+ },
125
+ {
126
+ "kind": "list_splat"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ "argument": {
132
+ "not": {
133
+ "any": [
134
+ {
135
+ "kind": "keyword_argument"
136
+ },
137
+ {
138
+ "kind": "dictionary_splat"
139
+ }
140
+ ]
141
+ }
142
+ },
143
+ "no-keywords": {
144
+ "kind": "argument_list",
145
+ "not": {
146
+ "has": {
147
+ "stopBy": "neighbor",
148
+ "any": [
149
+ {
150
+ "kind": "keyword_argument"
151
+ },
152
+ {
153
+ "kind": "dictionary_splat"
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ },
159
+ "statement-expression": {
160
+ "inside": {
161
+ "stopBy": "neighbor",
162
+ "any": [
163
+ {
164
+ "kind": "expression_statement",
165
+ "not": {
166
+ "has": {
167
+ "stopBy": "neighbor",
168
+ "regex": "^,$"
169
+ }
170
+ }
171
+ },
172
+ {
173
+ "kind": "parenthesized_expression",
174
+ "matches": "statement-expression"
175
+ }
176
+ ]
177
+ }
178
+ }
179
+ },
180
+ "rule": {
181
+ "kind": "call",
182
+ "pattern": "$FUNC($OBJ, $NAME, $VALUE)",
183
+ "matches": "statement-expression",
184
+ "has": {
185
+ "stopBy": "neighbor",
186
+ "matches": "no-keywords"
187
+ }
188
+ },
189
+ "constraints": {
190
+ "FUNC": {
191
+ "matches": "callee"
192
+ },
193
+ "OBJ": {
194
+ "matches": "positional"
195
+ },
196
+ "NAME": {
197
+ "matches": "identifier-literal"
198
+ },
199
+ "VALUE": {
200
+ "matches": "argument"
201
+ }
202
+ }
203
+ }
204
+ },
205
+ "violation": {
206
+ "anchor": "witness.span",
207
+ "code": "B010",
208
+ "message": "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.",
209
+ "suppress": {
210
+ "noqa": {
211
+ "codes": [
212
+ "B010"
213
+ ]
214
+ }
215
+ }
216
+ }
217
+ }
218
+ ]
219
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-b011-assert-false",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's B011 (assert-false): an `assert` statement whose test is the literal `False` (Ruff's `is_const_false`; parentheses transparent), reported on the literal. Ported from the Ruff conformance suite (rerail/conformance/ruff/rules/B011.json at 3f102adcb), with Ruff's `# noqa` honoured as the Ruff CLI honours it.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "assert-false",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "python",
19
+ "utils": {
20
+ "assert-test": {
21
+ "any": [
22
+ {
23
+ "follows": {
24
+ "stopBy": "neighbor",
25
+ "regex": "^assert$"
26
+ },
27
+ "inside": {
28
+ "stopBy": "neighbor",
29
+ "kind": "assert_statement"
30
+ }
31
+ },
32
+ {
33
+ "inside": {
34
+ "stopBy": "neighbor",
35
+ "kind": "parenthesized_expression",
36
+ "matches": "assert-test"
37
+ }
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ "rule": {
43
+ "kind": "false",
44
+ "matches": "assert-test"
45
+ }
46
+ }
47
+ },
48
+ "violation": {
49
+ "anchor": "witness.span",
50
+ "code": "B011",
51
+ "message": "Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`",
52
+ "suppress": {
53
+ "noqa": {
54
+ "codes": [
55
+ "B011"
56
+ ]
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ]
62
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-b013-redundant-tuple-in-exception-handler",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's B013 (redundant-tuple-in-exception-handler): the type of an `except` (or `except*`) handler is a parenthesized tuple with exactly one element that is not starred. Parentheses around the tuple are transparent, and an `as` name does not matter. Reported on the tuple.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "redundant-tuple-in-exception-handler",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "python",
19
+ "utils": {
20
+ "handler-type": {
21
+ "inside": {
22
+ "stopBy": "neighbor",
23
+ "any": [
24
+ {
25
+ "kind": "except_clause"
26
+ },
27
+ {
28
+ "kind": "as_pattern",
29
+ "inside": {
30
+ "stopBy": "neighbor",
31
+ "kind": "except_clause"
32
+ }
33
+ },
34
+ {
35
+ "kind": "parenthesized_expression",
36
+ "matches": "handler-type"
37
+ }
38
+ ]
39
+ }
40
+ },
41
+ "element": {
42
+ "not": {
43
+ "any": [
44
+ {
45
+ "kind": "comment"
46
+ },
47
+ {
48
+ "regex": "^[(),]$"
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ },
54
+ "rule": {
55
+ "kind": "tuple",
56
+ "matches": "handler-type",
57
+ "all": [
58
+ {
59
+ "count": {
60
+ "has": {
61
+ "stopBy": "neighbor",
62
+ "matches": "element"
63
+ },
64
+ "min": 1,
65
+ "max": 1
66
+ }
67
+ },
68
+ {
69
+ "not": {
70
+ "has": {
71
+ "stopBy": "neighbor",
72
+ "kind": "list_splat"
73
+ }
74
+ }
75
+ }
76
+ ]
77
+ }
78
+ }
79
+ },
80
+ "violation": {
81
+ "anchor": "witness.span",
82
+ "code": "B013",
83
+ "message": "A length-one tuple literal is redundant in exception handlers",
84
+ "suppress": {
85
+ "noqa": {
86
+ "codes": [
87
+ "B013"
88
+ ]
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ]
94
+ }
@@ -0,0 +1,126 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-b014-duplicate-handler-exception",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's B014 (duplicate-handler-exception): the type of an `except` (or `except*`) handler is a tuple in which the same dotted name (a name or an attribute chain of names, Ruff's `UnqualifiedName`) occurs more than once (parentheses around an element are transparent). Reported once on the tuple, whatever the number of duplicates.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "duplicate-handler-exception",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "python",
19
+ "utils": {
20
+ "handler-type": {
21
+ "inside": {
22
+ "stopBy": "neighbor",
23
+ "any": [
24
+ {
25
+ "kind": "except_clause"
26
+ },
27
+ {
28
+ "kind": "as_pattern",
29
+ "inside": {
30
+ "stopBy": "neighbor",
31
+ "kind": "except_clause"
32
+ }
33
+ },
34
+ {
35
+ "kind": "parenthesized_expression",
36
+ "matches": "handler-type"
37
+ }
38
+ ]
39
+ }
40
+ },
41
+ "dotted-name": {
42
+ "any": [
43
+ {
44
+ "kind": "identifier"
45
+ },
46
+ {
47
+ "kind": "attribute",
48
+ "has": {
49
+ "stopBy": "neighbor",
50
+ "kind": "identifier",
51
+ "precedes": {
52
+ "stopBy": "neighbor",
53
+ "regex": "^\\.$"
54
+ },
55
+ "matches": "dotted-name"
56
+ }
57
+ },
58
+ {
59
+ "kind": "attribute",
60
+ "has": {
61
+ "stopBy": "neighbor",
62
+ "kind": "attribute",
63
+ "matches": "dotted-name"
64
+ }
65
+ }
66
+ ]
67
+ },
68
+ "element": {
69
+ "any": [
70
+ {
71
+ "matches": "dotted-name",
72
+ "pattern": "$NAME"
73
+ },
74
+ {
75
+ "kind": "parenthesized_expression",
76
+ "has": {
77
+ "stopBy": "neighbor",
78
+ "matches": "element"
79
+ }
80
+ }
81
+ ]
82
+ },
83
+ "same-element": {
84
+ "any": [
85
+ {
86
+ "pattern": "$NAME"
87
+ },
88
+ {
89
+ "kind": "parenthesized_expression",
90
+ "has": {
91
+ "stopBy": "neighbor",
92
+ "matches": "same-element"
93
+ }
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ "rule": {
99
+ "kind": "tuple",
100
+ "matches": "handler-type",
101
+ "has": {
102
+ "stopBy": "neighbor",
103
+ "matches": "element",
104
+ "precedes": {
105
+ "stopBy": "end",
106
+ "matches": "same-element"
107
+ }
108
+ }
109
+ }
110
+ }
111
+ },
112
+ "violation": {
113
+ "anchor": "witness.span",
114
+ "code": "B014",
115
+ "message": "Exception handler with duplicate exception: `$NAME`",
116
+ "suppress": {
117
+ "noqa": {
118
+ "codes": [
119
+ "B014"
120
+ ]
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ]
126
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-b016-raise-literal",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's B016 (raise-literal): the exception of a `raise` statement is a literal (Ruff's `is_literal_expr`: string, bytes, number, `True`/`False`, `None`, `...`; not an f-string or t-string, including an implicit concatenation with one; parentheses transparent). Reported on the literal.",
7
+ "scope": { "include": ["**/*"], "exclude": [] },
8
+ "clauses": [
9
+ {
10
+ "id": "raise-literal",
11
+ "forbid": {
12
+ "ast": {
13
+ "language": "python",
14
+ "utils": {
15
+ "plain-string": {
16
+ "kind": "string",
17
+ "not": { "has": { "stopBy": "neighbor", "kind": "string_start", "regex": "[fFtT]" } }
18
+ },
19
+ "raised": {
20
+ "any": [
21
+ {
22
+ "follows": { "stopBy": "neighbor", "regex": "^raise$" },
23
+ "inside": { "stopBy": "neighbor", "kind": "raise_statement" }
24
+ },
25
+ { "inside": { "stopBy": "neighbor", "kind": "parenthesized_expression", "matches": "raised" } }
26
+ ]
27
+ }
28
+ },
29
+ "rule": {
30
+ "matches": "raised",
31
+ "any": [
32
+ { "matches": "plain-string" },
33
+ { "kind": "concatenated_string", "not": { "has": { "stopBy": "neighbor", "kind": "string", "not": { "matches": "plain-string" } } } },
34
+ { "kind": "integer" },
35
+ { "kind": "float" },
36
+ { "kind": "true" },
37
+ { "kind": "false" },
38
+ { "kind": "none" },
39
+ { "kind": "ellipsis" }
40
+ ]
41
+ }
42
+ }
43
+ },
44
+ "violation": { "anchor": "witness.span", "code": "B016", "message": "Cannot raise a literal. Did you intend to return it or raise an Exception?", "suppress": { "noqa": { "codes": ["B016"] } } }
45
+ }
46
+ ]
47
+ }