GithubHelp home page GithubHelp logo

Comments (5)

zzstoatzz avatar zzstoatzz commented on September 18, 2024

thanks @williamjamir for the issue! will take a look at this

from prefect.

zzstoatzz avatar zzstoatzz commented on September 18, 2024

hi @williamjamir

using this MRE

» cat repros/task_typing.py
from functools import partial
from typing import reveal_type

from prefect import task

@task
def test(a: int, b: int) -> None: ...

partial(test, a=1)
reveal_type(test)

and this version of mypy

» pip freeze | rg mypy
mypy==1.11.0
mypy-extensions==1.0.0

I am not yet able to reproduce this on 2.16.9, newest 2.x, or 3.x

specific version checks
## 2.16.9
» uv pip install prefect==2.16.9 --force-reinstall
...
» mypy repros/task_typing.py
repros/task_typing.py:12: note: Revealed type is "Any"
Success: no issues found in 1 source file

## newest 2.x
» uv pip install -U prefect
...
» mypy repros/task_typing.py
repros/task_typing.py:12: note: Revealed type is "Any"
Success: no issues found in 1 source file

## newest 3.x
» uv pip install -U prefect --pre
...
» mypy repros/task_typing.py
repros/task_typing.py:12: note: Revealed type is "Any"
Success: no issues found in 1 source file

is there anything you notice that I'm missing here?

from prefect.

williamjamir avatar williamjamir commented on September 18, 2024

Thanks for looking at this @zzstoatzz !

It's odd that mypy is not detecting the correct typing for you. The output of reveal_type is Any, which, in my understanding, disables the check that would be made on partial.

I would expected to see the reveal_type instead as Task, like in my initial message.

from prefect.

zzstoatzz avatar zzstoatzz commented on September 18, 2024

taking another look, I was able to reproduce in a completely fresh sandbox environment

(root) root@678e57987c9b:~# mypy /tmp/repros/14756.py
/tmp/repros/14756.py:11: error: "Task[[int, int], None]" not callable  [misc]
/tmp/repros/14756.py:12: note: Revealed type is "prefect.tasks.Task[[a: builtins.int, b: builtins.int], None]"
Found 1 error in 1 file (checked 1 source file)

will dig into this

from prefect.

zzstoatzz avatar zzstoatzz commented on September 18, 2024

it appears that I wasn't able to reproduce before because I had follow_imports = skip set, once I turned that off I could reliably reproduce.

I don't yet understand what mypy is on about here, since we overload __call__ for several cases (perhaps incorrectly somehow) so it should be recognized as a callable thing. (edit, its because of partial)

perhaps this issue is related? python/mypy#5079 (edit, I dont think it is)


edit actually it appears this might be more relevant python/mypy#17585

as without the partial, we pass fine. I would say for the moment, I think this is an upstream issue with mypy (as described in the above linked issue).

from prefect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.