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
12 changes: 6 additions & 6 deletions src/usethis/_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def files_manager() -> Iterator[None]:
with (
PyprojectTOMLManager(),
SetupCFGManager(),
CodespellRCManager(),
CoverageRCManager(),
CoverageRCTOMLManager(),
DotCodespellRCManager(),
DotCoverageRCManager(),
DotCoverageRCTOMLManager(),
DotRuffTOMLManager(),
DotPytestINIManager(),
DotImportLinterManager(),
Expand All @@ -35,23 +35,23 @@ def files_manager() -> Iterator[None]:
yield


class CodespellRCManager(INIFileManager):
class DotCodespellRCManager(INIFileManager):
"""Class to manage the .codespellrc file."""

@property
def relative_path(self) -> Path:
return Path(".codespellrc")


class CoverageRCManager(INIFileManager):
class DotCoverageRCManager(INIFileManager):
"""Class to manage the .coveragerc file."""

@property
def relative_path(self) -> Path:
return Path(".coveragerc")


class CoverageRCTOMLManager(TOMLFileManager):
class DotCoverageRCTOMLManager(TOMLFileManager):
"""Class to manage the .coveragerc.toml file."""

@property
Expand Down
6 changes: 3 additions & 3 deletions src/usethis/_tool/impl/codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing_extensions import assert_never

from usethis._config import usethis_config
from usethis._config_file import CodespellRCManager
from usethis._config_file import DotCodespellRCManager
from usethis._console import how_print
from usethis._integrations.backend.dispatch import get_backend
from usethis._integrations.backend.uv.used import is_uv_used
Expand Down Expand Up @@ -66,14 +66,14 @@ def get_dev_deps(self, *, unconditional: bool = False) -> list[Dependency]:
def preferred_file_manager(self) -> KeyValueFileManager:
if (usethis_config.cpd() / "pyproject.toml").exists():
return PyprojectTOMLManager()
return CodespellRCManager()
return DotCodespellRCManager()

def get_config_spec(self) -> ConfigSpec:
# https://github.com/codespell-project/codespell?tab=readme-ov-file#using-a-config-file

return ConfigSpec.from_flat(
file_managers=[
CodespellRCManager(),
DotCodespellRCManager(),
SetupCFGManager(),
PyprojectTOMLManager(),
],
Expand Down
10 changes: 5 additions & 5 deletions src/usethis/_tool/impl/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from usethis._config import usethis_config
from usethis._config_file import (
CoverageRCManager,
CoverageRCTOMLManager,
DotCoverageRCManager,
DotCoverageRCTOMLManager,
ToxINIManager,
)
from usethis._console import how_print
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_test_deps(self, *, unconditional: bool = False) -> list[Dependency]:
def preferred_file_manager(self) -> KeyValueFileManager:
if (usethis_config.cpd() / "pyproject.toml").exists():
return PyprojectTOMLManager()
return CoverageRCManager()
return DotCoverageRCManager()

def get_config_spec(self) -> ConfigSpec:
# https://coverage.readthedocs.io/en/latest/config.html#configuration-reference
Expand All @@ -94,8 +94,8 @@ def _get_source():

return ConfigSpec.from_flat(
file_managers=[
CoverageRCManager(),
CoverageRCTOMLManager(),
DotCoverageRCManager(),
DotCoverageRCTOMLManager(),
SetupCFGManager(),
ToxINIManager(),
PyprojectTOMLManager(),
Expand Down
4 changes: 2 additions & 2 deletions tests/usethis/_tool/impl/test_coverage_py.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from usethis._config_file import CoverageRCTOMLManager, files_manager
from usethis._config_file import DotCoverageRCTOMLManager, files_manager
from usethis._integrations.file.pyproject_toml.io_ import PyprojectTOMLManager
from usethis._test import change_cwd
from usethis._tool.impl.coverage_py import CoveragePyTool
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_coveragerc_toml_preferred_over_pyproject_toml(self, tmp_path: Path):

# Assert - config should be added to .coveragerc.toml
with change_cwd(tmp_path), files_manager():
assert ["run"] in CoverageRCTOMLManager()
assert ["run"] in DotCoverageRCTOMLManager()
content = (tmp_path / ".coveragerc.toml").read_text()
assert "[run]" in content
assert "[report]" in content
Expand Down