Skip to content

Refactor: Properly type progress_task decorator to eliminate type: ignore comments #25

@MaKaNu

Description

@MaKaNu

Problem

The progress_task decorator in tipi/core/permanences.py returns Callable[..., Callable[..., Any]], which causes mypy to report no-any-return errors when using it.

Currently we have # type: ignore[no-any-return] comments in tipi/core/processes.py (lines 113, 134, 155) to suppress these warnings.

Proposed Solution

Update progress_task to use TypeVar and ParamSpec for proper generic typing:

from typing import TypeVar, ParamSpec

P = ParamSpec("P")
R = TypeVar("R")

def progress_task(self, task_name: str, visible: bool = True) -> Callable[[Callable[P, R]], Callable[[int], R]]:
    ...

This would:

  1. Preserve the decorated function's return type
  2. Eliminate the need for type: ignore comments
  3. Provide better IDE support and type checking

Files Affected

[permanences.py] - Update decorator signature
[processes.py] - Remove [type: ignore] comments after fix

Additional Context

A [ProgressTaskCallable] Protocol was added to document the expected interface:

This can potentially be removed or repurposed once the decorator is properly typed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions