Dunder Patterns Diagnostics

Beacon flags special-casing guidance for dunder blocks and entry-point guards to keep symbol metadata accurate.

DUNDER_INFO – EntryPointGuard

Example

if __name__ == "__main__":
    run_cli()

Guidance

This informational hint makes entry-point guards easier to spot. No action needed. The behavior is described in Semantic Enhancements.

DUNDER001 – MagicMethodOutOfScope

Example

def __str__():
    return "oops"  # Should live inside a class

Guidance

Define magic methods inside classes (class Foo:\n def __str__(self) -> str: ...). This keeps symbol metadata consistent with Python semantics. See Semantic Enhancements for background on how Beacon tracks dunders.