Skip to content

Commit f11a583

Browse files
Rename to managed pyproject keys instead of ID keys
1 parent f8c99db commit f11a583

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/usethis/_tool.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def get_managed_files(self) -> list[Path]:
9595
"""Get (relative) paths to files managed by the tool."""
9696
return []
9797

98-
def get_pyproject_id_keys(self) -> list[list[str]]:
98+
def get_managed_pyproject_keys(self) -> list[list[str]]:
9999
"""Get keys for any pyproject.toml sections only used by this tool (not shared)."""
100100
return []
101101

@@ -118,7 +118,7 @@ def is_used(self) -> bool:
118118
for file in self.get_managed_files():
119119
if file.exists() and file.is_file():
120120
return True
121-
for id_keys in self.get_pyproject_id_keys():
121+
for id_keys in self.get_managed_pyproject_keys():
122122
if do_id_keys_exist(id_keys):
123123
return True
124124
for dep in self.get_dev_deps(unconditional=True):
@@ -208,7 +208,7 @@ def remove_pyproject_configs(self) -> None:
208208
# Collect all keys to remove
209209
keys_to_remove = [
210210
config.id_keys for config in self.get_pyproject_configs()
211-
] + self.get_pyproject_id_keys()
211+
] + self.get_managed_pyproject_keys()
212212

213213
# Try to remove the first key to trigger the message
214214
first_removal = True
@@ -273,7 +273,7 @@ def get_pre_commit_repos(self) -> list[LocalRepo | UriRepo]:
273273
)
274274
]
275275

276-
def get_pyproject_id_keys(self) -> list[list[str]]:
276+
def get_managed_pyproject_keys(self) -> list[list[str]]:
277277
return [["tool", "codespell"]]
278278

279279
def get_managed_files(self) -> list[Path]:
@@ -335,7 +335,7 @@ def get_pyproject_configs(self) -> list[PyProjectConfig]:
335335
),
336336
]
337337

338-
def get_pyproject_id_keys(self) -> list[list[str]]:
338+
def get_managed_pyproject_keys(self) -> list[list[str]]:
339339
return [["tool", "coverage"]]
340340

341341
def get_managed_files(self) -> list[Path]:
@@ -372,7 +372,7 @@ def get_pre_commit_repos(self) -> list[LocalRepo | UriRepo]:
372372
)
373373
]
374374

375-
def get_pyproject_id_keys(self) -> list[list[str]]:
375+
def get_managed_pyproject_keys(self) -> list[list[str]]:
376376
return [["tool", "deptry"]]
377377

378378
def get_bitbucket_steps(self) -> list[BitbucketStep]:
@@ -453,7 +453,7 @@ def get_pyproject_configs(self) -> list[PyProjectConfig]:
453453
)
454454
]
455455

456-
def get_pyproject_id_keys(self) -> list[list[str]]:
456+
def get_managed_pyproject_keys(self) -> list[list[str]]:
457457
return [["tool", "pyproject-fmt"]]
458458

459459
def get_bitbucket_steps(self) -> list[BitbucketStep]:
@@ -535,7 +535,7 @@ def get_pyproject_configs(self) -> list[PyProjectConfig]:
535535
def get_associated_ruff_rules(self) -> list[str]:
536536
return ["PT"]
537537

538-
def get_pyproject_id_keys(self) -> list[list[str]]:
538+
def get_managed_pyproject_keys(self) -> list[list[str]]:
539539
return [["tool", "pytest"]]
540540

541541
def get_managed_files(self) -> list[Path]:
@@ -639,7 +639,7 @@ def get_pyproject_configs(self) -> list[PyProjectConfig]:
639639
)
640640
]
641641

642-
def get_pyproject_id_keys(self) -> list[list[str]]:
642+
def get_managed_pyproject_keys(self) -> list[list[str]]:
643643
return [["tool", "ruff"]]
644644

645645
def get_managed_files(self) -> list[Path]:

tests/usethis/test_usethis_tool.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_associated_ruff_rules(self) -> list[str]:
6969
def get_managed_files(self) -> list[Path]:
7070
return [Path("mytool-config.yaml")]
7171

72-
def get_pyproject_id_keys(self) -> list[list[str]]:
72+
def get_managed_pyproject_keys(self) -> list[list[str]]:
7373
return [["tool", self.name], ["project", "classifiers"]]
7474

7575

@@ -171,14 +171,14 @@ def test_specific(self):
171171
Path("mytool-config.yaml"),
172172
]
173173

174-
class TestGetPyprojectIdKeys:
174+
class TestManagedPyprojectKeys:
175175
def test_default(self):
176176
tool = DefaultTool()
177-
assert tool.get_pyproject_id_keys() == []
177+
assert tool.get_managed_pyproject_keys() == []
178178

179179
def test_specific(self):
180180
tool = MyTool()
181-
assert tool.get_pyproject_id_keys() == [
181+
assert tool.get_managed_pyproject_keys() == [
182182
["tool", "my_tool"],
183183
["project", "classifiers"],
184184
]
@@ -781,7 +781,7 @@ def test_get_pyproject_id_keys(self):
781781
tool = DeptryTool()
782782

783783
# Act
784-
result = tool.get_pyproject_id_keys()
784+
result = tool.get_managed_pyproject_keys()
785785

786786
# Assert
787787
assert result == [["tool", "deptry"]]
@@ -809,7 +809,7 @@ def test_config_keys_are_subkeys_of_id_keys(self):
809809
tool = DeptryTool()
810810

811811
# Act
812-
id_keys = tool.get_pyproject_id_keys()
812+
id_keys = tool.get_managed_pyproject_keys()
813813
configs = tool.get_pyproject_configs()
814814

815815
# Assert
@@ -823,7 +823,7 @@ def test_config_keys_are_subkeys_of_id_keys(self):
823823
@pytest.mark.parametrize("tool", ALL_TOOLS)
824824
def test_all_tools_config_keys_are_subkeys_of_id_keys(tool: Tool):
825825
"""Test that all tools' config keys are subkeys of their ID keys."""
826-
id_keys = tool.get_pyproject_id_keys()
826+
id_keys = tool.get_managed_pyproject_keys()
827827
configs = tool.get_pyproject_configs()
828828

829829
for config in configs:

0 commit comments

Comments
 (0)