|
|
|
@ -9,19 +9,8 @@ from pylint.interfaces import IAstroidChecker
|
|
|
|
|
from pylint.checkers import BaseChecker
|
|
|
|
|
from pylint.checkers import utils
|
|
|
|
|
from pylint.checkers.utils import check_messages
|
|
|
|
|
try:
|
|
|
|
|
from pylint.checkers.utils import parse_format_method_string
|
|
|
|
|
except ImportError:
|
|
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
|
from pylint.checkers.strings import parse_format_method_string
|
|
|
|
|
|
|
|
|
|
MSGS = {
|
|
|
|
|
'E9305': ("Format string contains automatic field numbering "
|
|
|
|
|
"specification",
|
|
|
|
|
"ansible-format-automatic-specification",
|
|
|
|
|
"Used when a PEP 3101 format string contains automatic "
|
|
|
|
|
"field numbering (e.g. '{}').",
|
|
|
|
|
{'minversion': (2, 6)}),
|
|
|
|
|
'E9390': ("bytes object has no .format attribute",
|
|
|
|
|
"ansible-no-format-on-bytestring",
|
|
|
|
|
"Used when a bytestring was used as a PEP 3101 format string "
|
|
|
|
@ -64,20 +53,6 @@ class AnsibleStringFormatChecker(BaseChecker):
|
|
|
|
|
if isinstance(strnode.value, bytes):
|
|
|
|
|
self.add_message('ansible-no-format-on-bytestring', node=node)
|
|
|
|
|
return
|
|
|
|
|
if not isinstance(strnode.value, str):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if node.starargs or node.kwargs:
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
num_args = parse_format_method_string(strnode.value)[1]
|
|
|
|
|
except utils.IncompleteFormatString:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if num_args:
|
|
|
|
|
self.add_message('ansible-format-automatic-specification',
|
|
|
|
|
node=node)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register(linter):
|
|
|
|
|