Skip to content

Eliminate all type: ignore comments with proper typing #44

@elijahr

Description

@elijahr

Summary

Audit and eliminate all # type: ignore comments across the codebase by properly typing the underlying values. Currently there are ~50+ type: ignore comments, most due to:

  1. Original function ClassVars typed as Any: Every plugin stores intercepted function references as ClassVar[Any]. When these are called in _GuardPassThrough handlers or deactivate() restores, mypy can't verify return types.

  2. Method assignment ignores: Patching class methods with setattr or direct assignment triggers [method-assign] or [assignment] errors.

  3. Untyped library stubs: Some dependencies lack type stubs (celery, botocore, paramiko, pika, cffi, grpc, pymemcache).

Proposed Approach

Original function ClassVars (highest impact)

Replace ClassVar[Any] with properly typed ClassVar[Callable[..., ReturnType] | None]:

# Before:
_original_connect: ClassVar[Any] = None

# After:
_original_connect: ClassVar[Callable[[socket.socket, tuple[str, int]], None] | None] = None

This eliminates no-any-return and ANN401 errors in one pass.

Method assignment

Use typing.cast or protocol types to satisfy mypy when assigning patched methods to class attributes.

Untyped libraries

Keep per-module ignore_missing_imports overrides in pyproject.toml (already configured). These can't be fixed without upstream stubs.

Scope

  • All src/bigfoot/plugins/*.py files
  • src/bigfoot/_context.py, src/bigfoot/_verifier.py
  • Goal: zero type: ignore comments that can be eliminated with proper typing
  • Keep only genuinely unavoidable ignores (untyped 3rd-party libs, dynamic method patching where no Protocol can help)

Success Criteria

  • uv run mypy src/bigfoot/ reports 0 errors (or only untyped-library errors)
  • No # type: ignore[no-any-return] comments remain
  • No # type: ignore[assignment] comments that could be replaced with proper typing
  • All existing tests still pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions