python / python/mypy

Daemon does not progate change from decorated to async function

Open
#13,706 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-async topic-daemon
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This fine-grained incremental test case fails (no error on second run):

[case testDecoratedToAsyncReExported]
from mm import f
x: int = f()

[file mm.py]
from m import f

[file m.py]
from d import singleton

@singleton
def f() -> int:
    return 0

[file m.py.2]
async def f() -> str:
    return 'x'

[file d.py]
from typing import Callable

class Singleton:
    def __call__(self) -> int:
        return 0

def singleton(f: Callable[[], int]) -> Singleton: pass
[out]
==
main:2: error: Incompatible types in assignment (expression has type "Coroutine[Any, Any, str]", variable has type "int")

It seems necessary to have a re-export, a decorator, and an async function for this to work. Also changing the return type of the functions seems required. I have no idea so far why this corner case fails.

This fails in 0.971 so it's not a recent regression.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the testDecoratedToAsyncReExported case in the fine-grained incremental test harness, using the listed mm.py, m.py, and d.py snapshots. Trace why the second run produces no error; done means the second run reports the shown incompatible-types diagnostic without regressing related incremental tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.