Skip to main content

SKY-Q803 · Quality, structure and performance

Module hard to change or unused

Medium

The catalog gives no severity. Every finding is reported MEDIUM.

Using instability (I) and abstractness (A) as in SKY-Q802, SKY-Q803 names two corners. The zone of pain is a concrete module that others depend on and that depends on little itself (A and I below 0.3). The zone of uselessness is an abstract module that nothing stable depends on (A and I above 0.7).

Languages
Python, TypeScript, JavaScript
Quality gate
listed, not counted by the gate (full and diff scans). By default it is an advisory shown under architecture metrics, and no limit counts it. With enforce_iad = true under [tool.skylos.architecture] (used in the examples) it becomes a quality finding, counted toward max_quality and failing a strict gate.
Finding type
advice
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A module in the zone of pain is hard to change: each edit reaches every importer, and there is no interface to put a new implementation behind. A module in the zone of uselessness is abstraction that nothing uses, which readers still have to understand.

What Skylos flags

shop/pricing.py · PythonReported on line 1
"""Tax and discount rules."""  def price_with_tax(amount, rate):    return round(amount * (1 + rate), 2)
shop/checkout.py · Python
"""Checkout totals.""" from shop.pricing import price_with_tax  def checkout_total(cart):    return price_with_tax(sum(item.price for item in cart), 0.2)
shop/invoices.py · Python
"""Invoice lines.""" from shop.pricing import price_with_tax  def invoice_line(item):    return f"{item.name}: {price_with_tax(item.price, 0.2)}"
shop/__init__.py · Python
"""The shop package."""
pyproject.toml · TOML
[tool.skylos.architecture]enforce_iad = true

What Skylos leaves alone

shop/pricing.py · Python
"""Tax and discount rules.""" from shop._rates import TAX_RATE  def price_with_tax(amount):    return round(amount * (1 + TAX_RATE), 2)
shop/_rates.py · Python
"""Tax rates.""" TAX_RATE = 0.2
shop/checkout.py · Python
"""Checkout totals.""" from shop.pricing import price_with_tax  def checkout_total(cart):    return price_with_tax(sum(item.price for item in cart))
shop/invoices.py · Python
"""Invoice lines.""" from shop.pricing import price_with_tax  def invoice_line(item):    return f"{item.name}: {price_with_tax(item.price)}"

shop/__init__.py: same as in the flagged example.

pyproject.toml: same as in the flagged example.

Why Skylos leaves it alone

pricing now also depends on a module of its own (I = 1/3), so it is no longer in the zone of pain; SKY-Q802 may still report its distance. The constants moved to _rates, a private helper with at most three importers, which Skylos does not place in a zone.

How Skylos decides

  1. Runs with --quality, on the import graph of the project's Python modules (top-level imports only) and TypeScript and JavaScript modules, with I and A computed as for SKY-Q802.
  2. A module with at least one import link is in the zone of pain when A and I are both below 0.3 and in the zone of uselessness when both are above 0.7, unless its distance |A + I - 1| is at most 0.2.
  3. Skips test modules, entry points (a module with an if __name__ == "__main__": block or a pyproject.toml script), a private module (name starting with _) with at most three importers, and a package submodule imported only by its own package __init__.
  4. Reports MEDIUM on line 1, naming the zone. Without enforce_iad = true the finding is an advisory in the scan's architecture metrics.

How to fix it

Mark internal helpers private: rename pricing.py to _pricing.py (below) and update the imports. For a real shared boundary, let importers depend on an interface (Protocol or ABC) instead of the concrete module. Remove abstractions nothing uses.

Fix · Python
"""Tax and discount rules."""  def price_with_tax(amount, rate):    return round(amount * (1 + rate), 2)

When it can be wrong

  • The zones were defined for whole packages. At file level most shared constants and helper modules land in the zone of pain without being a problem, which is why the rule is advisory by default.
  • Third-party imports do not count, so a module that wraps a library can look more stable than it is.

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 marker does not work for this rule: with this comment on line 1, the reported line, the module is still reported.

    Python
    """Tax and discount rules."""  # skylos: ignore[SKY-Q803] stable by design
  • ignore = ["SKY-Q803"] under [tool.skylos] turns the rule off for the project; leaving out enforce_iad keeps it an advisory that no gate counts.

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