|
| 1 | +--- |
| 2 | +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs |
| 3 | +--- |
| 4 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 5 | + --> B043.py:18:1 |
| 6 | + | |
| 7 | +17 | # Invalid usage |
| 8 | +18 | delattr(foo, "bar") |
| 9 | + | ^^^^^^^^^^^^^^^^^^^ |
| 10 | +19 | delattr(foo, "_123abc") |
| 11 | +20 | delattr(foo, "__123abc__") |
| 12 | + | |
| 13 | +help: Replace `delattr` with `del` statement |
| 14 | +15 | pass |
| 15 | +16 | |
| 16 | +17 | # Invalid usage |
| 17 | + - delattr(foo, "bar") |
| 18 | +18 + del foo.bar |
| 19 | +19 | delattr(foo, "_123abc") |
| 20 | +20 | delattr(foo, "__123abc__") |
| 21 | +21 | delattr(foo, "abc123") |
| 22 | + |
| 23 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 24 | + --> B043.py:19:1 |
| 25 | + | |
| 26 | +17 | # Invalid usage |
| 27 | +18 | delattr(foo, "bar") |
| 28 | +19 | delattr(foo, "_123abc") |
| 29 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 30 | +20 | delattr(foo, "__123abc__") |
| 31 | +21 | delattr(foo, "abc123") |
| 32 | + | |
| 33 | +help: Replace `delattr` with `del` statement |
| 34 | +16 | |
| 35 | +17 | # Invalid usage |
| 36 | +18 | delattr(foo, "bar") |
| 37 | + - delattr(foo, "_123abc") |
| 38 | +19 + del foo._123abc |
| 39 | +20 | delattr(foo, "__123abc__") |
| 40 | +21 | delattr(foo, "abc123") |
| 41 | +22 | delattr(foo, r"abc123") |
| 42 | + |
| 43 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 44 | + --> B043.py:20:1 |
| 45 | + | |
| 46 | +18 | delattr(foo, "bar") |
| 47 | +19 | delattr(foo, "_123abc") |
| 48 | +20 | delattr(foo, "__123abc__") |
| 49 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 50 | +21 | delattr(foo, "abc123") |
| 51 | +22 | delattr(foo, r"abc123") |
| 52 | + | |
| 53 | +help: Replace `delattr` with `del` statement |
| 54 | +17 | # Invalid usage |
| 55 | +18 | delattr(foo, "bar") |
| 56 | +19 | delattr(foo, "_123abc") |
| 57 | + - delattr(foo, "__123abc__") |
| 58 | +20 + del foo.__123abc__ |
| 59 | +21 | delattr(foo, "abc123") |
| 60 | +22 | delattr(foo, r"abc123") |
| 61 | +23 | |
| 62 | + |
| 63 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 64 | + --> B043.py:21:1 |
| 65 | + | |
| 66 | +19 | delattr(foo, "_123abc") |
| 67 | +20 | delattr(foo, "__123abc__") |
| 68 | +21 | delattr(foo, "abc123") |
| 69 | + | ^^^^^^^^^^^^^^^^^^^^^^ |
| 70 | +22 | delattr(foo, r"abc123") |
| 71 | + | |
| 72 | +help: Replace `delattr` with `del` statement |
| 73 | +18 | delattr(foo, "bar") |
| 74 | +19 | delattr(foo, "_123abc") |
| 75 | +20 | delattr(foo, "__123abc__") |
| 76 | + - delattr(foo, "abc123") |
| 77 | +21 + del foo.abc123 |
| 78 | +22 | delattr(foo, r"abc123") |
| 79 | +23 | |
| 80 | +24 | # Starred argument |
| 81 | + |
| 82 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 83 | + --> B043.py:22:1 |
| 84 | + | |
| 85 | +20 | delattr(foo, "__123abc__") |
| 86 | +21 | delattr(foo, "abc123") |
| 87 | +22 | delattr(foo, r"abc123") |
| 88 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 89 | +23 | |
| 90 | +24 | # Starred argument |
| 91 | + | |
| 92 | +help: Replace `delattr` with `del` statement |
| 93 | +19 | delattr(foo, "_123abc") |
| 94 | +20 | delattr(foo, "__123abc__") |
| 95 | +21 | delattr(foo, "abc123") |
| 96 | + - delattr(foo, r"abc123") |
| 97 | +22 + del foo.abc123 |
| 98 | +23 | |
| 99 | +24 | # Starred argument |
| 100 | +25 | delattr(*foo, "bar") |
| 101 | + |
| 102 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 103 | + --> B043.py:28:1 |
| 104 | + | |
| 105 | +27 | # Non-NFKC attribute name (unsafe fix) |
| 106 | +28 | delattr(foo, "\u017f") |
| 107 | + | ^^^^^^^^^^^^^^^^^^^^^^ |
| 108 | +29 | |
| 109 | +30 | # Comment in expression (unsafe fix) |
| 110 | + | |
| 111 | +help: Replace `delattr` with `del` statement |
| 112 | +25 | delattr(*foo, "bar") |
| 113 | +26 | |
| 114 | +27 | # Non-NFKC attribute name (unsafe fix) |
| 115 | + - delattr(foo, "\u017f") |
| 116 | +28 + del foo.ſ |
| 117 | +29 | |
| 118 | +30 | # Comment in expression (unsafe fix) |
| 119 | +31 | delattr( |
| 120 | +note: This is an unsafe fix and may change runtime behavior |
| 121 | + |
| 122 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 123 | + --> B043.py:31:1 |
| 124 | + | |
| 125 | +30 | # Comment in expression (unsafe fix) |
| 126 | +31 | / delattr( |
| 127 | +32 | | obj, |
| 128 | +33 | | # text |
| 129 | +34 | | "foo", |
| 130 | +35 | | ) |
| 131 | + | |_^ |
| 132 | +36 | |
| 133 | +37 | import builtins |
| 134 | + | |
| 135 | +help: Replace `delattr` with `del` statement |
| 136 | +28 | delattr(foo, "\u017f") |
| 137 | +29 | |
| 138 | +30 | # Comment in expression (unsafe fix) |
| 139 | + - delattr( |
| 140 | + - obj, |
| 141 | + - # text |
| 142 | + - "foo", |
| 143 | + - ) |
| 144 | +31 + del obj.foo |
| 145 | +32 | |
| 146 | +33 | import builtins |
| 147 | +34 | builtins.delattr(foo, "bar") |
| 148 | +note: This is an unsafe fix and may change runtime behavior |
| 149 | + |
| 150 | +B043 [*] Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion. |
| 151 | + --> B043.py:38:1 |
| 152 | + | |
| 153 | +37 | import builtins |
| 154 | +38 | builtins.delattr(foo, "bar") |
| 155 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 156 | + | |
| 157 | +help: Replace `delattr` with `del` statement |
| 158 | +35 | ) |
| 159 | +36 | |
| 160 | +37 | import builtins |
| 161 | + - builtins.delattr(foo, "bar") |
| 162 | +38 + del foo.bar |
0 commit comments