SKY-D223 · Supply chain and agent configuration
Undeclared third-party import
A Python file imports a third-party package that the project's manifest (pyproject.toml, requirements.txt, setup.cfg or setup.py) does not declare. SKY-D223 reports the import line and names the distribution that would provide it.
- Languages
- Python
- Turned on by
skylos . --ai-defects(or-a); reads the code as it is, no diff needed- Quality gate
- counted toward the gate limits (full and diff scans). Reported with the AI-code findings and counted toward
max_ai_defects. A MEDIUM finding does not fail the gate on its own unlessblock_ai_defect_severitiesunder[tool.skylos.gate]lists"MEDIUM". - Finding type
- review
- Catalog name
- Undeclared third-party dependency
Why it matters
The code works on the machine where the package happens to be installed and fails with ModuleNotFoundError in a clean install, a container or CI. Coding agents often add an import without touching the manifest, and the gap shows up only after release.
What Skylos flags
from pathlib import Path import requestsimport yaml def load_settings(path: Path) -> dict: with path.open() as handle: return yaml.safe_load(handle) def fetch_rates(url: str) -> dict: return requests.get(url, timeout=10).json()[project]name = "invoice-service"version = "1.0.0"dependencies = ["requests==2.32.3"]What Skylos leaves alone
[project]name = "invoice-service"version = "1.0.0"dependencies = ["requests==2.32.3", "PyYAML==6.0.2"]Why Skylos leaves it alone
The import is yaml but the distribution is called PyYAML. Skylos maps import names to the distributions that provide them, so a package declared under its distribution name counts.
How Skylos decides
- Runs with
--ai-defectson Python files. For each file it finds the nearest manifest and reads the declared dependencies; nothing is installed or imported from the scanned project. - Skips the standard library, the project's own modules and packages, names starting with
_, imports insetup.pyof build tools such assetuptools, and names listed in theSKYLOS_PRIVATE_DEPS_ALLOWenvironment variable. - Looks the import up in the distributions installed next to Skylos. If one of them provides it and none of those is declared, it reports "Undeclared import 'yaml' (provided by: pyyaml)".
- Otherwise it uses a built-in map of import names to distributions, and then asks PyPI whether a project of that name exists. A package that exists and is not declared is reported here; a name that no PyPI project has is reported as SKY-D222 instead.
- Does not report when the project has no manifest at all, when a declared dependency or a lockfile edge provides the import, or when the import is used only under
if TYPE_CHECKING:.
How to fix it
Declare the package, with the version you tested, in the manifest the project installs from. If the import was a mistake, remove it.
[project]name = "invoice-service"version = "1.0.0"Removed: dependencies = ["requests==2.32.3"]Added: dependencies = ["requests==2.32.3", "PyYAML==6.0.2"]When it can be wrong
- The installed-package lookup uses the Python that runs Skylos. A package installed there under a different distribution name than the one you declared can be reported as undeclared.
- A private package that is installed by other means, such as a base image, is reported. List it in
SKYLOS_PRIVATE_DEPS_ALLOW(comma-separated names) for the scan. - An import that Skylos cannot match to any distribution, for example a module whose PyPI project has a different name, is still reported, with "(possible import/dist name mismatch)" in the message.
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
Mark a reviewed import on its own line.
Python import yaml # skylos: ignore[SKY-D223] installed by the base imageAccept existing findings with
skylos baseline ., then scan with--baseline.ignore = ["SKY-D223"]under[tool.skylos]turns the rule off for the whole project.