Skip to content

Commit ec781c3

Browse files
committedDec 30, 2022
Fix linting errors from latest depednency upgrades
1 parent f2f8c2c commit ec781c3

8 files changed

+17
-13
lines changed
 

‎isort/api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def sort_stream(
178178
file_input=_input_stream.read(),
179179
file_output=_output_stream.read(),
180180
file_path=file_path,
181-
output=output_stream if show_diff is True else cast(TextIO, show_diff),
181+
output=output_stream if show_diff is True else show_diff,
182182
color_output=config.color_output,
183183
)
184184
return changed
@@ -296,7 +296,7 @@ def check_stream(
296296
file_input=file_contents,
297297
file_output=output_stream.read(),
298298
file_path=file_path,
299-
output=None if show_diff is True else cast(TextIO, show_diff),
299+
output=None if show_diff is True else show_diff,
300300
color_output=config.color_output,
301301
)
302302
return False
@@ -488,7 +488,7 @@ def sort_file(
488488
file_input=source_file.stream.read(),
489489
file_output=output.read(),
490490
file_path=actual_file_path,
491-
output=None if show_diff is True else cast(TextIO, show_diff),
491+
output=None if show_diff is True else show_diff,
492492
color_output=config.color_output,
493493
)
494494
source_file.stream.close()

‎isort/settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
SortingFunctionDoesNotExist,
3939
UnsupportedSettings,
4040
)
41-
from .profiles import profiles
41+
from .profiles import profiles as profiles
4242
from .sections import DEFAULT as SECTION_DEFAULTS
4343
from .sections import FIRSTPARTY, FUTURE, LOCALFOLDER, STDLIB, THIRDPARTY
4444
from .utils import Trie
@@ -318,7 +318,7 @@ def __init__(
318318
config_vars.pop("_skips")
319319
config_vars.pop("_skip_globs")
320320
config_vars.pop("_sorting_function")
321-
super().__init__(**config_vars) # type: ignore
321+
super().__init__(**config_vars)
322322
return
323323

324324
# We can't use self.quiet to conditionally show warnings before super.__init__() is called

‎tests/benchmark/test_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
import pytest
24

35
from isort import api
@@ -7,7 +9,7 @@
79

810

911
@pytest.fixture
10-
def imperfect(tmpdir) -> None:
12+
def imperfect(tmpdir) -> Any:
1113
imperfect_file = tmpdir.join("test_needs_changes.py")
1214
imperfect_file.write_text(imperfect_content, "utf8")
1315
return imperfect_file

‎tests/integration/test_hypothesmith.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _record_targets(code: str, prefix: str = "") -> str:
3333
return code
3434

3535

36-
def configs(**force_strategies: st.SearchStrategy) -> st.SearchStrategy[isort.Config]:
36+
def configs(**force_strategies: st.SearchStrategy[isort.Config]) -> st.SearchStrategy[isort.Config]:
3737
"""Generate arbitrary Config objects."""
3838
skip = {
3939
"line_ending",
@@ -66,7 +66,7 @@ def configs(**force_strategies: st.SearchStrategy) -> st.SearchStrategy[isort.Co
6666
"py_version": st.sampled_from(("auto",) + isort.settings.VALID_PY_TARGETS),
6767
}
6868
kwargs = {**inferred_kwargs, **specific, **force_strategies}
69-
return st.fixed_dictionaries({}, optional=kwargs).map(_as_config)
69+
return st.fixed_dictionaries({}, optional=kwargs).map(_as_config) # type: ignore
7070

7171

7272
st.register_type_strategy(isort.Config, configs())

‎tests/integration/test_projects_using_isort.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
It is important to isort that as few regressions as possible are experienced by our users.
77
Having your project tested here is the most sure way to keep those regressions form ever happening.
88
"""
9+
from __future__ import annotations
10+
911
from pathlib import Path
1012
from subprocess import check_call
11-
from typing import Sequence
13+
from typing import Generator, Sequence
1214

1315
from isort.main import main
1416

@@ -18,7 +20,7 @@ def git_clone(repository_url: str, directory: Path):
1820
check_call(["git", "clone", "--depth", "1", repository_url, str(directory)])
1921

2022

21-
def run_isort(arguments: Sequence[str]):
23+
def run_isort(arguments: Generator[str, None, None] | Sequence[str]):
2224
"""Runs isort in diff and check mode with the given arguments"""
2325
main(["--check-only", "--diff", *arguments])
2426

‎tests/integration/test_setting_combinations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def configs() -> st.SearchStrategy[isort.Config]:
6161
"py_version": st.sampled_from(("auto",) + isort.settings.VALID_PY_TARGETS),
6262
}
6363
kwargs = {**inferred_kwargs, **specific}
64-
return st.fixed_dictionaries({}, optional=kwargs).map(_as_config)
64+
return st.fixed_dictionaries({}, optional=kwargs).map(_as_config) # type:ignore
6565

6666

6767
st.register_type_strategy(isort.Config, configs())

‎tests/unit/test_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_colored_printer_diff_output(capsys):
105105
def test_colorama_not_available_handled_gracefully(capsys):
106106
with pytest.raises(SystemExit) as system_exit:
107107
_ = isort.format.create_terminal_printer(color=True)
108-
assert system_exit.value.code > 0
108+
assert system_exit.value.code and int(system_exit.value.code) > 0
109109
_, err = capsys.readouterr()
110110
assert "colorama" in err
111111
assert "colors extra" in err

‎tests/unit/test_ticketed_features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def test_isort_should_warn_on_empty_custom_config_issue_1433(tmpdir):
617617
quiet = true
618618
"""
619619
)
620-
with pytest.warns(None) as warning:
620+
with pytest.warns(None) as warning: # type: ignore
621621
assert Config(settings_file=str(settings_file)).quiet
622622
assert not warning
623623

0 commit comments

Comments
 (0)
Please sign in to comment.