Your IP : 216.73.216.213
B
A!p\{ � @ s` d Z ddlZddlZddlZddlZddlmZ ddlZddlm Z ddl
mZ ddlm
Z
mZmZ ddlmZmZ ddlmZ dd lmZ d
Zejdd� dkZejdd� d
kZddddddddddddddddddd �Zejejejejejejej fZ!ej"d! Z#ej"d" Z$ej"d# Z%d$d%� Z&d&d'� Z'G d(d)� d)e�Z(G d*d+� d+e�Z)d,d-� Z*d.d/� Z+dS )0z*Checker for string formatting operations.
� N)�Counter)�CallSite)�Const)�
ITokenChecker�IAstroidChecker�IRawChecker)�BaseChecker�BaseTokenChecker)�utils)�check_messages)z__builtin__.unicodez__builtin__.strzbuiltins.str� )� r )r � )z3Unsupported format character %r (%#02x) at index %dzbad-format-characterzEUsed when an unsupported format character is used in a format string.)z4Format string ends in middle of conversion specifierztruncated-format-stringzNUsed when a format string terminates before the end of a conversion specifier.)z?Mixing named and unnamed conversion specifiers in format stringzmixed-format-stringz�Used when a format string contains both named (e.g. '%(foo)d') and unnamed (e.g. '%d') conversion specifiers. This is also used when a named conversion specifier contains * for the minimum field width and/or precision.)z*Expected mapping for format string, not %szformat-needs-mappingzoUsed when a format string that uses named conversion specifiers is used with an argument that is not a mapping.)z7Format string dictionary key should be a string, not %szbad-format-string-keyzyUsed when a format string that uses named conversion specifiers is used with a dictionary whose keys are not all strings.)z)Unused key %r in format string dictionaryzunused-format-string-keyz�Used when a format string that uses named conversion specifiers is used with a dictionary that contains keys not required by the format string.)z*Missing key %r in format string dictionaryzmissing-format-string-keyz�Used when a format string that uses named conversion specifiers is used with a dictionary that doesn't contain all the keys required by the format string.)z$Too many arguments for format stringztoo-many-format-argsz^Used when a format string that uses unnamed conversion specifiers is given too many arguments.)z&Not enough arguments for format stringztoo-few-format-argsz\Used when a format string that uses unnamed conversion specifiers is given too few arguments)z)Argument %r does not match format type %rzbad-string-format-typezSUsed when a type required by format string is not suitable for actual argument type)z!Suspicious argument in %s.%s callzbad-str-strip-callzGThe argument to a str.{l,r,}strip call contains a duplicate character, )zInvalid format stringzbad-format-stringz.Used when a PEP 3101 format string is invalid.)z-Missing keyword argument %r for format stringzmissing-format-argument-keyzhUsed when a PEP 3101 format string that uses named fields doesn't receive one or more required keywords.)zUnused format argument %rzunused-format-string-argumentz}Used when a PEP 3101 format string that uses named fields is used with an argument that is not required by the format string.)zTFormat string contains both automatic field numbering and manual field specificationzformat-combined-specificationz�Used when a PEP 3101 format string contains both automatic field numbering (e.g. '{}') and manual field specification (e.g. '{0}').)z2Missing format attribute %r in format specifier %rzmissing-format-attributez�Used when a PEP 3101 format string uses an attribute specifier ({0.length}), but the argument passed for formatting doesn't have that attribute.)z2Using invalid lookup key %r in format specifier %rzinvalid-format-indexz�Used when a PEP 3101 format string uses a lookup specifier ({a[1]}), but the argument passed for formatting doesn't contain or doesn't have that key as an attribute.)zKDuplicate string formatting argument %r, consider passing as named argumentz$duplicate-string-formatting-argumentzmUsed when we detect that a string formatting is repeating an argument instead of using named string arguments)ZE1300ZE1301ZE1302ZE1303ZW1300ZW1301ZE1304ZE1305ZE1306ZE1307ZE1310ZW1302ZW1303ZW1304ZW1305ZW1306ZW1307ZW1308z.strz.floatz.intc C sN g }x6|D ].\}}|r(|� d�|�� q
|� d�|�� q
W t| �d�|� S )z^ Given a list of format specifiers, returns
the final access path (e.g. a.b.c[0][1]).
z.{}z[{!r}]� )�append�format�str�join)�key�parts�path�is_attribute� specifier� r �H/opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/strings.py�get_access_path� s r c C sT |dkrdS t | tj�rP| �� } | tkr0|dkS | tkr@|dkS | tkrLdS dS dS )N�srT�cz deEfFgGn%F)�
isinstance�astroid�Instance�pytype�BUILTINS_STR�BUILTINS_FLOAT�BUILTINS_INT)�arg_type�format_typer r r �arg_matches_format_type� s r'