File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change 88from __future__ import annotations
99
1010import logging
11- from typing import TYPE_CHECKING
11+ from pathlib import Path
1212
1313import numpy as np
1414
1515from tfs .errors import TfsFormatError
1616from tfs .reader import read_tfs
1717from tfs .writer import write_tfs
1818
19- if TYPE_CHECKING :
20- from pathlib import Path
21-
2219LOGGER = logging .getLogger (__name__ )
2320
2421
@@ -88,8 +85,7 @@ def remove_header_comments_from_files(list_of_files: list[str | Path]) -> None:
8885 """
8986 for filepath in list_of_files :
9087 LOGGER .info (f"Checking file: { filepath } " )
91- with open (filepath ) as f :
92- f_lines = f .readlines ()
88+ f_lines = Path (filepath ).read_text ().splitlines (keepends = True )
9389
9490 delete_indicies = []
9591 for index , line in enumerate (f_lines ):
@@ -104,5 +100,4 @@ def remove_header_comments_from_files(list_of_files: list[str | Path]) -> None:
104100 deleted_line = f_lines .pop (index )
105101 LOGGER .info (f" Deleted line: { deleted_line .strip ():s} " )
106102
107- with open (filepath , "w" ) as f :
108- f .writelines (f_lines )
103+ Path (filepath ).write_text ("" .join (f_lines ))
Original file line number Diff line number Diff line change 1212import string
1313from types import NoneType
1414from typing import TYPE_CHECKING
15+
1516import numpy as np
1617from pandas .api import types as pdtypes
1718from pandas .io .common import get_handle
You can’t perform that action at this time.
0 commit comments