SKY-T102 · Quality, structure and performance
Missing return type annotation
A return annotation (-> str) states what a function gives back. SKY-T102 reports a public Python function or method without one, but only where the project has asked for annotations: when its own mypy settings require them, or when annotation advice is turned on.
- Languages
- Python
- Turned on by
--quality, when the project's mypy settings require annotations ortyping_coverage_advice = trueis set under[tool.skylos]- Quality gate
- counted toward the gate limits (full and diff scans). When it runs, it is listed and counted toward
max_quality. Missing parameter types on the same function (SKY-T101) are shown in the same entry. - Needs
- a mypy policy that requires annotations for the file (
disallow_untyped_defs,disallow_incomplete_defsorstrict), ortyping_coverage_advice = trueunder[tool.skylos] - Finding type
- advice
- Catalog name
- Missing return type annotations
Why it matters
Without a declared return type, mypy treats the function as returning Any (or skips it), so every caller loses checking. A function that sometimes returns None then reaches code that calls .upper() on it.
What Skylos flags
"""Price formatting for invoices.""" from decimal import Decimal def format_price(price: Decimal, currency: str): return f"{price:.2f} {currency}"[tool.mypy]files = ["app"]disallow_incomplete_defs = trueWhat Skylos leaves alone
"""Price formatting for invoices.""" from decimal import Decimal def format_price(price: Decimal, currency: str) -> str: return f"{price:.2f} {currency}" def legacy_total(items): return sum(item.price for item in items)Why Skylos leaves it alone
disallow_incomplete_defs only rejects functions that are partly annotated, as format_price was. legacy_total has no annotations at all, so mypy accepts it under this setting, and Skylos follows mypy.
How Skylos decides
- Runs with
--quality, once per Python module, with the same scope as SKY-T101: public module-level functions and methods of public classes, restricted to a literal__all__when there is one; test code, examples, benchmarks, a top-leveldocsfolder and the rootsetup.pyare skipped unless the mypy policy covers them. - Reads the project's mypy settings and requires a return type where mypy would: on every public function with
disallow_untyped_defsorstrict, and only on partly annotated ones withdisallow_incomplete_defs. The file must be among the files mypy checks (filesor a command's targets). A# type:comment counts. - With
typing_coverage_advice = trueunder[tool.skylos]and no such requirement, it reports functions that are explicitly part of an API, such as names in a literal__all__; a plain procedure that never returns a value is then not reported. - Reports LOW on the
defline.
How to fix it
Add the return type. For a function that returns nothing, write -> None.
"""Price formatting for invoices.""" from decimal import Decimal Removed: def format_price(price: Decimal, currency: str):Added: def format_price(price: Decimal, currency: str) -> str: return f"{price:.2f} {currency}"When it can be wrong
- Under a mypy requirement, a function that only performs an action without
-> Noneis reported, as mypy would report it. - It misses private functions (names starting with
_) and nested functions, which mypy still checks.
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
On the
defline (the reported line):Python def format_price(price: Decimal, currency: str): # skylos: ignore[SKY-T102] stubignore = ["SKY-T102"]under[tool.skylos]turns the rule off for the project. A baseline accepts existing findings, but it records the absolute file path and the line, so an entry stops matching when the checkout moves or the line shifts.