diff options
author | cpopa <devnull@localhost> | 2014-06-13 14:23:31 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-06-13 14:23:31 +0300 |
commit | e8d8cef9c6a455599f30bd60693b1279fb127e58 (patch) | |
tree | 0348007096a16c8d15fe4d6d1b3aec17bc32c0a3 | |
parent | 0cb1b2077c77f68b220c55f1ffa469d24571638a (diff) | |
download | pylint-e8d8cef9c6a455599f30bd60693b1279fb127e58.tar.gz |
Skip YES arguments, add a few test cases.
-rw-r--r-- | checkers/strings.py | 2 | ||||
-rw-r--r-- | test/input/func_string_format_py27.py | 8 | ||||
-rw-r--r-- | test/messages/func_string_format_py27.txt | 43 |
3 files changed, 31 insertions, 22 deletions
diff --git a/checkers/strings.py b/checkers/strings.py index 202dfb0..3735756 100644 --- a/checkers/strings.py +++ b/checkers/strings.py @@ -378,6 +378,8 @@ class StringMethodsChecker(BaseChecker): if key not in named: continue argument = named[key] + if argument is astroid.YES: + continue try: argument = next(argument.infer()) except astroid.InferenceError: diff --git a/test/input/func_string_format_py27.py b/test/input/func_string_format_py27.py index 7b056a2..2eba807 100644 --- a/test/input/func_string_format_py27.py +++ b/test/input/func_string_format_py27.py @@ -1,6 +1,6 @@ """test for Python 3 string formatting error
"""
-# pylint: disable=too-few-public-methods, import-error
+# pylint: disable=too-few-public-methods, import-error, unused-argument
from missing import Missing
__revision__ = 1
@@ -24,6 +24,10 @@ class ReturnYes(object): """ can't be properly infered """
missing = Missing()
+def log(message, message_type="error"):
+ """ Test """
+ return message
+
def pprint():
"""Test string format """
print "{{}}".format(1)
@@ -60,3 +64,5 @@ def pprint(): print "{1.missing.length}".format(ReturnYes())
print "{b[0]}".format(a=23)
print "{a[0]}".format(a=object)
+ print "{a}".format(a=Missing())
+ print log("{}".format(2, "info"))
diff --git a/test/messages/func_string_format_py27.txt b/test/messages/func_string_format_py27.txt index 4f45bca..6b71517 100644 --- a/test/messages/func_string_format_py27.txt +++ b/test/messages/func_string_format_py27.txt @@ -1,22 +1,23 @@ -E: 29:pprint: Too many arguments for format string
-E: 37:pprint: Not enough arguments for format string
-E: 38:pprint: Too many arguments for format string
-E: 40:pprint: Not enough arguments for format string
-W: 30:pprint: Invalid Python 3 format string
-W: 31:pprint: Invalid Python 3 format string
-W: 32:pprint: Format string contains both automatic field numbering and manual field specification
-W: 34:pprint: Missing keyword argument 'a' for format string
-W: 35:pprint: Missing keyword argument 'b' for format string
-W: 35:pprint: Unused format argument 'c'
-W: 36:pprint: Missing keyword argument 'a' for format string
-W: 39:pprint: Missing keyword argument 'a' for format string
+E: 33:pprint: Too many arguments for format string
+E: 41:pprint: Not enough arguments for format string
+E: 42:pprint: Too many arguments for format string
+E: 44:pprint: Not enough arguments for format string
+E: 68:pprint: Too many arguments for format string
+W: 34:pprint: Invalid Python 3 format string
+W: 35:pprint: Invalid Python 3 format string
+W: 36:pprint: Format string contains both automatic field numbering and manual field specification
+W: 38:pprint: Missing keyword argument 'a' for format string
W: 39:pprint: Missing keyword argument 'b' for format string
-W: 39:pprint: Missing keyword argument 'c' for format string
-W: 41:pprint: Missing keyword argument 'a' for format string
-W: 41:pprint: Missing keyword argument 'b' for format string
-W: 48:pprint: Missing format attribute 'length' in format specifier 'a.ids.__len__.length'
-W: 56:pprint: Using invalid lookup key 400 in format specifier 'a.ids[3][400]'
-W: 57:pprint: Using invalid lookup key "'string'" in format specifier 'a.ids[3]["\'string\'"]'
-W: 61:pprint: Missing keyword argument 'b' for format string
-W: 61:pprint: Unused format argument 'a'
-W: 62:pprint: Using invalid lookup key 0 in format specifier 'a[0]'
\ No newline at end of file +W: 39:pprint: Unused format argument 'c'
+W: 40:pprint: Missing keyword argument 'a' for format string
+W: 43:pprint: Missing keyword argument 'a' for format string
+W: 43:pprint: Missing keyword argument 'b' for format string
+W: 43:pprint: Missing keyword argument 'c' for format string
+W: 45:pprint: Missing keyword argument 'a' for format string
+W: 45:pprint: Missing keyword argument 'b' for format string
+W: 52:pprint: Missing format attribute 'length' in format specifier 'a.ids.__len__.length'
+W: 60:pprint: Using invalid lookup key 400 in format specifier 'a.ids[3][400]'
+W: 61:pprint: Using invalid lookup key "'string'" in format specifier 'a.ids[3]["\'string\'"]'
+W: 65:pprint: Missing keyword argument 'b' for format string
+W: 65:pprint: Unused format argument 'a'
+W: 66:pprint: Using invalid lookup key 0 in format specifier 'a[0]'
\ No newline at end of file |