Skip to content

Task pre attribute is wrongly types #1065

@kasium

Description

@kasium
from typing import cast, Any
from invoke.context import Context
from invoke.tasks import Task, task

@task()
def bar(context: Context) -> None:
    pass

@task(bar)
def foo(context: Context) -> None:
    pass

assert cast(Task[Any], foo).pre == (bar,)

The code works during runtime, but during type checking it fails with

x.py:17:8: error: Non-overlapping equality check (left operand type: "list[str] | str", right operand type: "tuple[Any]")  [comparison-overlap]
    assert cast(Task[Any], foo).pre == (bar,)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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