File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -127,8 +127,10 @@ def get_pyproject_content(pyproject_file_path: str) -> str:
127127# flake8: noqa: C901
128128def format_content (content_str : str , pyproject_file_path : str = "" ) -> str :
129129 pyproject_dict : dict = {}
130+ toml = None # type: ignore
131+
130132 try :
131- import tomllib as toml
133+ import tomllib as toml # type: ignore
132134 except ImportError :
133135 try :
134136 import toml # type: ignore
@@ -137,10 +139,11 @@ def format_content(content_str: str, pyproject_file_path: str = "") -> str:
137139 "The toml module is not installed and the configuration information cannot be obtained through"
138140 " pyproject.toml"
139141 )
140- else :
141- pyproject_content = get_pyproject_content (pyproject_file_path )
142- if pyproject_content :
143- pyproject_dict = toml .loads (pyproject_content )
142+
143+ if toml :
144+ pyproject_content = get_pyproject_content (pyproject_file_path )
145+ if pyproject_content :
146+ pyproject_dict = toml .loads (pyproject_content )
144147 try :
145148 p2p_format_dict : dict = pyproject_dict ["tool" ]["protobuf-to-pydantic" ]["format" ]
146149 except KeyError :
You can’t perform that action at this time.
0 commit comments