|
1 | 1 | # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
2 | 2 | # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE |
3 | | -from typing import Union, cast |
| 3 | +from typing import Union |
4 | 4 |
|
5 | 5 | import astroid |
6 | 6 | from astroid import nodes |
@@ -128,17 +128,14 @@ def _check_use_maxsplit_arg(self, node: nodes.Call) -> None: |
128 | 128 | # Check if loop present within the scope of the node |
129 | 129 | scope = node.scope() |
130 | 130 | for loop_node in scope.nodes_of_class((nodes.For, nodes.While)): |
131 | | - loop_node = cast(nodes.NodeNG, loop_node) |
132 | 131 | if not loop_node.parent_of(node): |
133 | 132 | continue |
134 | 133 |
|
135 | 134 | # Check if var is mutated within loop (Assign/AugAssign) |
136 | 135 | for assignment_node in loop_node.nodes_of_class(nodes.AugAssign): |
137 | | - assignment_node = cast(nodes.AugAssign, assignment_node) |
138 | 136 | if node.parent.slice.name == assignment_node.target.name: |
139 | 137 | return |
140 | 138 | for assignment_node in loop_node.nodes_of_class(nodes.Assign): |
141 | | - assignment_node = cast(nodes.Assign, assignment_node) |
142 | 139 | if node.parent.slice.name in [ |
143 | 140 | n.name for n in assignment_node.targets |
144 | 141 | ]: |
@@ -216,7 +213,6 @@ def _check_consider_using_enumerate(self, node: nodes.For) -> None: |
216 | 213 | # for body. |
217 | 214 | for child in node.body: |
218 | 215 | for subscript in child.nodes_of_class(nodes.Subscript): |
219 | | - subscript = cast(nodes.Subscript, subscript) |
220 | 216 | if not isinstance(subscript.value, expected_subscript_val_type): |
221 | 217 | continue |
222 | 218 |
|
@@ -254,8 +250,6 @@ def _check_consider_using_dict_items(self, node: nodes.For) -> None: |
254 | 250 | # for body. |
255 | 251 | for child in node.body: |
256 | 252 | for subscript in child.nodes_of_class(nodes.Subscript): |
257 | | - subscript = cast(nodes.Subscript, subscript) |
258 | | - |
259 | 253 | if not isinstance(subscript.value, (nodes.Name, nodes.Attribute)): |
260 | 254 | continue |
261 | 255 |
|
@@ -304,8 +298,6 @@ def _check_consider_using_dict_items_comprehension( |
304 | 298 |
|
305 | 299 | for child in node.parent.get_children(): |
306 | 300 | for subscript in child.nodes_of_class(nodes.Subscript): |
307 | | - subscript = cast(nodes.Subscript, subscript) |
308 | | - |
309 | 301 | if not isinstance(subscript.value, (nodes.Name, nodes.Attribute)): |
310 | 302 | continue |
311 | 303 |
|
|
0 commit comments