77import tokenize
88from pathlib import Path
99
10- from pydocstringformatter import __version__ , formatting , utils
10+ from pydocstringformatter import __version__ , _utils , formatting
1111from pydocstringformatter ._configuration .arguments_manager import ArgumentsManager
1212
1313
@@ -34,21 +34,21 @@ def __init__(self, argv: list[str] | None) -> None:
3434 # pylint: disable-next=inconsistent-return-statements
3535 def _check_files (self , files : list [str ]) -> None :
3636 """Find all files and perform the formatting."""
37- filepaths = utils ._find_python_files (files , self .config .exclude )
37+ filepaths = _utils ._find_python_files (files , self .config .exclude )
3838
3939 is_changed = self ._format_files (filepaths )
4040
4141 if is_changed : # pylint: disable=consider-using-assignment-expr
42- return utils ._sys_exit (32 , self .config .exit_code )
42+ return _utils ._sys_exit (32 , self .config .exit_code )
4343
4444 files_string = f"{ len (filepaths )} "
4545 files_string += "files" if len (filepaths ) != 1 else "file"
46- utils ._print_to_console (
46+ _utils ._print_to_console (
4747 f"Nothing to do! All docstrings in { files_string } are correct 🎉\n " ,
4848 self .config .quiet ,
4949 )
5050
51- utils ._sys_exit (0 , self .config .exit_code )
51+ _utils ._sys_exit (0 , self .config .exit_code )
5252
5353 def _format_file (self , filename : Path ) -> bool :
5454 """Format a file."""
@@ -59,7 +59,7 @@ def _format_file(self, filename: Path) -> bool:
5959 try :
6060 tokens = list (tokenize .generate_tokens (file .readline ))
6161 except tokenize .TokenError as exc :
62- raise utils .ParsingError (
62+ raise _utils .ParsingError (
6363 f"Can't parse { os .path .relpath (filename )} . Is it valid Python code?"
6464 ) from exc
6565 # Record type of newlines so we can make sure to use
@@ -69,7 +69,7 @@ def _format_file(self, filename: Path) -> bool:
6969 for index , tokeninfo in enumerate (tokens ):
7070 new_tokeninfo = tokeninfo
7171
72- if utils ._is_docstring (new_tokeninfo , tokens [index - 1 ]):
72+ if _utils ._is_docstring (new_tokeninfo , tokens [index - 1 ]):
7373 for formatter in formatting .FORMATTERS :
7474 if getattr (self .config , formatter .name ):
7575 new_tokeninfo = formatter .treat_token (new_tokeninfo )
@@ -96,12 +96,12 @@ def _format_file(self, filename: Path) -> bool:
9696 )
9797 with open (filename , "w" , encoding = "utf-8" , newline = newlines ) as file :
9898 file .write (tokenize .untokenize (changed_tokens ))
99- utils ._print_to_console (
99+ _utils ._print_to_console (
100100 f"Formatted { filename_str } 📖\n " , self .config .quiet
101101 )
102102 else :
103103 sys .stdout .write (
104- utils ._generate_diff (
104+ _utils ._generate_diff (
105105 tokenize .untokenize (tokens ),
106106 tokenize .untokenize (changed_tokens ),
107107 filename_str ,
0 commit comments