Skip to content

Commit f0fc425

Browse files
committed
fix(config): streamline multiple config files warning logic
1 parent f2c8e4f commit f0fc425

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

commitizen/config/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ def read_cfg(filepath: str | None = None) -> BaseConfig:
3838
config_candidates = list(_resolve_config_paths(filepath))
3939

4040
# Check for multiple config files and warn the user
41-
if filepath is None:
42-
config_candidates_exclude_pyproject = [
43-
path for path in config_candidates if path.name != "pyproject.toml"
44-
]
45-
if len(config_candidates_exclude_pyproject) > 1:
46-
filenames = [path.name for path in config_candidates_exclude_pyproject]
47-
out.warn(
48-
f"Multiple config files detected: {', '.join(filenames)}. "
49-
f"Using config file: '{filenames[0]}'."
50-
)
41+
config_candidates_exclude_pyproject = [
42+
path for path in config_candidates if path.name != "pyproject.toml"
43+
]
44+
if len(config_candidates_exclude_pyproject) > 1:
45+
filenames = [path.name for path in config_candidates_exclude_pyproject]
46+
out.warn(
47+
f"Multiple config files detected: {', '.join(filenames)}. "
48+
f"Using config file: '{filenames[0]}'."
49+
)
5150

5251
for filename in config_candidates:
5352
with open(filename, "rb") as f:

0 commit comments

Comments
 (0)