diff options
author | cpopa <devnull@localhost> | 2014-06-15 02:14:22 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-06-15 02:14:22 +0300 |
commit | 2f173114dfd45952daa34f2eb5912e8914d8fdb7 (patch) | |
tree | 508320426efbdf6e899ffd6563c74eafa4bdffa3 | |
parent | 0298f143249c31f627f0b84b5844d99dffc03ee9 (diff) | |
download | pylint-2f173114dfd45952daa34f2eb5912e8914d8fdb7.tar.gz |
Filter YES arguments.
-rw-r--r-- | checkers/strings.py | 4 | ||||
-rw-r--r-- | test/input/func_string_format_py27.py | 2 | ||||
-rw-r--r-- | test/messages/func_string_format_py27.txt | 44 |
3 files changed, 26 insertions, 24 deletions
diff --git a/checkers/strings.py b/checkers/strings.py index 25f2f00..4f4293a 100644 --- a/checkers/strings.py +++ b/checkers/strings.py @@ -378,13 +378,13 @@ class StringMethodsChecker(BaseChecker): if key not in named: continue argument = named[key] - if argument is astroid.YES: + if argument in (astroid.YES, None): continue try: argument = next(argument.infer()) except astroid.InferenceError: continue - if not specifiers: + if not specifiers or argument is astroid.YES: # No need to check this key if it doesn't # use attribute / item access continue diff --git a/test/input/func_string_format_py27.py b/test/input/func_string_format_py27.py index 2eba807..cd3071b 100644 --- a/test/input/func_string_format_py27.py +++ b/test/input/func_string_format_py27.py @@ -1,6 +1,7 @@ """test for Python 3 string formatting error
"""
# pylint: disable=too-few-public-methods, import-error, unused-argument
+import os
from missing import Missing
__revision__ = 1
@@ -66,3 +67,4 @@ def pprint(): print "{a[0]}".format(a=object)
print "{a}".format(a=Missing())
print log("{}".format(2, "info"))
+ print "{pid}".format(pid=os.getpid())
diff --git a/test/messages/func_string_format_py27.txt b/test/messages/func_string_format_py27.txt index 6b71517..632ff60 100644 --- a/test/messages/func_string_format_py27.txt +++ b/test/messages/func_string_format_py27.txt @@ -1,23 +1,23 @@ -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
+E: 34:pprint: Too many arguments for format string
+E: 42:pprint: Not enough arguments for format string
+E: 43:pprint: Too many arguments for format string
+E: 45:pprint: Not enough arguments for format string
+E: 69:pprint: Too many arguments for 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: 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 +W: 36:pprint: Invalid Python 3 format string
+W: 37:pprint: Format string contains both automatic field numbering and manual field specification
+W: 39:pprint: Missing keyword argument 'a' for format string
+W: 40:pprint: Missing keyword argument 'b' for format string
+W: 40:pprint: Unused format argument 'c'
+W: 41:pprint: Missing keyword argument 'a' for format string
+W: 44:pprint: Missing keyword argument 'a' for format string
+W: 44:pprint: Missing keyword argument 'b' for format string
+W: 44:pprint: Missing keyword argument 'c' for format string
+W: 46:pprint: Missing keyword argument 'a' for format string
+W: 46:pprint: Missing keyword argument 'b' for format string
+W: 53:pprint: Missing format attribute 'length' in format specifier 'a.ids.__len__.length'
+W: 61:pprint: Using invalid lookup key 400 in format specifier 'a.ids[3][400]'
+W: 62:pprint: Using invalid lookup key "'string'" in format specifier 'a.ids[3]["\'string\'"]'
+W: 66:pprint: Missing keyword argument 'b' for format string
+W: 66:pprint: Unused format argument 'a'
+W: 67:pprint: Using invalid lookup key 0 in format specifier 'a[0]'
\ No newline at end of file |