PK���ȼRY��������€��� �v3.phpUT �øŽg‰gñ“gux �õ��õ��½T]kÛ0}߯pEhìâÙM7X‰çv%”v0֐µ{)Aå:6S$!ÉMJèߕ?R÷!>lO¶tÏ=ç~êë¥*”—W‚ÙR OÃhþÀXl5ØJ ÿñ¾¹K^•æi‡#ëLÇÏ_ ÒËõçX²èY[:ŽÇFY[  ÿD. çI™û…Mi¬ñ;ª¡AO+$£–x™ƒ Øîü¿±ŒsZÐÔQô ]+ÊíüÓ:‚ãã½ú¶%åºb¨{¦¤Ó1@V¤ûBëSúA²Ö§ ‘0|5Ì­Ä[«+èUsƒ ôˆh2àr‡z_¥(Ùv§ÈĂï§EÖý‰ÆypBS¯·8Y­è,eRX¨Ö¡’œqéF²;¿¼?Ø?Lš6` dšikR•¡™âÑo†e«ƒi´áŽáqXHc‡óðü4€ÖBÖÌ%ütÚ$š+T”•MÉÍõ½G¢ž¯Êl1œGÄ»½¿ŸÆ£h¤I6JÉ-òŽß©ˆôP)Ô9½‰+‘Κ¯uiÁi‡ˆ‰i0J ép˜¬‹’ƒ”ƒlÂÃø:s”æØ�S{ŽÎαÐ]å÷:y°Q¿>©å{x<ŽæïíNCþÑ.Mf?¨«2ý}=ûõýî'=£§ÿu•Ü(—¾IIa­"éþ@¶�¿ä9?^-qìÇÞôvŠeÈc ðlacã®xèÄ'®âd¶ çˆSEæódP/ÍÆv{Ô)Ó ?>…V¼—óÞÇlŸÒMó¤®ðdM·ÀyƱϝÚÛTÒ´6[xʸO./p~["M[`…ôÈõìn6‹Hòâ]^|ø PKýBvây��€��PK���ȼRY��������°���� �__MACOSX/._v3.phpUT �øŽg‰gþ“gux �õ��õ��c`cg`b`ðMLVðVˆP€'qƒøˆŽ!!AP&HÇ %PDF-1.7 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 9 0 R >> >> /MediaBox [0.000 0.000 595.280 841.890] >> endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Producer (���d�o�m�p�d�f� �2�.�0�.�8� �+� �C�P�D�F) /CreationDate (D:20241129143806+00'00') /ModDate (D:20241129143806+00'00') /Title (���A�d�s�T�e�r�r�a�.�c�o�m� �i�n�v�o�i�c�e) >> endobj 6 0 obj << /Type /Page /MediaBox [0.000 0.000 595.280 841.890] /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Filter /FlateDecode /Length 904 >> stream x���]o�J���+F�ͩ����su\ �08=ʩzရ���lS��lc� "Ց� ���wޙ�%�R�DS��� �OI�a`� �Q�f��5����_���םO�`�7�_FA���D�Џ.j�a=�j����>��n���R+�P��l�rH�{0��w��0��=W�2D ����G���I�>�_B3ed�H�yJ�G>/��ywy�fk��%�$�2.��d_�h����&)b0��"[\B��*_.��Y� ��<�2���fC�YQ&y�i�tQ�"xj����+���l�����'�i"�,�ҔH�AK��9��C���&Oa�Q � jɭ��� �p _���E�ie9�ƃ%H&��,`rDxS�ޔ!�(�X!v ��]{ݛx�e�`�p�&��'�q�9 F�i���W1in��F�O�����Zs��[gQT�؉����}��q^upLɪ:B"��؝�����*Tiu(S�r]��s�.��s9n�N!K!L�M�?�*[��N�8��c��ۯ�b�� ��� �YZ���SR3�n�����lPN��P�;��^�]�!'�z-���ӊ���/��껣��4�l(M�E�QL��X ��~���G��M|�����*��~�;/=N4�-|y�`�i�\�e�T�<���L��G}�"В�J^���q��"X�?(V�ߣXۆ{��H[����P�� �c���kc�Z�9v�����? �a��R�h|��^�k�D4W���?Iӊ�]<��4�)$wdat���~�����������|�L��x�p|N�*��E� �/4�Qpi�x.>��d����,M�y|4^�Ż��8S/޾���uQe���D�y� ��ͧH�����j�wX � �&z� endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj 9 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj xref 0 10 0000000000 65535 f 0000000009 00000 n 0000000074 00000 n 0000000120 00000 n 0000000284 00000 n 0000000313 00000 n 0000000514 00000 n 0000000617 00000 n 0000001593 00000 n 0000001700 00000 n trailer << /Size 10 /Root 1 0 R /Info 5 0 R /ID[] >> startxref 1812 %%EOF
Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 128

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 129

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 131
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt """Check for use of for loops that only check for a condition.""" from __future__ import annotations from typing import TYPE_CHECKING from astroid import nodes from pylint.checkers import BaseChecker from pylint.checkers.utils import ( assigned_bool, only_required_for_messages, returns_bool, ) from pylint.interfaces import HIGH if TYPE_CHECKING: from pylint.lint.pylinter import PyLinter class ConsiderUsingAnyOrAllChecker(BaseChecker): name = "consider-using-any-or-all" msgs = { "C0501": ( "`for` loop could be `%s`", "consider-using-any-or-all", "A for loop that checks for a condition and return a bool can be replaced with any or all.", ) } @only_required_for_messages("consider-using-any-or-all") def visit_for(self, node: nodes.For) -> None: if len(node.body) != 1: # Only If node with no Else return if not isinstance(node.body[0], nodes.If): return if_children = list(node.body[0].get_children()) if any(isinstance(child, nodes.If) for child in if_children): # an if node within the if-children indicates an elif clause, # suggesting complex logic. return node_after_loop = node.next_sibling() if self._assigned_reassigned_returned(node, if_children, node_after_loop): final_return_bool = node_after_loop.value.name suggested_string = self._build_suggested_string(node, final_return_bool) self.add_message( "consider-using-any-or-all", node=node, args=suggested_string, confidence=HIGH, ) return if self._if_statement_returns_bool(if_children, node_after_loop): final_return_bool = node_after_loop.value.value suggested_string = self._build_suggested_string(node, final_return_bool) self.add_message( "consider-using-any-or-all", node=node, args=suggested_string, confidence=HIGH, ) return @staticmethod def _if_statement_returns_bool( if_children: list[nodes.NodeNG], node_after_loop: nodes.NodeNG ) -> bool: """Detect for-loop, if-statement, return pattern: Ex: def any_uneven(items): for item in items: if not item % 2 == 0: return True return False """ if not len(if_children) == 2: # The If node has only a comparison and return return False if not returns_bool(if_children[1]): return False # Check for terminating boolean return right after the loop return returns_bool(node_after_loop) @staticmethod def _assigned_reassigned_returned( node: nodes.For, if_children: list[nodes.NodeNG], node_after_loop: nodes.NodeNG ) -> bool: """Detect boolean-assign, for-loop, re-assign, return pattern: Ex: def check_lines(lines, max_chars): long_line = False for line in lines: if len(line) > max_chars: long_line = True # no elif / else statement return long_line """ node_before_loop = node.previous_sibling() if not assigned_bool(node_before_loop): # node before loop isn't assigning to boolean return False assign_children = [x for x in if_children if isinstance(x, nodes.Assign)] if not assign_children: # if-nodes inside loop aren't assignments return False # We only care for the first assign node of the if-children. Otherwise it breaks the pattern. first_target = assign_children[0].targets[0] target_before_loop = node_before_loop.targets[0] if not ( isinstance(first_target, nodes.AssignName) and isinstance(target_before_loop, nodes.AssignName) ): return False node_before_loop_name = node_before_loop.targets[0].name return ( first_target.name == node_before_loop_name and isinstance(node_after_loop, nodes.Return) and isinstance(node_after_loop.value, nodes.Name) and node_after_loop.value.name == node_before_loop_name ) @staticmethod def _build_suggested_string(node: nodes.For, final_return_bool: bool) -> str: """When a nodes.For node can be rewritten as an any/all statement, return a suggestion for that statement. 'final_return_bool' is the boolean literal returned after the for loop if all conditions fail. """ loop_var = node.target.as_string() loop_iter = node.iter.as_string() test_node = next(node.body[0].get_children()) if isinstance(test_node, nodes.UnaryOp) and test_node.op == "not": # The condition is negated. Advance the node to the operand and modify the suggestion test_node = test_node.operand suggested_function = "all" if final_return_bool else "not all" else: suggested_function = "not any" if final_return_bool else "any" test = test_node.as_string() return f"{suggested_function}({test} for {loop_var} in {loop_iter})" def register(linter: PyLinter) -> None: linter.register_checker(ConsiderUsingAnyOrAllChecker(linter))