Skip to content

Commit 9342c64

Browse files
author
Keppler, Kyle
committed
import tomllib
1 parent ac03ec7 commit 9342c64

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

protobuf_to_pydantic/util.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,19 @@ def get_pyproject_content(pyproject_file_path: str) -> str:
128128
def format_content(content_str: str, pyproject_file_path: str = "") -> str:
129129
pyproject_dict: dict = {}
130130
try:
131-
import toml # type: ignore
131+
import tomllib as toml
132132
except ImportError:
133-
logging.warning(
134-
"The toml module is not installed and the configuration information cannot be obtained through"
135-
" pyproject.toml"
136-
)
137-
else:
138-
pyproject_content = get_pyproject_content(pyproject_file_path)
139-
if pyproject_content:
140-
pyproject_dict = toml.loads(pyproject_content)
133+
try:
134+
import toml # type: ignore
135+
except ImportError:
136+
logging.warning(
137+
"The toml module is not installed and the configuration information cannot be obtained through"
138+
" pyproject.toml"
139+
)
140+
return content_str
141+
pyproject_content = get_pyproject_content(pyproject_file_path)
142+
if pyproject_content:
143+
pyproject_dict = toml.loads(pyproject_content)
141144
try:
142145
p2p_format_dict: dict = pyproject_dict["tool"]["protobuf-to-pydantic"]["format"]
143146
except KeyError:

0 commit comments

Comments
 (0)