Skip to content

Commit

Permalink
More robust is_used for pre-commit (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjmcdougall authored Oct 24, 2024
1 parent 501f579 commit 8694c77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/usethis/_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ def get_associated_ruff_rules(self) -> list[str]:
raise NotImplementedError

def is_used(self) -> bool:
return (Path.cwd() / ".pre-commit-config.yaml").exists()
return (
any(is_dep_used(dep) for dep in self.dev_deps)
or (Path.cwd() / ".pre-commit-config.yaml").exists()
)


class DeptryTool(Tool):
Expand Down Expand Up @@ -229,7 +232,11 @@ def is_used(self) -> bool:
Path.cwd() / ".ruff.toml"
).exists()

return super().is_used() or is_pyproject_config or is_ruff_toml_config
return (
any(is_dep_used(dep) for dep in self.dev_deps)
or is_pyproject_config
or is_ruff_toml_config
)

def get_pre_commit_repo_config(self) -> PreCommitRepoConfig:
return PreCommitRepoConfig(
Expand Down

0 comments on commit 8694c77

Please sign in to comment.