summaryrefslogtreecommitdiff
path: root/checkers
diff options
context:
space:
mode:
authorMichal Nowikowski <godfryd@gmail.com>2014-07-26 07:45:33 +0200
committerMichal Nowikowski <godfryd@gmail.com>2014-07-26 07:45:33 +0200
commite78a81deb11af85da6678ff7d7c236c2c67e7d1f (patch)
tree6b8b12e89447b90ff208e92d00ce9b5470b9a1cc /checkers
parente03a152f6995f9ddb96d12b82cffb1b1e28386d3 (diff)
parent67a56a24f5553f3579a76cbee1c0f1df61e23437 (diff)
downloadpylint-e78a81deb11af85da6678ff7d7c236c2c67e7d1f.tar.gz
merge
Diffstat (limited to 'checkers')
-rw-r--r--checkers/base.py12
-rw-r--r--checkers/format.py36
-rw-r--r--checkers/imports.py5
3 files changed, 31 insertions, 22 deletions
diff --git a/checkers/base.py b/checkers/base.py
index fb63c51..c1600b5 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -53,6 +53,7 @@ REVERSED_METHODS = (('__getitem__', '__len__'),
('__reversed__', ))
PY33 = sys.version_info >= (3, 3)
+PY3K = sys.version_info >= (3, 0)
BAD_FUNCTIONS = ['map', 'filter', 'apply']
if sys.version_info < (3, 0):
BAD_FUNCTIONS.append('input')
@@ -1092,6 +1093,17 @@ class DocStringChecker(_BasicChecker):
if node_type != 'module' and max_lines > -1 and lines < max_lines:
return
self.stats['undocumented_'+node_type] += 1
+ if (node.body and isinstance(node.body[0], astroid.Discard) and
+ isinstance(node.body[0].value, astroid.CallFunc)):
+ # Most likely a string with a format call. Let's see.
+ func = safe_infer(node.body[0].value.func)
+ if (isinstance(func, astroid.BoundMethod)
+ and isinstance(func.bound, astroid.Instance)):
+ # Strings in Python 3, others in Python 2.
+ if PY3K and func.bound.name == 'str':
+ return
+ elif func.bound.name in ('str', 'unicode', 'bytes'):
+ return
self.add_message('missing-docstring', node=node, args=(node_type,))
elif not docstring.strip():
self.stats['undocumented_'+node_type] += 1
diff --git a/checkers/format.py b/checkers/format.py
index 1d93a2d..2c0e215 100644
--- a/checkers/format.py
+++ b/checkers/format.py
@@ -105,6 +105,22 @@ MSGS = {
{'old_names': [('C0323', 'no-space-after-operator'),
('C0324', 'no-space-after-comma'),
('C0322', 'no-space-before-operator')]}),
+ 'W0331': ('Use of the <> operator',
+ 'old-ne-operator',
+ 'Used when the deprecated "<>" operator is used instead '
+ 'of "!=".',
+ {'maxversion': (3, 0)}),
+ 'W0332': ('Use of "l" as long integer identifier',
+ 'lowercase-l-suffix',
+ 'Used when a lower case "l" is used to mark a long integer. You '
+ 'should use a upper case "L" since the letter "l" looks too much '
+ 'like the digit "1"',
+ {'maxversion': (3, 0)}),
+ 'W0333': ('Use of the `` operator',
+ 'backtick',
+ 'Used when the deprecated "``" (backtick) operator is used '
+ 'instead of the str() function.',
+ {'scope': WarningScope.NODE, 'maxversion': (3, 0)}),
'C0327': ('Mixed line endings LF and CRLF',
'mixed-line-endings',
'Used when there are mixed (LF and CRLF) newline signs in a file.'),
@@ -114,26 +130,6 @@ MSGS = {
}
-if sys.version_info < (3, 0):
-
- MSGS.update({
- 'W0331': ('Use of the <> operator',
- 'old-ne-operator',
- 'Used when the deprecated "<>" operator is used instead '
- 'of "!=".'),
- 'W0332': ('Use of "l" as long integer identifier',
- 'lowercase-l-suffix',
- 'Used when a lower case "l" is used to mark a long integer. You '
- 'should use a upper case "L" since the letter "l" looks too much '
- 'like the digit "1"'),
- 'W0333': ('Use of the `` operator',
- 'backtick',
- 'Used when the deprecated "``" (backtick) operator is used '
- 'instead of the str() function.',
- {'scope': WarningScope.NODE}),
- })
-
-
def _underline_token(token):
length = token[3][1] - token[2][1]
offset = token[2][1]
diff --git a/checkers/imports.py b/checkers/imports.py
index 3242b75..5964a26 100644
--- a/checkers/imports.py
+++ b/checkers/imports.py
@@ -139,8 +139,9 @@ MSGS = {
'Used a module marked as deprecated is imported.'),
'W0403': ('Relative import %r, should be %r',
'relative-import',
- 'Used when an import relative to the package directory is \
- detected.'),
+ 'Used when an import relative to the package directory is '
+ 'detected.',
+ {'maxversion': (3, 0)}),
'W0404': ('Reimport %r (imported line %s)',
'reimported',
'Used when a module is reimported multiple times.'),