# ban_hasattr_dispatch โ€” v1 **Why this iteration:** Lifted verbatim from `conductor/code_styleguides/python.md` ยง17.4 (lines 300-326). This is the baseline encoding โ€” the imperative-ban style currently in production. Future variants will test alternative encodings (rationale-first, before/after, tabular) against this baseline. **Source:** `conductor/code_styleguides/python.md:300-326` --- ### 17.4 Banned: `hasattr()` for entity type dispatch ```python # BANNED: def handle_event(self, event: Metadata) -> None: if hasattr(event, 'tool_calls'): # tool call path elif hasattr(event, 'source_tier'): # mma path elif hasattr(event, 'path'): # file path # CORRECT (typed Union dispatch): def handle_event(self, event: CommsLogEntry | FileItem | HistoryMessage) -> None: if isinstance(event, CommsLogEntry): # mma path elif isinstance(event, FileItem): # file path elif isinstance(event, HistoryMessage): # tool call path # CORRECT (preferred โ€” refactor so no dispatch is needed): def _handle_comms_entry(self, event: CommsLogEntry) -> None: ... def _handle_file_item(self, event: FileItem) -> None: ... def _handle_history(self, event: HistoryMessage) -> None: ... ```