Minor: type annotation, getattr cleanup, error message clarity in _load_detector #11

Closed
opened 2026-08-07 02:12:58 +00:00 by Mark · 0 comments
Owner

Two minor issues in the new _load_detector() helper (face_swapper.py:217):

  1. Missing return type annotation. Should be -> Optional["SCRFDDetector"].
  2. Defensive getattr for an attribute that's always set in __init__. Line 226 uses getattr(self, '_detector', None) even though self._detector = None is on line 54. Inconsistent with _official access.

Also: Error message on line 129 is technically accurate but misleading for users who only call infer_with_embedding() (which doesn't need SCRFD). Consider clarifying.

Fix: Add type annotation. Replace getattr(self, '_detector', None) with self._detector. Tighten the error message to mention that this error is specific to infer(), not infer_with_embedding().

Files to modify: auraframe/models/face_swapper.py lines 217-235

Test: Lint clean. Existing tests pass.

Two minor issues in the new `_load_detector()` helper (face_swapper.py:217): 1. Missing return type annotation. Should be `-> Optional["SCRFDDetector"]`. 2. Defensive `getattr` for an attribute that's always set in `__init__`. Line 226 uses `getattr(self, '_detector', None)` even though `self._detector = None` is on line 54. Inconsistent with `_official` access. Also: Error message on line 129 is technically accurate but misleading for users who only call `infer_with_embedding()` (which doesn't need SCRFD). Consider clarifying. **Fix:** Add type annotation. Replace `getattr(self, '_detector', None)` with `self._detector`. Tighten the error message to mention that this error is specific to `infer()`, not `infer_with_embedding()`. **Files to modify:** `auraframe/models/face_swapper.py` lines 217-235 **Test:** Lint clean. Existing tests pass.
Mark closed this issue 2026-08-07 02:27:39 +00:00
Sign in to join this conversation.
No description provided.