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_