Commit 9322fc3
authored
Add node_ancestors method (#1169)
I've been thinking about ways to get rid of unbounded `while` loops in
the Pylint codebase. A common use is to loop over a node's ancestors.
The `node_ancestors` method centralizes this logic in one place so
that those `while` loops can be rewritten as `for`.
A few uses are made of this new method. It only comes up a few places
in Astroid, but there are many more in Pylint.1 parent 8fbef58 commit 9322fc3
3 files changed
+13
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | 112 | | |
114 | | - | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
119 | 117 | | |
120 | | - | |
121 | 118 | | |
122 | | - | |
| 119 | + | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
| |||
162 | 159 | | |
163 | 160 | | |
164 | 161 | | |
165 | | - | |
166 | 162 | | |
167 | 163 | | |
168 | 164 | | |
| |||
4719 | 4715 | | |
4720 | 4716 | | |
4721 | 4717 | | |
4722 | | - | |
4723 | | - | |
| 4718 | + | |
4724 | 4719 | | |
4725 | 4720 | | |
4726 | | - | |
4727 | 4721 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
211 | 218 | | |
212 | 219 | | |
213 | 220 | | |
| |||
218 | 225 | | |
219 | 226 | | |
220 | 227 | | |
221 | | - | |
222 | | - | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | | - | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
0 commit comments