Uname : Linux premium36.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Soft : LiteSpeed
Ip : 198.54.115.237
Port : 443
~
/
opt
/
cloudlinux
/
venv
/
lib64
/
python3.11
/
site-packages
/
pylint
/
checkers
/
refactoring
/
__pycache__
[ HOME ]
Exec
Submit
File Name : implicit_booleaness_checker.cpython-311.pyc
� � h�$ � �| � d dl mZ d dlZd dlmZmZmZ d dlmZ d dlm Z d dl mZmZ G d� dej � � ZdS ) � )�annotationsN)�bases�nodes�util)�checkers)�utils)�HIGH� INFERENCEc � � e Zd ZdZdZdddddgifdd �Zd Z ej d� � d&d�� � Z e d'd�� � Z ej d� � d(d�� � Z ej d� � d)d�� � Z d)d�Zd*d�Zd+d!�Ze d,d$�� � Zd%S )-�ImplicitBooleanessCheckera� Checks for incorrect usage of comparisons or len() inside conditions. Incorrect usage of len() Pep8 states: For sequences, (strings, lists, tuples), use the fact that empty sequences are false. Yes: if not seq: if seq: No: if len(seq): if not len(seq): Problems detected: * if len(sequence): * if not len(sequence): * elif len(sequence): * elif not len(sequence): * while len(sequence): * while not len(sequence): * assert len(sequence): * assert not len(sequence): * bool(len(sequence)) Incorrect usage of empty literal sequences; (), [], {}, For empty sequences, (dicts, lists, tuples), use the fact that empty sequences are false. Yes: if variable: if not variable No: if variable == empty_literal: if variable != empty_literal: Problems detected: * comparison such as variable == empty_literal: * comparison such as variable != empty_literal: �refactoringzQDo not use `len(SEQUENCE)` without comparison to determine if a sequence is empty�use-implicit-booleaness-not-lena Used when Pylint detects that len(sequence) is being used without explicit comparison inside a condition to determine if a sequence is empty. Instead of coercing the length to a boolean, either rely on the fact that empty sequences are false or compare the length against a scalar.� old_names)�C1801zlen-as-condition)z7'%s' can be simplified to '%s' as an empty %s is falsey�&use-implicit-booleaness-not-comparisonz�Used when Pylint detects that collection literal comparison is being used to check for emptiness; Use implicit booleaness instead of a collection classes; empty collections are considered as false)�C1802�C1803� �node� nodes.Call�return�Nonec � �� t j |d� � sd S |j }t |t j � � r!|j }t |t j � � �!t j ||� � sd S |j d }t j t j t j t j f}t ||� � r| � d|t �� � d S t |� � � � � }n# t j $ r Y d S w xY w| � |� � �t'