Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ rules.possibly-missing-attribute = "ignore"
ignore = [ "src/usethis/_version.py" ]
reportAny = false
reportAssignmentType = false
reportCallInDefaultInitializer = false
reportExplicitAny = false
reportImplicitStringConcatenation = false
reportMissingParameterType = false
Expand Down
16 changes: 10 additions & 6 deletions src/usethis/_ui/interface/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._ui.options import backend_opt, quiet_opt
from usethis._ui.options import (
author_email_opt,
author_name_opt,
author_overwrite_opt,
backend_opt,
quiet_opt,
)


def author(
name: str = typer.Option(..., "--name", help="Author name"),
email: str = typer.Option("", "--email", help="Author email"),
overwrite: bool = typer.Option(
False, "--overwrite", help="Overwrite any existing authors"
),
name: str = author_name_opt,
email: str = author_email_opt,
overwrite: bool = author_overwrite_opt,
quiet: bool = quiet_opt,
backend: BackendEnum = backend_opt,
) -> None:
Expand Down
6 changes: 2 additions & 4 deletions src/usethis/_ui/interface/browse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typer

from usethis._config import usethis_config
from usethis._ui.options import offline_opt, quiet_opt
from usethis._ui.options import browser_opt, offline_opt, quiet_opt

app = typer.Typer(
help="Visit important project-related web pages.", add_completion=False
Expand All @@ -12,9 +12,7 @@
def pypi(
package: str,
*,
browser: bool = typer.Option(
False, "--browser", help="Open the URL in the default web browser."
),
browser: bool = browser_opt,
offline: bool = offline_opt,
quiet: bool = quiet_opt,
) -> None:
Expand Down
19 changes: 10 additions & 9 deletions src/usethis/_ui/interface/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._ui.options import backend_opt, frozen_opt, offline_opt, quiet_opt
from usethis._ui.options import (
backend_opt,
ci_remove_opt,
frozen_opt,
matrix_python_opt,
offline_opt,
quiet_opt,
)

app = typer.Typer(
help="Add config for Continuous Integration (CI) pipelines.",
Expand All @@ -13,14 +20,8 @@

@app.command(help="Use Bitbucket Pipelines for CI.")
def bitbucket(
remove: bool = typer.Option(
False, "--remove", help="Remove Bitbucket Pipelines CI instead of adding it."
),
matrix_python: bool = typer.Option(
True,
"--matrix-python/--no-matrix-python",
help="Test against multiple Python versions.",
),
remove: bool = ci_remove_opt,
matrix_python: bool = matrix_python_opt,
offline: bool = offline_opt,
quiet: bool = quiet_opt,
frozen: bool = frozen_opt,
Expand Down
12 changes: 8 additions & 4 deletions src/usethis/_ui/interface/docstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._types.docstyle import DocStyleEnum
from usethis._ui.options import backend_opt, frozen_opt, offline_opt, quiet_opt
from usethis._ui.options import (
backend_opt,
docstyle_style_arg,
frozen_opt,
offline_opt,
quiet_opt,
)


def docstyle(
style: DocStyleEnum = typer.Argument(
default="google", help="Docstring style to enforce."
),
style: DocStyleEnum = docstyle_style_arg,
offline: bool = offline_opt,
quiet: bool = quiet_opt,
frozen: bool = frozen_opt,
Expand Down
82 changes: 30 additions & 52 deletions src/usethis/_ui/interface/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,43 @@
from usethis._types.ci import CIServiceEnum
from usethis._types.docstyle import DocStyleEnum
from usethis._types.status import DevelopmentStatusEnum
from usethis._ui.options import backend_opt, frozen_opt, offline_opt, quiet_opt
from usethis._ui.options import (
backend_opt,
frozen_opt,
init_arch_opt,
init_ci_opt,
init_doc_opt,
init_docstyle_opt,
init_format_opt,
init_hook_opt,
init_lint_opt,
init_path_arg,
init_spellcheck_opt,
init_status_opt,
init_test_opt,
init_typecheck_opt,
offline_opt,
quiet_opt,
)


def init(
arch: bool = typer.Option(
False, "--arch/--no-arch", help="Add recommended architecture analysis tools."
),
doc: bool = typer.Option(
True, "--doc/--no-doc", help="Add a recommended documentation framework."
),
format_: bool = typer.Option(
True, "--format/--no-format", help="Add recommended formatters."
),
lint: bool = typer.Option(
True, "--lint/--no-lint", help="Add recommended linters."
),
spellcheck: bool = typer.Option(
True,
"--spellcheck/--no-spellcheck",
help="Add a recommended spellchecker.",
),
test: bool = typer.Option(
True,
"--test/--no-test",
help="Add a recommended testing framework.",
),
typecheck: bool = typer.Option(
True,
"--typecheck/--no-typecheck",
help="Add a recommended type checker.",
),
hook: bool = typer.Option(
False,
"--hook/--no-hook",
help="Add a recommended git hook framework.",
),
ci: CIServiceEnum | None = typer.Option(
None,
"--ci",
help="Add a CI service configuration.",
),
docstyle: DocStyleEnum | None = typer.Option(
None,
"--docstyle",
help="Set a docstring style convention for the project.",
),
status: DevelopmentStatusEnum = typer.Option(
"planning",
"--status",
help="Set the development status of the project.",
),
arch: bool = init_arch_opt,
doc: bool = init_doc_opt,
format_: bool = init_format_opt,
lint: bool = init_lint_opt,
spellcheck: bool = init_spellcheck_opt,
test: bool = init_test_opt,
typecheck: bool = init_typecheck_opt,
hook: bool = init_hook_opt,
ci: CIServiceEnum | None = init_ci_opt,
docstyle: DocStyleEnum | None = init_docstyle_opt,
status: DevelopmentStatusEnum = init_status_opt,
offline: bool = offline_opt,
quiet: bool = quiet_opt,
frozen: bool = frozen_opt,
backend: BackendEnum = backend_opt,
path: str | None = typer.Argument(
None,
help="The path to use for the project. Defaults to the current working directory.",
),
path: str | None = init_path_arg,
) -> None:
"""Initialize a new project with recommended tooling."""
from usethis._config_file import files_manager
Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_ui/interface/readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._ui.options import backend_opt, quiet_opt
from usethis._ui.options import backend_opt, badges_opt, quiet_opt


def readme(
quiet: bool = quiet_opt,
backend: BackendEnum = backend_opt,
badges: bool = typer.Option(False, "--badges", help="Add relevant badges"),
badges: bool = badges_opt,
) -> None:
from usethis._backend.uv.detect import is_uv_used
from usethis._config_file import files_manager
Expand Down
6 changes: 2 additions & 4 deletions src/usethis/_ui/interface/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._types.status import DevelopmentStatusEnum
from usethis._ui.options import backend_opt, quiet_opt
from usethis._ui.options import backend_opt, quiet_opt, status_arg


def status(
status: DevelopmentStatusEnum = typer.Argument(
default=..., help="Docstring style to enforce."
),
status: DevelopmentStatusEnum = status_arg,
quiet: bool = quiet_opt,
backend: BackendEnum = backend_opt,
) -> None:
Expand Down
14 changes: 4 additions & 10 deletions src/usethis/_ui/interface/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
from usethis._types.backend import BackendEnum
from usethis._ui.options import (
backend_opt,
formatter_opt,
frozen_opt,
how_opt,
linter_opt,
offline_opt,
quiet_opt,
remove_opt,
Expand Down Expand Up @@ -306,16 +308,8 @@ def ruff(
quiet: bool = quiet_opt,
frozen: bool = frozen_opt,
backend: BackendEnum = backend_opt,
linter: bool = typer.Option(
True,
"--linter/--no-linter",
help="Add or remove specifically the Ruff linter.",
),
formatter: bool = typer.Option(
True,
"--formatter/--no-formatter",
help="Add or remove specifically the Ruff formatter.",
),
linter: bool = linter_opt,
formatter: bool = formatter_opt,
) -> None:
from usethis._config_file import files_manager
from usethis._core.tool import use_ruff
Expand Down
97 changes: 97 additions & 0 deletions src/usethis/_ui/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
REMOVE_DEFAULT,
)

# shared options
offline_opt = typer.Option(OFFLINE_DEFAULT, "--offline", help="Disable network access")
quiet_opt = typer.Option(QUIET_DEFAULT, "--quiet", help="Suppress output")
how_opt = typer.Option(
Expand All @@ -27,3 +28,99 @@
backend_opt = typer.Option(
BACKEND_DEFAULT, "--backend", help="Package manager backend to use."
)

# author command options
author_name_opt = typer.Option(..., "--name", help="Author name")
author_email_opt = typer.Option("", "--email", help="Author email")
author_overwrite_opt = typer.Option(
False, "--overwrite", help="Overwrite any existing authors"
)

# browse command options
browser_opt = typer.Option(
False, "--browser", help="Open the URL in the default web browser."
)

# ci command options
ci_remove_opt = typer.Option(
False, "--remove", help="Remove Bitbucket Pipelines CI instead of adding it."
)
matrix_python_opt = typer.Option(
True,
"--matrix-python/--no-matrix-python",
help="Test against multiple Python versions.",
)

# docstyle command options
docstyle_style_arg = typer.Argument(
default="google", help="Docstring style to enforce."
)

# init command options
init_arch_opt = typer.Option(
False, "--arch/--no-arch", help="Add recommended architecture analysis tools."
)
init_doc_opt = typer.Option(
True, "--doc/--no-doc", help="Add a recommended documentation framework."
)
init_format_opt = typer.Option(
True, "--format/--no-format", help="Add recommended formatters."
)
init_lint_opt = typer.Option(True, "--lint/--no-lint", help="Add recommended linters.")
init_spellcheck_opt = typer.Option(
True,
"--spellcheck/--no-spellcheck",
help="Add a recommended spellchecker.",
)
init_test_opt = typer.Option(
True,
"--test/--no-test",
help="Add a recommended testing framework.",
)
init_typecheck_opt = typer.Option(
True,
"--typecheck/--no-typecheck",
help="Add a recommended type checker.",
)
init_hook_opt = typer.Option(
False,
"--hook/--no-hook",
help="Add a recommended git hook framework.",
)
init_ci_opt = typer.Option(
None,
"--ci",
help="Add a CI service configuration.",
)
init_docstyle_opt = typer.Option(
None,
"--docstyle",
help="Set a docstring style convention for the project.",
)
init_status_opt = typer.Option(
"planning",
"--status",
help="Set the development status of the project.",
)
init_path_arg = typer.Argument(
None,
help="The path to use for the project. Defaults to the current working directory.",
)

# readme command options
badges_opt = typer.Option(False, "--badges", help="Add relevant badges")

# status command options
status_arg = typer.Argument(default=..., help="Docstring style to enforce.")

# ruff command options
linter_opt = typer.Option(
True,
"--linter/--no-linter",
help="Add or remove specifically the Ruff linter.",
)
formatter_opt = typer.Option(
True,
"--formatter/--no-formatter",
help="Add or remove specifically the Ruff formatter.",
)
Loading