python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 16 forks source link

`TaskStatus.started` annotations can be type-safe without requiring the mypy plugin be used #80

Closed gschaffner closed 1 year ago

gschaffner commented 1 year ago

e.g. without the plugin, the following currently passes type checking but is not type-safe:

async def foo(*, task_status: TaskStatus[int]) -> None:
    # the following should be rejected
    task_status.started()
    # as it's equivalent to the following, which is correctly rejected
    # task_status.started(None)

see also https://github.com/agronholm/anyio/issues/565

gschaffner commented 1 year ago

oh, I did not realize that the mypy plugin handles this.

in any event, this can be typed correctly without requiring the mypy plugin be used.