Skip to content

Commit 31a0d16

Browse files
Add vulture for development and clean up dead code references (#1837)
* Add vulture for development and clean up dead code references Most of these are from CI implementations which are now removed. Also sneaking in a change in functionality where we will prefer to use poetry if available in the environment when uv isn't instead of using the None backend and pyproject.toml doesn't exist. Solves #1816 and solves #1836 * Rename by removing underscore `_get_yaml_document` -> `get_yaml_document` Add docstring * Revert bad change to Poetry detection * Fix broken references in tests
1 parent 5d57925 commit 31a0d16

119 files changed

Lines changed: 447 additions & 1215 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.importlinter

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type = layers
1313
containers =
1414
usethis
1515
layers =
16-
_test | __main__
16+
__main__
1717
_ui
1818
_toolset
1919
_core
@@ -111,8 +111,7 @@ type = layers
111111
containers =
112112
usethis._integrations
113113
layers =
114-
ci | pre_commit
115-
environ
114+
pre_commit
116115
mkdocs | pytest | pydantic | sonarqube
117116
project | readme
118117
exhaustive = true
@@ -149,12 +148,3 @@ layers =
149148
result
150149
containers | ops
151150
exhaustive = true
152-
153-
[importlinter:contract:integrations_ci]
154-
name = usethis._integrations.ci
155-
type = layers
156-
containers =
157-
usethis._integrations.ci
158-
layers =
159-
github
160-
exhaustive = true

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ repos:
6161
additional_dependencies:
6262
- tomli
6363
priority: 0
64+
- repo: https://github.com/jendrikseipp/vulture
65+
rev: v2.16
66+
hooks:
67+
- id: vulture
68+
priority: 0
6469
- repo: local
6570
hooks:
6671
- id: check-skills-documented

AGENTS.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ usethis # usethis: Automatically manage Python tooling
1818
├── _fallback # Central module for hard-coded fallback version constants.
1919
├── _init # Project initialization and build system setup.
2020
├── _subprocess # Subprocess invocation utilities.
21-
├── _test # Test utilities and fixtures for the usethis test suite.
2221
├── errors # Custom errors for the usethis package.
2322
├── _backend # Backend dispatch and tool-specific backend implementations.
2423
│ ├── dispatch # Backend selection and dispatch logic.
@@ -38,9 +37,7 @@ usethis # usethis: Automatically manage Python tooling
3837
│ ├── init # Project initialization via uv.
3938
│ ├── link_mode # Symlink link-mode configuration for uv.
4039
│ ├── lockfile # Lock file creation and management for uv.
41-
│ ├── python # Python version queries via uv.
42-
│ ├── toml # Manager for the uv.toml configuration file.
43-
│ └── version # Retrieve the installed uv version.
40+
│ └── toml # Manager for the uv.toml configuration file.
4441
├── _core # Core business logic for usethis commands.
4542
│ ├── author # Author metadata management for pyproject.toml.
4643
│ ├── badge # README badge generation and management.
@@ -70,7 +67,6 @@ usethis # usethis: Automatically manage Python tooling
7067
│ │ ├── io_ # pyproject.toml file I/O manager.
7168
│ │ ├── name # Project name and description extraction from pyproject.toml.
7269
│ │ ├── project # Access the [project] section of pyproject.toml.
73-
│ │ ├── remove # Removal of the pyproject.toml file.
7470
│ │ ├── requires_python # Python version requirement queries from pyproject.toml.
7571
│ │ ├── valid # Validation and repair of pyproject.toml structure.
7672
│ │ └── write # Preparation helpers for writing pyproject.toml via subprocesses.
@@ -86,12 +82,6 @@ usethis # usethis: Automatically manage Python tooling
8682
│ ├── typing_ # Type aliases for YAML document values.
8783
│ └── update # Smart update strategies for YAML sequences and mappings.
8884
├── _integrations # Third-party tool integrations.
89-
│ ├── ci # CI platform integrations.
90-
│ │ └── github # GitHub CI integration.
91-
│ │ ├── errors # Error types for GitHub CI operations.
92-
│ │ └── tags # GitHub repository tag fetching.
93-
│ ├── environ # Environment detection utilities.
94-
│ │ └── python # Python version environment queries.
9585
│ ├── mkdocs # MkDocs documentation integration.
9686
│ │ └── core # MkDocs project setup and configuration.
9787
│ ├── pre_commit # Pre-commit hook framework integration.
@@ -236,11 +226,6 @@ ALWAYS check whether an existing function already covers your use case before im
236226
- `ensure_pyproject_toml_via_uv()` (`usethis._backend.uv.init`) — Create a pyproject.toml file using `uv init --bare`.
237227
- `ensure_symlink_mode()` (`usethis._backend.uv.link_mode`) — Ensure that the symlink link mode is enabled.
238228
- `ensure_uv_lock()` (`usethis._backend.uv.lockfile`) — Ensure a uv.lock file exists, creating it if necessary.
239-
- `get_available_uv_python_versions()` (`usethis._backend.uv.python`) — Get the set of Python versions available via uv.
240-
- `get_supported_uv_minor_python_versions()` (`usethis._backend.uv.python`) — Get the minor Python versions supported by the project and available via uv.
241-
- `uv_python_pin()` (`usethis._backend.uv.python`) — Pin the Python version for the project using uv.
242-
- `get_uv_version()` (`usethis._backend.uv.version`) — Get the version string of the installed uv tool.
243-
- `next_breaking_uv_version()` (`usethis._backend.uv.version`) — Get the next breaking version for a uv version string, following semver.
244229
- `files_manager()` (`usethis._config_file`) — Context manager that opens all configuration file managers for coordinated I/O.
245230
- `plain_print()` (`usethis._console`) — Print a plain message to the console, respecting quiet and alert-only settings.
246231
- `table_print()` (`usethis._console`) — Print a Rich table to the console, respecting quiet and alert-only settings.
@@ -294,7 +279,6 @@ ALWAYS check whether an existing function already covers your use case before im
294279
- `use_ruff()` (`usethis._core.tool`) — Add Ruff to the project.
295280
- `use_tach()` (`usethis._core.tool`) — Add and configure the Tach architecture enforcement tool.
296281
- `use_ty()` (`usethis._core.tool`) — Add and configure the ty type checker tool.
297-
- `use_tool()` (`usethis._core.tool`) — General dispatch function to add or remove a tool to/from the project.
298282
- `get_project_deps()` (`usethis._deps`) — Get all project dependencies.
299283
- `get_dep_groups()` (`usethis._deps`) — Get all dependency groups from pyproject.toml.
300284
- `get_deps_from_group()` (`usethis._deps`) — Get the list of dependencies in a named dependency group.
@@ -319,21 +303,17 @@ ALWAYS check whether an existing function already covers your use case before im
319303
- `get_name()` (`usethis._file.pyproject_toml.name`) — Get the project name from pyproject.toml.
320304
- `get_description()` (`usethis._file.pyproject_toml.name`) — Get the project description from pyproject.toml.
321305
- `get_project_dict()` (`usethis._file.pyproject_toml.project`) — Get the contents of the [project] section from pyproject.toml.
322-
- `remove_pyproject_toml()` (`usethis._file.pyproject_toml.remove`) — Remove the pyproject.toml file from the project.
323306
- `get_requires_python()` (`usethis._file.pyproject_toml.requires_python`) — Get the requires-python constraint from pyproject.toml.
324307
- `get_required_minor_python_versions()` (`usethis._file.pyproject_toml.requires_python`) — Get Python minor versions that match the project's requires-python constraint.
325308
- `ensure_pyproject_validity()` (`usethis._file.pyproject_toml.valid`) — Ensure pyproject.toml has a valid structure, adding missing required fields.
326309
- `prepare_pyproject_write()` (`usethis._file.pyproject_toml.write`) — Prepare the pyproject.toml file for a subprocess that will modify it.
327-
- `edit_yaml()` (`usethis._file.yaml.io_`) — A context manager to modify a YAML file in-place, with managed read and write.
328-
- `read_yaml()` (`usethis._file.yaml.io_`) — A context manager to read a YAML file.
310+
- `get_yaml_document()` (`usethis._file.yaml.io_`) — Get a YAML document representation from a string or file-like object.
329311
- `update_ruamel_yaml_map()` (`usethis._file.yaml.update`) — Update the values of a ruamel.yaml map in-place using a diff-like algorithm.
330312
- `lcs_list_update()` (`usethis._file.yaml.update`) — Update in-place using a longest common subsequence solver.
331313
- `project_init()` (`usethis._init`) — Initialize the project by creating the pyproject.toml and project structure.
332314
- `write_simple_requirements_txt()` (`usethis._init`) — Write a simple requirements.txt file with -e . and any project dependencies.
333315
- `ensure_dep_declaration_file()` (`usethis._init`) — Ensure that the file where dependencies are declared exists, if necessary.
334316
- `ensure_pyproject_toml()` (`usethis._init`) — Ensure that a pyproject.toml file exists, creating it if necessary.
335-
- `get_github_latest_tag()` (`usethis._integrations.ci.github.tags`) — Get the name of the most recent tag on the default branch of a GitHub repository.
336-
- `get_supported_minor_python_versions()` (`usethis._integrations.environ.python`) — Get supported Python versions for the current backend.
337317
- `add_docs_dir()` (`usethis._integrations.mkdocs.core`) — Create the `docs` directory and a `docs/index.md` file if they do not exist.
338318
- `remove_pre_commit_config()` (`usethis._integrations.pre_commit.core`) — Remove the .pre-commit-config.yaml file from the project.
339319
- `install_pre_commit_hooks()` (`usethis._integrations.pre_commit.core`) — Install pre-commit hooks.
@@ -344,11 +324,9 @@ ALWAYS check whether an existing function already covers your use case before im
344324
- `remove_hook()` (`usethis._integrations.pre_commit.hooks`) — Remove pre-commit hook configuration.
345325
- `get_hook_ids()` (`usethis._integrations.pre_commit.hooks`) — Get the list of hook IDs currently configured in the pre-commit configuration file.
346326
- `extract_hook_ids()` (`usethis._integrations.pre_commit.hooks`) — Extract all hook IDs from a pre-commit configuration model.
347-
- `hooks_are_equivalent()` (`usethis._integrations.pre_commit.hooks`) — Check if two hooks are equivalent.
348327
- `hook_ids_are_equivalent()` (`usethis._integrations.pre_commit.hooks`) — Check if two hook IDs are equivalent.
349328
- `ensure_pre_commit_config_exists()` (`usethis._integrations.pre_commit.init`) — Ensure '.pre-commit-config.yaml' exists with minimal valid content.
350329
- `get_system_language()` (`usethis._integrations.pre_commit.language`) — Get the appropriate 'system' language keyword based on pre-commit version.
351-
- `get_pre_commit_version()` (`usethis._integrations.pre_commit.version`) — Get an inferred pre-commit version for usethis to target.
352330
- `get_minimum_pre_commit_version()` (`usethis._integrations.pre_commit.version`) — Get the declared minimum supported pre-commit version from the configuration.
353331
- `has_pyproject_toml_declared_build_system()` (`usethis._integrations.project.build`) — Check if a build system is declared in the project.
354332
- `get_layered_architectures()` (`usethis._integrations.project.imports`) — Get the suggested layers for a package.
@@ -370,8 +348,6 @@ ALWAYS check whether an existing function already covers your use case before im
370348
- `get_endpoint()` (`usethis._pipeweld.func`) — Get the last step name (endpoint) from a pipeline component.
371349
- `get_predecessor()` (`usethis._pipeweld.func`) — Find the step that immediately precedes `step` in a pipeline component.
372350
- `call_subprocess()` (`usethis._subprocess`) — Run a subprocess and return its stdout, raising SubprocessFailedError on failure.
373-
- `change_cwd()` (`usethis._test`) — Change the working directory temporarily.
374-
- `is_offline()` (`usethis._test`) — Return True if the current environment has no internet connectivity.
375351
- `ensure_managed_file_exists()` (`usethis._tool.config`) — Ensure a file manager's managed file exists.
376352
- `is_likely_used()` (`usethis._tool.heuristics`) — Determine whether a tool is likely used in the current project.
377353
- `is_rule_covered_by()` (`usethis._tool.rule`) — Check if a rule is covered (subsumed) by a more general rule.

docs/functions.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
- `ensure_pyproject_toml_via_uv()` (`usethis._backend.uv.init`) — Create a pyproject.toml file using `uv init --bare`.
1919
- `ensure_symlink_mode()` (`usethis._backend.uv.link_mode`) — Ensure that the symlink link mode is enabled.
2020
- `ensure_uv_lock()` (`usethis._backend.uv.lockfile`) — Ensure a uv.lock file exists, creating it if necessary.
21-
- `get_available_uv_python_versions()` (`usethis._backend.uv.python`) — Get the set of Python versions available via uv.
22-
- `get_supported_uv_minor_python_versions()` (`usethis._backend.uv.python`) — Get the minor Python versions supported by the project and available via uv.
23-
- `uv_python_pin()` (`usethis._backend.uv.python`) — Pin the Python version for the project using uv.
24-
- `get_uv_version()` (`usethis._backend.uv.version`) — Get the version string of the installed uv tool.
25-
- `next_breaking_uv_version()` (`usethis._backend.uv.version`) — Get the next breaking version for a uv version string, following semver.
2621
- `files_manager()` (`usethis._config_file`) — Context manager that opens all configuration file managers for coordinated I/O.
2722
- `plain_print()` (`usethis._console`) — Print a plain message to the console, respecting quiet and alert-only settings.
2823
- `table_print()` (`usethis._console`) — Print a Rich table to the console, respecting quiet and alert-only settings.
@@ -76,7 +71,6 @@
7671
- `use_ruff()` (`usethis._core.tool`) — Add Ruff to the project.
7772
- `use_tach()` (`usethis._core.tool`) — Add and configure the Tach architecture enforcement tool.
7873
- `use_ty()` (`usethis._core.tool`) — Add and configure the ty type checker tool.
79-
- `use_tool()` (`usethis._core.tool`) — General dispatch function to add or remove a tool to/from the project.
8074
- `get_project_deps()` (`usethis._deps`) — Get all project dependencies.
8175
- `get_dep_groups()` (`usethis._deps`) — Get all dependency groups from pyproject.toml.
8276
- `get_deps_from_group()` (`usethis._deps`) — Get the list of dependencies in a named dependency group.
@@ -101,21 +95,17 @@
10195
- `get_name()` (`usethis._file.pyproject_toml.name`) — Get the project name from pyproject.toml.
10296
- `get_description()` (`usethis._file.pyproject_toml.name`) — Get the project description from pyproject.toml.
10397
- `get_project_dict()` (`usethis._file.pyproject_toml.project`) — Get the contents of the [project] section from pyproject.toml.
104-
- `remove_pyproject_toml()` (`usethis._file.pyproject_toml.remove`) — Remove the pyproject.toml file from the project.
10598
- `get_requires_python()` (`usethis._file.pyproject_toml.requires_python`) — Get the requires-python constraint from pyproject.toml.
10699
- `get_required_minor_python_versions()` (`usethis._file.pyproject_toml.requires_python`) — Get Python minor versions that match the project's requires-python constraint.
107100
- `ensure_pyproject_validity()` (`usethis._file.pyproject_toml.valid`) — Ensure pyproject.toml has a valid structure, adding missing required fields.
108101
- `prepare_pyproject_write()` (`usethis._file.pyproject_toml.write`) — Prepare the pyproject.toml file for a subprocess that will modify it.
109-
- `edit_yaml()` (`usethis._file.yaml.io_`) — A context manager to modify a YAML file in-place, with managed read and write.
110-
- `read_yaml()` (`usethis._file.yaml.io_`) — A context manager to read a YAML file.
102+
- `get_yaml_document()` (`usethis._file.yaml.io_`) — Get a YAML document representation from a string or file-like object.
111103
- `update_ruamel_yaml_map()` (`usethis._file.yaml.update`) — Update the values of a ruamel.yaml map in-place using a diff-like algorithm.
112104
- `lcs_list_update()` (`usethis._file.yaml.update`) — Update in-place using a longest common subsequence solver.
113105
- `project_init()` (`usethis._init`) — Initialize the project by creating the pyproject.toml and project structure.
114106
- `write_simple_requirements_txt()` (`usethis._init`) — Write a simple requirements.txt file with -e . and any project dependencies.
115107
- `ensure_dep_declaration_file()` (`usethis._init`) — Ensure that the file where dependencies are declared exists, if necessary.
116108
- `ensure_pyproject_toml()` (`usethis._init`) — Ensure that a pyproject.toml file exists, creating it if necessary.
117-
- `get_github_latest_tag()` (`usethis._integrations.ci.github.tags`) — Get the name of the most recent tag on the default branch of a GitHub repository.
118-
- `get_supported_minor_python_versions()` (`usethis._integrations.environ.python`) — Get supported Python versions for the current backend.
119109
- `add_docs_dir()` (`usethis._integrations.mkdocs.core`) — Create the `docs` directory and a `docs/index.md` file if they do not exist.
120110
- `remove_pre_commit_config()` (`usethis._integrations.pre_commit.core`) — Remove the .pre-commit-config.yaml file from the project.
121111
- `install_pre_commit_hooks()` (`usethis._integrations.pre_commit.core`) — Install pre-commit hooks.
@@ -126,11 +116,9 @@
126116
- `remove_hook()` (`usethis._integrations.pre_commit.hooks`) — Remove pre-commit hook configuration.
127117
- `get_hook_ids()` (`usethis._integrations.pre_commit.hooks`) — Get the list of hook IDs currently configured in the pre-commit configuration file.
128118
- `extract_hook_ids()` (`usethis._integrations.pre_commit.hooks`) — Extract all hook IDs from a pre-commit configuration model.
129-
- `hooks_are_equivalent()` (`usethis._integrations.pre_commit.hooks`) — Check if two hooks are equivalent.
130119
- `hook_ids_are_equivalent()` (`usethis._integrations.pre_commit.hooks`) — Check if two hook IDs are equivalent.
131120
- `ensure_pre_commit_config_exists()` (`usethis._integrations.pre_commit.init`) — Ensure '.pre-commit-config.yaml' exists with minimal valid content.
132121
- `get_system_language()` (`usethis._integrations.pre_commit.language`) — Get the appropriate 'system' language keyword based on pre-commit version.
133-
- `get_pre_commit_version()` (`usethis._integrations.pre_commit.version`) — Get an inferred pre-commit version for usethis to target.
134122
- `get_minimum_pre_commit_version()` (`usethis._integrations.pre_commit.version`) — Get the declared minimum supported pre-commit version from the configuration.
135123
- `has_pyproject_toml_declared_build_system()` (`usethis._integrations.project.build`) — Check if a build system is declared in the project.
136124
- `get_layered_architectures()` (`usethis._integrations.project.imports`) — Get the suggested layers for a package.
@@ -152,8 +140,6 @@
152140
- `get_endpoint()` (`usethis._pipeweld.func`) — Get the last step name (endpoint) from a pipeline component.
153141
- `get_predecessor()` (`usethis._pipeweld.func`) — Find the step that immediately precedes `step` in a pipeline component.
154142
- `call_subprocess()` (`usethis._subprocess`) — Run a subprocess and return its stdout, raising SubprocessFailedError on failure.
155-
- `change_cwd()` (`usethis._test`) — Change the working directory temporarily.
156-
- `is_offline()` (`usethis._test`) — Return True if the current environment has no internet connectivity.
157143
- `ensure_managed_file_exists()` (`usethis._tool.config`) — Ensure a file manager's managed file exists.
158144
- `is_likely_used()` (`usethis._tool.heuristics`) — Determine whether a tool is likely used in the current project.
159145
- `is_rule_covered_by()` (`usethis._tool.rule`) — Check if a rule is covered (subsumed) by a more general rule.

0 commit comments

Comments
 (0)