summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-08-29 14:24:30 -0400
committerBrett Cannon <brett@python.org>2014-08-29 14:24:30 -0400
commit8f3506b375a193856f7dd857f582f6f3b9c5580c (patch)
tree421c672fbc23e47f4fdc8c4b8dfb7154a9765dad
parentfea908c8e20aa3eac1bcaad18fecd4c68cfc9b05 (diff)
downloadpylint-8f3506b375a193856f7dd857f582f6f3b9c5580c.tar.gz
Change basestring to six.string_types
-rw-r--r--checkers/base.py2
-rw-r--r--checkers/logging.py5
-rw-r--r--checkers/strings.py9
-rw-r--r--checkers/variables.py2
4 files changed, 12 insertions, 6 deletions
diff --git a/checkers/base.py b/checkers/base.py
index 98e5a58..501d930 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -578,7 +578,7 @@ functions, methods
"""check for various kind of statements without effect"""
expr = node.value
if isinstance(expr, astroid.Const) and isinstance(expr.value,
- basestring):
+ six.string_types):
# treat string statement in a separated message
# Handle PEP-257 attribute docstrings.
# An attribute docstring is defined as being a string right after
diff --git a/checkers/logging.py b/checkers/logging.py
index a5b38d8..39c4d9c 100644
--- a/checkers/logging.py
+++ b/checkers/logging.py
@@ -20,6 +20,9 @@ from pylint import interfaces
from pylint.checkers import utils
from pylint.checkers.utils import check_messages
+import six
+
+
MSGS = {
'W1201': ('Specify string format arguments as logging function parameters',
'logging-not-lazy',
@@ -166,7 +169,7 @@ class LoggingChecker(checkers.BaseChecker):
# don't check any further.
return
format_string = node.args[format_arg].value
- if not isinstance(format_string, basestring):
+ if not isinstance(format_string, six.string_types):
# If the log format is constant non-string (e.g. logging.debug(5)),
# ensure there are no arguments.
required_num_args = 0
diff --git a/checkers/strings.py b/checkers/strings.py
index f517c4c..03c557a 100644
--- a/checkers/strings.py
+++ b/checkers/strings.py
@@ -30,6 +30,9 @@ from pylint.checkers import BaseChecker, BaseTokenChecker
from pylint.checkers import utils
from pylint.checkers.utils import check_messages
+import six
+
+
_PY3K = sys.version_info[:2] >= (3, 0)
_PY27 = sys.version_info[:2] == (2, 7)
@@ -231,7 +234,7 @@ class StringFormatChecker(BaseChecker):
args = node.right
if not (isinstance(left, astroid.Const)
- and isinstance(left.value, basestring)):
+ and isinstance(left.value, six.string_types)):
return
format_string = left.value
try:
@@ -260,7 +263,7 @@ class StringFormatChecker(BaseChecker):
for k, _ in args.items:
if isinstance(k, astroid.Const):
key = k.value
- if isinstance(key, basestring):
+ if isinstance(key, six.string_types):
keys.add(key)
else:
self.add_message('bad-format-string-key',
@@ -365,7 +368,7 @@ class StringMethodsChecker(BaseChecker):
return
named_fields = set(field[0] for field in fields
- if isinstance(field[0], basestring))
+ if isinstance(field[0], six.string_types))
if num_args and manual_pos:
self.add_message('format-combined-specification',
node=node)
diff --git a/checkers/variables.py b/checkers/variables.py
index bcb5bb2..6a26f5a 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -321,7 +321,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
continue
if not isinstance(elt_name, astroid.Const) \
- or not isinstance(elt_name.value, basestring):
+ or not isinstance(elt_name.value, six.string_types):
self.add_message('invalid-all-object',
args=elt.as_string(), node=elt)
continue