22
33import ast
44from io import BytesIO , StringIO , TextIOWrapper
5+ from pathlib import Path
56
67import pytest
78
@@ -2036,7 +2037,9 @@ def test_check_code_should_not_false_positive_with_float_to_top_and_add_imports(
20362037 "# isort: off\n import z\n import a\n # isort: on\n " ,
20372038 ],
20382039)
2039- def test_float_to_top_check_accepts_unchanged_sections_issue_2681 (line_ending , boundary ):
2040+ def test_float_to_top_check_accepts_unchanged_sections_issue_2681 (
2041+ line_ending : str , boundary : str
2042+ ) -> None :
20402043 source = ("import os\n \n " + boundary + "\n import sys\n " ).replace ("\n " , line_ending )
20412044
20422045 assert isort .code (source , float_to_top = True ) == source
@@ -2045,7 +2048,9 @@ def test_float_to_top_check_accepts_unchanged_sections_issue_2681(line_ending, b
20452048
20462049@pytest .mark .parametrize ("line_ending" , ["\n " , "\r \n " ])
20472050@pytest .mark .parametrize ("blank_lines" , [0 , 1 , 3 ])
2048- def test_float_to_top_preserves_boundary_spacing_issue_2681 (line_ending , blank_lines ):
2051+ def test_float_to_top_preserves_boundary_spacing_issue_2681 (
2052+ line_ending : str , blank_lines : int
2053+ ) -> None :
20492054 source = ("import os\n " + "\n " * blank_lines + "# isort: split\n " ).replace ("\n " , line_ending )
20502055 result = _float_to_top (StringIO (source ), [], isort .Config (float_to_top = True ), "py" )
20512056
@@ -2054,7 +2059,7 @@ def test_float_to_top_preserves_boundary_spacing_issue_2681(line_ending, blank_l
20542059
20552060
20562061@pytest .mark .parametrize ("line_ending" , ["\n " , "\r \n " ])
2057- def test_float_to_top_check_detects_unsorted_sections_issue_2681 (line_ending ) :
2062+ def test_float_to_top_check_detects_unsorted_sections_issue_2681 (line_ending : str ) -> None :
20582063 source = "import sys\n import os\n \n # isort: split\n \n import a\n " .replace ("\n " , line_ending )
20592064 expected = "import os\n import sys\n \n # isort: split\n \n import a\n " .replace ("\n " , line_ending )
20602065
@@ -2064,7 +2069,7 @@ def test_float_to_top_check_detects_unsorted_sections_issue_2681(line_ending):
20642069
20652070
20662071@pytest .mark .parametrize ("configured_ending" , ["\n " , "\r \n " ])
2067- def test_float_to_top_configured_line_ending_issue_2681 (configured_ending ) :
2072+ def test_float_to_top_configured_line_ending_issue_2681 (configured_ending : str ) -> None :
20682073 source = "import os\r \n \r \n # isort: split\r \n \r \n import sys\r \n "
20692074 expected = source .replace ("\r \n " , configured_ending )
20702075 result = isort .code (source , float_to_top = True , line_ending = configured_ending )
@@ -2073,7 +2078,7 @@ def test_float_to_top_configured_line_ending_issue_2681(configured_ending):
20732078 assert isort .check_code (result , float_to_top = True , line_ending = configured_ending )
20742079
20752080
2076- def test_float_to_top_cli_check_accepts_crlf_issue_2681 (tmp_path ) :
2081+ def test_float_to_top_cli_check_accepts_crlf_issue_2681 (tmp_path : Path ) -> None :
20772082 path = tmp_path / "example.py"
20782083 source = b"import os\r \n \r \n # isort: split\r \n \r \n import sys\r \n "
20792084 path .write_bytes (source )
0 commit comments