Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

refactor(Init): use ternary operator #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v4-9-0-test
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def __call__(self) -> None:
out.success("Configuration complete 🚀")

def _ask_config_path(self) -> str:
default_path = ".cz.toml"
if self.project_info.has_pyproject:
default_path = "pyproject.toml"
default_path = (
"pyproject.toml" if self.project_info.has_pyproject else ".cz.toml"
)

name: str = questionary.select(
"Please choose a supported config file: ",
Expand Down Expand Up @@ -270,15 +270,13 @@ def _ask_version_provider(self) -> str:

def _ask_version_scheme(self) -> str:
"""Ask for setting: version_scheme"""
default = "semver"
if self.project_info.is_python:
default = "pep440"
default_scheme = "pep440" if self.project_info.is_python else "semver"

scheme: str = questionary.select(
"Choose version scheme: ",
choices=list(KNOWN_SCHEMES),
choices=KNOWN_SCHEMES,
style=self.cz.style,
default=default,
default=default_scheme,
).unsafe_ask()
return scheme

Expand Down Expand Up @@ -318,10 +316,9 @@ def _gen_pre_commit_cmd(self, hook_types: list[str]) -> str:
"""Generate pre-commit command according to given hook types"""
if not hook_types:
raise ValueError("At least 1 hook type should be provided.")
cmd_str = "pre-commit install " + " ".join(
return "pre-commit install " + " ".join(
f"--hook-type {ty}" for ty in hook_types
)
return cmd_str

def _install_pre_commit_hook(self, hook_types: list[str] | None = None) -> None:
pre_commit_config_filename = ".pre-commit-config.yaml"
Expand Down