summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-03-29 18:11:37 -0700
committerAnthony Sottile <asottile@umich.edu>2021-03-30 17:37:13 -0700
commit3a85c8ce96d5c7c4c8250921734a826ac95e89b3 (patch)
tree40f33e38cf42e7a447e23a6d6924e4e2ee271a84
parent5b9edd04eeb184922f38f28dd682317d56372592 (diff)
downloadflake8-3a85c8ce96d5c7c4c8250921734a826ac95e89b3.tar.gz
clean up string_types
-rw-r--r--src/flake8/options/manager.py10
-rw-r--r--src/flake8/utils.py5
2 files changed, 6 insertions, 9 deletions
diff --git a/src/flake8/options/manager.py b/src/flake8/options/manager.py
index 5e0fee2..f537a42 100644
--- a/src/flake8/options/manager.py
+++ b/src/flake8/options/manager.py
@@ -82,11 +82,11 @@ def _flake8_normalize(value, *args, **kwargs):
raise TypeError(f"Unexpected keyword args: {kwargs}")
ret = value # type: Union[str, List[str]]
- if comma_separated_list and isinstance(ret, utils.string_types):
+ if comma_separated_list and isinstance(ret, str):
ret = utils.parse_comma_separated_list(value)
if normalize_paths:
- if isinstance(ret, utils.string_types):
+ if isinstance(ret, str):
ret = utils.normalize_path(ret, *args)
else:
ret = utils.normalize_paths(ret, *args)
@@ -212,7 +212,7 @@ class Option:
nargs = 0
# optparse -> argparse for `type`
- if isinstance(type, utils.string_types):
+ if isinstance(type, str):
LOG.warning(
"option %s: please update from optparse string `type=` to "
"argparse callable `type=` -- this will be an error in the "
@@ -299,9 +299,7 @@ class Option:
def normalize(self, value, *normalize_args):
# type: (Any, *str) -> Any
"""Normalize the value based on the option configuration."""
- if self.comma_separated_list and isinstance(
- value, utils.string_types
- ):
+ if self.comma_separated_list and isinstance(value, str):
value = utils.parse_comma_separated_list(value)
if self.normalize_paths:
diff --git a/src/flake8/utils.py b/src/flake8/utils.py
index 074cf0b..6bf0b49 100644
--- a/src/flake8/utils.py
+++ b/src/flake8/utils.py
@@ -29,7 +29,6 @@ if False: # `typing.TYPE_CHECKING` was introduced in 3.5.2
DIFF_HUNK_REGEXP = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$")
COMMA_SEPARATED_LIST_RE = re.compile(r"[,\s]")
LOCAL_PLUGIN_LIST_RE = re.compile(r"[,\t\n\r\f\v]")
-string_types = (str, type(""))
def parse_comma_separated_list(value, regexp=COMMA_SEPARATED_LIST_RE):
@@ -48,7 +47,7 @@ def parse_comma_separated_list(value, regexp=COMMA_SEPARATED_LIST_RE):
:rtype:
list
"""
- assert isinstance(value, string_types), value
+ assert isinstance(value, str), value
separated = regexp.split(value)
item_gen = (item.strip() for item in separated)
@@ -96,7 +95,7 @@ def parse_files_to_codes_mapping(value_): # noqa: C901
:param value: String to be parsed and normalized.
:type value: str
"""
- if not isinstance(value_, string_types):
+ if not isinstance(value_, str):
value = "\n".join(value_)
else:
value = value_