":H d dl mZ d dlmZ d dlmZ d dlmZmZ d dl m
Z
erd dlmZ ddhZ
d dhZ G d
dej ZddZdS ) )annotations)
TYPE_CHECKING)nodes)checkers
interfaces)utils)PyLinterappendremoveaddc e Zd ZdZdZddddZdZ ej dd d
d#d Z d$dZ
d%dZed&d Z
ed'd Zed&d Zd(dZd(dZd(dZd)d!Zd"S )*ModifiedIterationCheckerzChecks for modified iterators in for loops iterations.
Currently supports `for` loops for Sets, Dictionaries and Lists.
modified_iteration)zkIterated list '%s' is being modified inside for loop body, consider iterating through a copy of it instead.modified-iterating-listzEmitted when items are added or removed to a list being iterated through. Doing so can result in unexpected behaviour, that is why it is preferred to use a copy of the list.)z`Iterated dict '%s' is being modified inside for loop body, iterate through a copy of it instead.modified-iterating-dictziEmitted when items are added or removed to a dict being iterated through. Doing so raises a RuntimeError.)z_Iterated set '%s' is being modified inside for loop body, iterate through a copy of it instead.modified-iterating-setzhEmitted when items are added or removed to a set being iterated through. Doing so raises a RuntimeError.)W4701E4702E4703 r r r node nodes.ForreturnNonec T |j }|j D ]}| || d S N)iterbody._modified_iterating_check_on_node_and_children)selfr iter_obj body_nodes |/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pylint/checkers/modified_iterating_checker.py visit_forz"ModifiedIterationChecker.visit_for6 sC 9 U UI?? 8TTTT U U r" nodes.NodeNGr! c | || | D ]}| || dS )zFSee if node or any of its children raises modified iterating messages.N)_modified_iterating_checkget_childrenr )r r" r! childs r# r zGModifiedIterationChecker._modified_iterating_check_on_node_and_children> s\
&&y(;;;++-- Q QE??xPPPP Q Qr% c d }t |t j rt fd|j D rkt j }t |t j rd}nt |t j rd}nt |t j rd}nqt t j
t j f snJ | rd}n1
| rd}n | rd}|rOt t j rj }nj } |||ft$ j d S d S )Nc 3 D K | ]} | V d S r )_deleted_iteration_target_cond).0tr! r s r#