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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ repos:
- id: pyproject-fmt
args: [--max-supported-python=3.14]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.5
rev: v0.14.3
hooks:
- id: ruff
- id: ruff-check
args: [ --fix ]
- id: ruff-format
- repo: local
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dev = [
"jinja2>=3.1.6",
"prek>=0.2.4",
"pyright[nodejs]>=1.1.399",
"ruff>=0.11.5",
"ruff>=0.14.3",
]
test = [
"click>=8.1.8",
Expand All @@ -80,6 +80,11 @@ doc = [
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.sdist]
exclude = [
"ruff.toml",
]

[tool.hatch.metadata.hooks.vcs.urls]
"Source Code" = "https://github.com/usethis-python/usethis-python"
"Documentation" = "https://usethis.readthedocs.io/en/stable/"
Expand Down Expand Up @@ -112,6 +117,7 @@ lint.select = [
"FURB",
"I",
"INP",
"PLC0415",
"PLE",
"PLR",
"PT",
Expand All @@ -123,7 +129,7 @@ lint.select = [
"UP",
]
lint.ignore = [ "PLR2004", "S101", "SIM108" ]
lint.per-file-ignores."!tests/**/*.py" = [ "ARG002" ]
lint.per-file-ignores."!tests/**/*.py" = [ "ARG002", "PT" ]
lint.per-file-ignores."tests/**/*.py" = [ "D", "INP", "S603", "TC" ]
lint.flake8-bugbear.extend-immutable-calls = [ "typer.Argument", "typer.Option" ]

Expand Down
39 changes: 20 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -836,25 +836,26 @@ ruamel-yaml-clib==0.2.12 ; python_full_version < '3.14' and platform_python_impl
--hash=sha256:f66efbc1caa63c088dead1c4170d148eabc9b80d95fb75b6c92ac0aad2437d76 \
--hash=sha256:fd5415dded15c3822597455bc02bcd66e81ef8b7a48cb71a33628fc9fdde39df
# via ruamel-yaml
ruff==0.11.5 \
--hash=sha256:0947c0a1afa75dcb5db4b34b070ec2bccee869d40e6cc8ab25aca11a7d527794 \
--hash=sha256:2561294e108eb648e50f210671cc56aee590fb6167b594144401532138c66c7b \
--hash=sha256:3068befab73620b8a0cc2431bd46b3cd619bc17d6f7695a3e1bb166b652c382a \
--hash=sha256:4bfd80a6ec559a5eeb96c33f832418bf0fb96752de0539905cf7b0cc1d31d779 \
--hash=sha256:56145ee1478582f61c08f21076dc59153310d606ad663acc00ea3ab5b2125f82 \
--hash=sha256:67e241b4314f4eacf14a601d586026a962f4002a475aa702c69980a38087aa4e \
--hash=sha256:6c6dc38af3cfe2863213ea25b6dc616d679205732dc0fb673356c2d69608f800 \
--hash=sha256:80b4df4d335a80315ab9afc81ed1cff62be112bd165e162b5eed8ac55bfc8470 \
--hash=sha256:81be52e7519f3d1a0beadcf8e974715b2dfc808ae8ec729ecfc79bddf8dbb783 \
--hash=sha256:ac12884b9e005c12d0bd121f56ccf8033e1614f736f766c118ad60780882a077 \
--hash=sha256:ad871ff74b5ec9caa66cb725b85d4ef89b53f8170f47c3406e32ef040400b038 \
--hash=sha256:b2a7cedf47244f431fd11aa5a7e2806dda2e0c365873bda7834e8f7d785ae159 \
--hash=sha256:cae2e2439cb88853e421901ec040a758960b576126dab520fa08e9de431d1bef \
--hash=sha256:e268da7b40f56e3eca571508a7e567e794f9bfcc0f412c4b607931d3af9c4afe \
--hash=sha256:e5f66f8f1e8c9fc594cbd66fbc5f246a8d91f916cb9667e80208663ec3728304 \
--hash=sha256:e6cf918390cfe46d240732d4d72fa6e18e528ca1f60e318a10835cf2fa3dc19f \
--hash=sha256:ef39f19cb8ec98cbc762344921e216f3857a06c47412030374fffd413fb8fd3a \
--hash=sha256:f5da2e710a9641828e09aa98b92c9ebbc60518fdf3921241326ca3e8f8e55b8b
ruff==0.14.3 \
--hash=sha256:0e2f8a0bbcffcfd895df39c9a4ecd59bb80dca03dc43f7fb63e647ed176b741e \
--hash=sha256:1ec1ac071e7e37e0221d2f2dbaf90897a988c531a8592a6a5959f0603a1ecf5e \
--hash=sha256:26eb477ede6d399d898791d01961e16b86f02bc2486d0d1a7a9bb2379d055dc1 \
--hash=sha256:3d6bc90307c469cb9d28b7cfad90aaa600b10d67c6e22026869f585e1e8a2db0 \
--hash=sha256:469e35872a09c0e45fecf48dd960bfbce056b5db2d5e6b50eca329b4f853ae20 \
--hash=sha256:4ff876d2ab2b161b6de0aa1f5bd714e8e9b4033dc122ee006925fbacc4f62153 \
--hash=sha256:678fdd7c7d2d94851597c23ee6336d25f9930b460b55f8598e011b57c74fd8c5 \
--hash=sha256:71ff6edca490c308f083156938c0c1a66907151263c4abdcb588602c6e696a14 \
--hash=sha256:786ee3ce6139772ff9272aaf43296d975c0217ee1b97538a98171bf0d21f87ed \
--hash=sha256:7bfc42f81862749a7136267a343990f865e71fe2f99cf8d2958f684d23ce3dfa \
--hash=sha256:876b21e6c824f519446715c1342b8e60f97f93264012de9d8d10314f8a79c371 \
--hash=sha256:a497ec0c3d2c88561b6d90f9c29f5ae68221ac00d471f306fa21fa4264ce5fcd \
--hash=sha256:a65e448cfd7e9c59fae8cf37f9221585d3354febaad9a07f29158af1528e165f \
--hash=sha256:afcdc4b5335ef440d19e7df9e8ae2ad9f749352190e96d481dc501b753f0733e \
--hash=sha256:b6fd8c79b457bedd2abf2702b9b472147cd860ed7855c73a5247fa55c9117654 \
--hash=sha256:cd6291d0061811c52b8e392f946889916757610d45d004e41140d81fb6cd5ddc \
--hash=sha256:d7b7006ac0756306db212fd37116cce2bd307e1e109375e1c6c106002df0ae5f \
--hash=sha256:e231e1be58fc568950a04fbe6887c8e4b85310e7889727e2b81db205c45059eb \
--hash=sha256:f3d91857d023ba93e14ed2d462ab62c3428f9bbf2b4fbac50a03ca66d31991f7
shellingham==1.5.4 \
--hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686 \
--hash=sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de
Expand Down
5 changes: 3 additions & 2 deletions src/usethis/_core/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ def use_requirements_txt(*, remove: bool = False, how: bool = False) -> None:
tick_print("Writing 'requirements.txt'.")
with open(path, "w", encoding="utf-8") as f:
f.write("-e .\n")
for dep in get_project_deps():
f.write(dep.to_requirement_string() + "\n")
f.writelines(
dep.to_requirement_string() + "\n" for dep in get_project_deps()
)
else:
assert_never(backend)

Expand Down
8 changes: 6 additions & 2 deletions src/usethis/_tool/impl/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def name(self) -> str:
return "Coverage.py"

def print_how_to_use(self) -> None:
from usethis._tool.impl.pytest import PytestTool
from usethis._tool.impl.pytest import ( # to avoid circularity; # noqa: PLC0415
PytestTool,
)

backend = get_backend()

Expand All @@ -52,7 +54,9 @@ def print_how_to_use(self) -> None:
how_print(f"Run 'coverage help' to see available {self.name} commands.")

def get_test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
from usethis._tool.impl.pytest import PytestTool
from usethis._tool.impl.pytest import ( # to avoid circularity; # noqa: PLC0415
PytestTool,
)

deps = [Dependency(name="coverage", extras=frozenset({"toml"}))]
if unconditional or PytestTool().is_used():
Expand Down
4 changes: 3 additions & 1 deletion src/usethis/_tool/impl/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def print_how_to_use(self) -> None:
how_print("Run 'pytest' to run the tests.")

def get_test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
from usethis._tool.impl.coverage_py import CoveragePyTool
from usethis._tool.impl.coverage_py import ( # to avoid circularity; # noqa: PLC0415
CoveragePyTool,
)

deps = [Dependency(name="pytest")]
if unconditional or CoveragePyTool().is_used():
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import typer

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

Expand All @@ -15,7 +16,6 @@ def author(
quiet: bool = quiet_opt,
backend: BackendEnum = backend_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.author import add_author
Expand Down
7 changes: 1 addition & 6 deletions src/usethis/_ui/interface/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import typer

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

if TYPE_CHECKING:
Expand All @@ -27,7 +28,6 @@ def pypi(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_pypi_badge

Expand All @@ -42,7 +42,6 @@ def ruff(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_ruff_badge

Expand All @@ -57,7 +56,6 @@ def pre_commit(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_pre_commit_badge

Expand All @@ -74,7 +72,6 @@ def socket(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_socket_badge

Expand All @@ -89,7 +86,6 @@ def usethis(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_usethis_badge

Expand All @@ -104,7 +100,6 @@ def uv(
quiet: bool = quiet_opt,
show: bool = show_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._core.badge import get_uv_badge

Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/browse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

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

app = typer.Typer(
Expand All @@ -17,7 +18,6 @@ def pypi(
offline: bool = offline_opt,
quiet: bool = quiet_opt,
) -> None:
from usethis._config import usethis_config
from usethis._console import err_print
from usethis._core.browse import browse_pypi
from usethis.errors import UsethisError
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/ci.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

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

Expand All @@ -18,7 +19,6 @@ def bitbucket(
frozen: bool = frozen_opt,
backend: BackendEnum = backend_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.ci import use_ci_bitbucket
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/doc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

from usethis._config import usethis_config
from usethis._ui.options import frozen_opt, how_opt, offline_opt, quiet_opt, remove_opt


Expand All @@ -11,7 +12,6 @@ def doc(
frozen: bool = frozen_opt,
) -> None:
"""Add a recommended documentation framework to the project."""
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._toolset.doc import use_doc_frameworks
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/docstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import typer

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
Expand All @@ -16,7 +17,6 @@ def docstyle(
frozen: bool = frozen_opt,
backend: BackendEnum = backend_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.docstyle import use_docstyle
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/format_.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._ui.options import (
backend_opt,
Expand All @@ -20,7 +21,6 @@ def format_( # noqa: PLR0913
backend: BackendEnum = backend_opt,
) -> None:
"""Add recommended formatters to the project."""
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._toolset.format_ import use_formatters
Expand Down
9 changes: 3 additions & 6 deletions src/usethis/_ui/interface/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from pathlib import Path

import typer
from typing_extensions import assert_never

from usethis._console import instruct_print
from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._types.ci import CIServiceEnum
from usethis._types.docstyle import DocStyleEnum
Expand Down Expand Up @@ -62,9 +63,8 @@ def init( # noqa: PLR0913
),
) -> None:
"""Initialize a new project with recommended tooling."""
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._console import err_print, instruct_print
from usethis.errors import UsethisError

assert isinstance(backend, BackendEnum)
Expand Down Expand Up @@ -115,9 +115,6 @@ def _init( # noqa: PLR0913, PLR0915
docstyle: DocStyleEnum | None,
status: DevelopmentStatusEnum,
):
from typing_extensions import assert_never

from usethis._config import usethis_config
from usethis._console import tick_print
from usethis._core.ci import print_how_to_use_ci_bitbucket, use_ci_bitbucket
from usethis._core.docstyle import use_docstyle
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/lint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

from usethis._config import usethis_config
from usethis._types.backend import BackendEnum
from usethis._ui.options import (
backend_opt,
Expand All @@ -20,7 +21,6 @@ def lint( # noqa: PLR0913
backend: BackendEnum = backend_opt,
) -> None:
"""Add recommended linters to the project."""
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._toolset.lint import use_linters
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import typer

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

Expand All @@ -11,7 +12,6 @@ def readme(
backend: BackendEnum = backend_opt,
badges: bool = typer.Option(False, "--badges", help="Add relevant badges"),
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.badge import (
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_ui/interface/rule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

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

Expand All @@ -19,7 +20,6 @@ def rule( # noqa: PLR0913
quiet: bool = quiet_opt,
backend: BackendEnum = backend_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.rule import (
Expand Down
3 changes: 1 addition & 2 deletions src/usethis/_ui/interface/show.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer

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

app = typer.Typer(
Expand All @@ -12,7 +13,6 @@ def name(
offline: bool = offline_opt,
quiet: bool = quiet_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.show import show_name
Expand All @@ -34,7 +34,6 @@ def sonarqube(
offline: bool = offline_opt,
quiet: bool = quiet_opt,
) -> None:
from usethis._config import usethis_config
from usethis._config_file import files_manager
from usethis._console import err_print
from usethis._core.show import show_sonarqube_config
Expand Down
Loading