Skip to content

Commit 3a85c8c

Browse files
committedMar 31, 2021
clean up string_types
1 parent 5b9edd0 commit 3a85c8c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed
 

‎src/flake8/options/manager.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def _flake8_normalize(value, *args, **kwargs):
8282
raise TypeError(f"Unexpected keyword args: {kwargs}")
8383

8484
ret = value # type: Union[str, List[str]]
85-
if comma_separated_list and isinstance(ret, utils.string_types):
85+
if comma_separated_list and isinstance(ret, str):
8686
ret = utils.parse_comma_separated_list(value)
8787

8888
if normalize_paths:
89-
if isinstance(ret, utils.string_types):
89+
if isinstance(ret, str):
9090
ret = utils.normalize_path(ret, *args)
9191
else:
9292
ret = utils.normalize_paths(ret, *args)
@@ -212,7 +212,7 @@ def __init__(
212212
nargs = 0
213213

214214
# optparse -> argparse for `type`
215-
if isinstance(type, utils.string_types):
215+
if isinstance(type, str):
216216
LOG.warning(
217217
"option %s: please update from optparse string `type=` to "
218218
"argparse callable `type=` -- this will be an error in the "
@@ -299,9 +299,7 @@ def __repr__(self): # type: () -> str # noqa: D105
299299
def normalize(self, value, *normalize_args):
300300
# type: (Any, *str) -> Any
301301
"""Normalize the value based on the option configuration."""
302-
if self.comma_separated_list and isinstance(
303-
value, utils.string_types
304-
):
302+
if self.comma_separated_list and isinstance(value, str):
305303
value = utils.parse_comma_separated_list(value)
306304

307305
if self.normalize_paths:

‎src/flake8/utils.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
DIFF_HUNK_REGEXP = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$")
3030
COMMA_SEPARATED_LIST_RE = re.compile(r"[,\s]")
3131
LOCAL_PLUGIN_LIST_RE = re.compile(r"[,\t\n\r\f\v]")
32-
string_types = (str, type(""))
3332

3433

3534
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):
4847
:rtype:
4948
list
5049
"""
51-
assert isinstance(value, string_types), value
50+
assert isinstance(value, str), value
5251

5352
separated = regexp.split(value)
5453
item_gen = (item.strip() for item in separated)
@@ -96,7 +95,7 @@ def parse_files_to_codes_mapping(value_): # noqa: C901
9695
:param value: String to be parsed and normalized.
9796
:type value: str
9897
"""
99-
if not isinstance(value_, string_types):
98+
if not isinstance(value_, str):
10099
value = "\n".join(value_)
101100
else:
102101
value = value_

0 commit comments

Comments
 (0)
Please sign in to comment.