Skip to content

Commit dd8250e

Browse files
committed
Remove dead code and prevent regressions
1 parent b255134 commit dd8250e

17 files changed

+122
-106
lines changed

.config/vulture_whitelist.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
_.configured # unused attribute (src/ansiblelint/__main__.py:140)
2+
configured # unused variable (src/ansiblelint/config.py:132)
3+
_.keep_trailing_newline # unused attribute (src/ansiblelint/rules/jinja.py:280)
4+
_.lstrip_blocks # unused attribute (src/ansiblelint/rules/jinja.py:282)
5+
_.trim_blocks # unused attribute (src/ansiblelint/rules/jinja.py:283)
6+
_.autoescape # unused attribute (src/ansiblelint/rules/jinja.py:284)
7+
_.newline_sequence # unused attribute (src/ansiblelint/rules/jinja.py:285)
8+
_.allow_duplicate_keys # unused attribute (src/ansiblelint/skip_utils.py:138)
9+
_.playbook_paths # unused attribute (src/ansiblelint/utils.py:257)
10+
_.explicit_end # unused attribute (src/ansiblelint/yaml_utils.py:915)
11+
_.default_flow_style # unused attribute (src/ansiblelint/yaml_utils.py:923)
12+
_.compact_seq_seq # unused attribute (src/ansiblelint/yaml_utils.py:924)
13+
_.compact_seq_map # unused attribute (src/ansiblelint/yaml_utils.py:925)
14+
_.Constructor # unused attribute (src/ansiblelint/yaml_utils.py:946)
15+
_.preserve_quotes # unused attribute (src/ansiblelint/yaml_utils.py:956)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ src/ansiblelint/_version.py
7777
test/eco
7878
test/local-content
7979
test/schemas/node_modules
80+
node_modules

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ repos:
173173
- wcmatch
174174
exclude: >
175175
(?x)^(
176+
.config/.*|
176177
collections/.*|
177178
test/local-content/.*|
178179
plugins/.*
@@ -227,6 +228,10 @@ repos:
227228
- typing_extensions
228229
- wcmatch
229230
- yamllint
231+
- repo: https://github.com/jendrikseipp/vulture
232+
rev: v2.13
233+
hooks:
234+
- id: vulture
230235
- # keep at bottom as these are slower
231236
repo: local
232237
hooks:

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@
4343
"editor.defaultFormatter": "ms-python.black-formatter",
4444
"editor.formatOnSave": true
4545
},
46-
"evenBetterToml.formatter.arrayTrailingComma": true
46+
"evenBetterToml.formatter.arrayTrailingComma": true,
47+
"[toml]": {
48+
"editor.defaultFormatter": "panekj.even-betterer-toml"
49+
}
4750
}

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"devDependencies": {
3+
"prettier": "^3.3.3"
4+
}
5+
}

pyproject.toml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ error_summary = true
9393
# warn_return_any = True
9494
# warn_unused_configs = True
9595
# site-packages is here to help vscode mypy integration getting confused
96-
exclude = "(build|dist|test/local-content|site-packages|~/.pyenv|examples/playbooks/collections|plugins/modules)"
96+
exclude = "(.config|build|dist|test/local-content|site-packages|~/.pyenv|examples/playbooks/collections|plugins/modules)"
9797
# https://github.com/python/mypy/issues/12664
9898
incremental = false
9999
python_version = "3.10"
@@ -122,7 +122,7 @@ bad-names = [
122122
# pylint defaults + f,fh,v,id
123123
good-names = ["i", "j", "k", "Run", "_", "f", "fh", "v", "id", "T"]
124124
# Ignore as being generated:
125-
ignore-paths = "^src/ansiblelint/_version.*$"
125+
ignore-paths = "^(src/ansiblelint/_version|.config/).*$"
126126

127127
[tool.pylint."MESSAGES CONTROL"]
128128
disable = [
@@ -195,6 +195,7 @@ minversion = "4.6.6"
195195
norecursedirs = [
196196
"*.egg",
197197
".cache",
198+
".config",
198199
".eggs",
199200
".git",
200201
".github",
@@ -222,6 +223,7 @@ xfail_strict = true
222223

223224
[tool.ruff]
224225
cache-dir = "./.cache/.ruff"
226+
exclude = [".config"]
225227
fix = true
226228
# Same as Black.
227229
line-length = 88
@@ -322,3 +324,27 @@ sort_table_keys = true
322324
annotation-style = "line"
323325
custom-compile-command = "tox run deps"
324326
no-emit-package = ["ansible-core", "pip", "resolvelib", "typing_extensions", "uv"]
327+
328+
[tool.vulture]
329+
exclude = [
330+
".eggs",
331+
".tox",
332+
"build",
333+
"collections",
334+
"examples",
335+
"plugins",
336+
"test/local-content",
337+
"venv",
338+
"src/ansiblelint/_version.py"
339+
]
340+
ignore_names = [
341+
"_ANSIBLE_ARGS",
342+
"__rich_console__",
343+
"fixture_*",
344+
"pytest_addoption",
345+
"pytest_collection_modifyitems",
346+
"pytest_configure",
347+
"side_effect",
348+
"test_*"
349+
]
350+
paths = ["src", "test", ".config/vulture_whitelist.py"]

src/ansiblelint/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def __call__(
135135
values: str | Sequence[Any] | None,
136136
option_string: str | None = None,
137137
) -> None:
138+
logging.debug(option_string)
138139
if isinstance(values, str | Path):
139140
values = [values]
140141
if values:

src/ansiblelint/config.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import urllib.request
1111
import warnings
1212
from dataclasses import dataclass, field
13-
from functools import lru_cache
1413
from http.client import HTTPException
1514
from importlib.metadata import PackageNotFoundError, distribution, version
1615
from pathlib import Path
@@ -201,26 +200,10 @@ def supported_ansible(self) -> list[str]:
201200
# Used to store detected tag deprecations
202201
used_old_tags: dict[str, str] = {}
203202

204-
# Used to store collection list paths (with mock paths if needed)
205-
collection_list: list[str] = []
206-
207203
# Used to store log messages before logging is initialized (level, message)
208204
log_entries: list[tuple[int, str]] = []
209205

210206

211-
@lru_cache
212-
def ansible_collections_path() -> str:
213-
"""Return collection path variable for current version of Ansible."""
214-
# respect Ansible behavior, which is to load old name if present
215-
for env_var in [
216-
"ANSIBLE_COLLECTIONS_PATHS",
217-
"ANSIBLE_COLLECTIONS_PATH",
218-
]: # pragma: no cover
219-
if env_var in os.environ:
220-
return env_var
221-
return "ANSIBLE_COLLECTIONS_PATH"
222-
223-
224207
def in_venv() -> bool:
225208
"""Determine whether Python is running from a venv."""
226209
if hasattr(sys, "real_prefix") or os.environ.get("CONDA_EXE", None) is not None:

src/ansiblelint/constants.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ class RC: # pylint: disable=too-few-public-methods
3636
EXIT_CONTROL_C = 130
3737

3838

39-
# Minimal version of Ansible we support for runtime
40-
ANSIBLE_MIN_VERSION = "2.12"
41-
4239
ANSIBLE_MOCKED_MODULE = """\
4340
# This is a mocked Ansible module generated by ansible-lint
4441
from ansible.module_utils.basic import AnsibleModule
@@ -208,13 +205,6 @@ def main():
208205
"include_role",
209206
}
210207

211-
# Newer versions of git might fail to run when different file ownership is
212-
# found of repo. One example is on GHA runners executing containerized
213-
# reusable actions, where the mounted volume might have different owner.
214-
#
215-
# https://github.com/ansible/ansible-lint-action/issues/138
216-
GIT_CMD = ["git", "-c", f"safe.directory={Path.cwd()}"]
217-
218208
CONFIG_FILENAMES = [
219209
".ansible-lint",
220210
".config/ansible-lint.yml",

0 commit comments

Comments
 (0)