oracletrace icon indicating copy to clipboard operation
oracletrace copied to clipboard

[Refactor] Comprehensive Type Hinting and PEP 561 Compliance

Open KaykCaputo opened this issue 7 months ago • 2 comments

[Refactor] Comprehensive Type Hinting and PEP 561 Compliance

Summary

Add type hints to the entire codebase and include a py.typed file to make OracleTrace PEP 561 compliant.

Problem

The current codebase lacks full type annotations. This results in poor autocompletion and lack of static analysis support (like mypy or pyright) for developers using OracleTrace as a library or contributing to the core.

Proposed Solution

  • Annotate all function signatures and variable declarations in tracer.py, cli.py, and analysis.py.
  • Add mypy to the dev dependencies and CI pipeline.
  • Include an empty py.typed file in the package root to signal type-checker support.

Use Case

A developer importing oracletrace into their own performance suite will get accurate IDE suggestions and type safety during development.

Example

# Before
def trace_function(func, args):
    ...

# After
def trace_function(func: Callable[..., Any], args: tuple[Any, ...]) -> TraceResult:
    ...

Alternatives Considered

  • Leaving types as implicit (not recommended for modern Python libraries).

Additional Context

Given the recent growth in contributors, this will significantly reduce "TypeErrors" in Pull Requests and improve code documentation.

Checklist

  • [x] I searched existing issues before opening this request
  • [x] I described the problem and why this feature is useful
  • [x] I provided enough detail for implementation discussion

KaykCaputo avatar Apr 09 '26 14:04 KaykCaputo

I wanna do this.

waldo121 avatar Apr 09 '26 15:04 waldo121

@waldo121 nice, go ahead

KaykCaputo avatar Apr 09 '26 15:04 KaykCaputo