Skip to content

Commit

Permalink
Remove unnecessary parentheses, use f-string, rm "object"
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Dec 22, 2022
1 parent 98390f5 commit 5ed78a8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
6 changes: 2 additions & 4 deletions isort/deprecated/finders.py
Expand Up @@ -391,10 +391,8 @@ def __init__(
# if one finder fails to instantiate isort can continue using the rest
if self.verbose:
print(
(
f"{finder_cls.__name__} encountered an error ({exception}) during "
"instantiation and cannot be used"
)
f"{finder_cls.__name__} encountered an error ({exception}) during "
"instantiation and cannot be used"
)
self.finders: Tuple[BaseFinder, ...] = tuple(finders)

Expand Down
2 changes: 1 addition & 1 deletion isort/main.py
Expand Up @@ -966,7 +966,7 @@ def _preconvert(item: Any) -> Union[str, List[Any]]:
return str(item)
if callable(item) and hasattr(item, "__name__"):
return str(item.__name__)
raise TypeError("Unserializable object {} of type {}".format(item, type(item)))
raise TypeError(f"Unserializable object {item} of type {type(item)}")


def identify_imports_main(
Expand Down
2 changes: 1 addition & 1 deletion isort/output.py
Expand Up @@ -562,7 +562,7 @@ def _with_straight_imports(
) -> List[str]:
output: List[str] = []

as_imports = any((module in parsed.as_map["straight"] for module in straight_modules))
as_imports = any(module in parsed.as_map["straight"] for module in straight_modules)

# combine_straight_imports only works for bare imports, 'as' imports not included
if config.combine_straight_imports and not as_imports:
Expand Down
12 changes: 5 additions & 7 deletions scripts/check_acknowledgments.py
Expand Up @@ -46,13 +46,11 @@ async def main():
)
results = response.json()
contributors.extend(
(
contributor
for contributor in results
if contributor["type"] == GITHUB_USER_TYPE
and contributor["login"] not in IGNORED_AUTHOR_LOGINS
and f"@{contributor['login'].lower()}" not in ACKNOWLEDGEMENTS
)
contributor
for contributor in results
if contributor["type"] == GITHUB_USER_TYPE
and contributor["login"] not in IGNORED_AUTHOR_LOGINS
and f"@{contributor['login'].lower()}" not in ACKNOWLEDGEMENTS
)

unacknowledged_users = await asyncio.gather(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_hooks.py
Expand Up @@ -65,7 +65,7 @@ def test_git_hook(src_dir):
"isort.hooks.get_lines", MagicMock(return_value=[os.path.join(src_dir, "main.py")])
) as run_mock:

class FakeProcessResponse(object):
class FakeProcessResponse:
stdout = b"# isort: skip-file\nimport b\nimport a\n"

with patch("subprocess.run", MagicMock(return_value=FakeProcessResponse())) as run_mock:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_isort.py
Expand Up @@ -3017,7 +3017,7 @@ def test_import_by_paren_issue_460() -> None:
import io
import os
"""
assert isort.code((test_input)) == test_input
assert isort.code(test_input) == test_input


def test_function_with_docstring() -> None:
Expand Down Expand Up @@ -3780,7 +3780,7 @@ def test_command_line(tmpdir, capfd, multiprocess: bool) -> None:

tmpdir.join("file1.py").write("import re\nimport os\n\nimport contextlib\n\n\nimport isort")
tmpdir.join("file2.py").write(
("import collections\nimport time\n\nimport abc" "\n\n\nimport isort")
"import collections\nimport time\n\nimport abc" "\n\n\nimport isort"
)
arguments = [str(tmpdir), "--settings-path", os.getcwd()]
if multiprocess:
Expand Down

0 comments on commit 5ed78a8

Please sign in to comment.