SKY-U005 · Dead code
Unused dependency
A declared Python runtime dependency or npm implementation/tooling dependency has no observed source, command or supported configuration use. Every install still downloads it.
- Languages
- Python, npm package.json
- Turned on by
skylos . --quality(or-a)- Quality gate
- counted toward the gate limits (full and diff scans). Reported in the quality list, so it counts toward
max_quality(10 by default), notmax_dead_code. - Finding type
- review
Why it matters
Each unused package makes installs slower and images larger, and is one more thing that can carry a vulnerability or be taken over by an attacker. Dependencies left behind after a rewrite are rarely noticed otherwise.
What Skylos flags
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3python-dateutil==2.9.0"""Price watcher service."""import requestsimport yamlfrom bs4 import BeautifulSoupfrom flask import Flask app = Flask(__name__) @app.get("/price")def price(): with open("settings.yml") as handle: settings = yaml.safe_load(handle) page = requests.get(settings["url"], timeout=10).text return BeautifulSoup(page, "html.parser").select_one(".price").textWhat Skylos leaves alone
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3alembic==1.13.2release: alembic upgrade headweb: flask runWhy Skylos leaves it alone
PyYAML is imported as yaml and beautifulsoup4 as bs4: Skylos maps distribution names to the modules they provide. alembic is never imported, but the Procfile runs its command, which counts as a use.
How Skylos decides
- For npm, also reads dependencies and devDependencies from each owning package.json with --quality. Literal imports (including Vue, Svelte and Astro script and style blocks, MDX ESM and stylesheet at-rules), package scripts, GitHub Actions
run:steps, Dockerfile, Makefile, Procfile and GitLab CI commands,/// <reference types>directives, tsconfigtypes(following relativeextends), supported tool configurations and package names in tool config strings supply usage; peer contracts are retained. An ancestor declaration that a workspace's import or command resolves to counts as used. - An
@types/xpackage is reported only whenxis used nowhere in the project and no tsconfigtypesentry, reference directive or ambient global names it;@types/nodestays while any source uses Node built-ins orprocess. A package declared in two sections is reported in each. - The npm check never runs package code or scripts. Command lines are read segment by segment, with
$VARarguments, redirections,cross-env,yarn --cwd/npm --prefixtargets andnode <script>files followed. Dynamic loaders that are not proven local, an expanded command name, unread source, unparsed components and incomplete source selection prevent absence claims. An unknown command holds back only the uninstalled, name-related dependencies that could provide it; an unread ESLint, Babel, Prettier or tool config holds back only that tool's family; an unresolved workspace consumer holds back only the ancestor declarations it could resolve. The receipt is analysis_summary.npm_dependency_analysis. - Runs with
--qualityon a directory scan that contains Python files (not when you scan single files). It reads run-time declarations next to the code, walking up at most five folders to the project root:requirements.txtandrequirements/*.txt(following-rincludes, ignoring-cconstraint files),[project].dependenciesinpyproject.toml, andinstall_requiresinsetup.cfgorsetup.py. Extras,setup_requiresandtests_requireare not read. - Treats compiled lock files (pip-compile or uv output with hashes and
# viacomments) as pins, not declarations, and reads their.ininput files instead. - Collects uses: imports (including
importlib.import_moduleand other string imports), module names in Django settings and other configuration, entry points, mypy and Sphinx plugins, pytest plugins, fixtures and markers, and commands in a Procfile, Dockerfile, Compose file or Makefile. - Never reports the project itself, command-line tools (
black,ruff,pytest,mypyand similar), runtime plugins such asgunicorn,celeryand database drivers, or type-stub packages. Maps each remaining package to the modules it installs, using the installed package metadata and a bundled name table, and keeps it when any of them is used. - Abstains, with a reason in
analysis_summary.unused_dependency_analysis, when an import or configuration value could not be resolved or a shared namespace hides which package is used. Otherwise reports MEDIUM on the package's line in the manifest.
How to fix it
Remove the package from the manifest and reinstall. If it is needed by something Skylos cannot see, such as a notebook or a deploy script outside the repository, move it to an extra or a separate requirements file for that use.
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3When it can be wrong
- Packages used only by notebooks, scripts outside the scanned folder or a shell command Skylos does not read are reported.
- A package loaded only through a plugin system Skylos does not know (a setting string it cannot resolve) is reported; an import it cannot resolve makes it abstain for every package instead.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
An inline
# skylos: ignore[SKY-U005]comment inrequirements.txtis not read: the package stays reported.[tool.skylos] ignore = ["SKY-U005"]turns the rule off; the summary then recordsrule_ignored.