Skip to main content

SKY-E002 · Dead code

Empty file

Low

A Python file with no code at all, or with nothing but a docstring. Such files are usually left behind when code moves elsewhere.

Languages
Python
Turned on by
skylos . (every scan)
Quality gate
counted toward the gate limits (full and diff scans). Counts toward max_dead_code, which has no limit by default, so it only fails a gate where you set one.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

An empty module still imports without error, so nothing breaks and nobody notices it. Readers open it looking for the helpers its name promises, and new code may be added to the stale location.

What Skylos flags

billing/helpers.py · PythonReported on line 1
"""Shared helpers for the billing app."""

What Skylos leaves alone

billing/__init__.py · Python
"""Billing: invoices, payments and refunds."""
billing/invoices.py · Python
def invoice_total(lines):    return sum(line.amount for line in lines)

Why Skylos leaves it alone

__init__.py marks billing as a package, so it may be empty or hold only the package docstring. Skylos also skips __main__.py and main.py.

How Skylos decides

  1. Runs in every scan, with no extra flag, on Python files that parse.
  2. Reports a file whose module body is empty (only comments, blank lines or nothing) or holds exactly one statement that is a string, the docstring.
  3. Skips files named __init__.py, __main__.py and main.py, and, in a Django project, an admin.py next to the app's __init__.py.
  4. Does not check whether other files import the module. Reports LOW on line 1, in the unused_files list of the JSON output.

How to fix it

Delete the file, and remove any import of it. If the module is a planned home for new code, add that code, or say so in the docstring and suppress the finding.

When it can be wrong

  • A deliberately empty module that other code imports, such as a settings override that is empty in the default configuration, is reported.

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

  • [tool.skylos] ignore = ["SKY-E002"] turns the rule off for the project.

  • An inline marker does not work for this rule: a # skylos: ignore[SKY-E002] (or a bare # skylos: ignore) on line 1 of the file is not read, and the file is still reported. Use the project setting above, or exclude the folder from the scan.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.