Replies: 2 comments
-
I'm not familiar with celery. It appears that it's not a typed library. I can see that you've enabled type checking in pylance. Type checking requires high-quality type information for libraries that you import. Pylance has a setting called "python.analysis.useLibraryCodeForTypes". By default, pylance enables this setting, but I recommend disabling it if you turn on type checking. By disabling it, you'll tell pylance that it shouldn't attempt to infer types from library code and instead treat all types imported from untyped libraries as "unknown" types. Types inferred from library code is typically good enough to offer reasonable completion suggestions, but it's often not good enough for type checking. In the specific example above, the decorator function If this library is important to you, please contact the maintainers of the library and request that they add type annotations to the next version. Here's our detailed guidance for library authors. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I will do that. Very interesting too.
Thanks,
Ben
…On Wed, Jul 7, 2021, 12:32 PM Eric Traut ***@***.***> wrote:
I'm not familiar with celery. It appears that it's not a typed library.
I can see that you've enabled type checking in pylance. Type checking
requires high-quality type information for libraries that you import.
Pylance has a setting called "python.analysis.useLibraryCodeForTypes". By
default, pylance enables this setting, but I recommend disabling it if you
turn on type checking. By disabling it, you'll tell pylance that it
shouldn't attempt to infer types from library code and instead treat all
types imported from untyped libraries as "unknown" types. Types inferred
from library code is typically good enough to offer reasonable completion
suggestions, but it's often not good enough for type checking.
In the specific example above, the decorator function task has no type
annotation in the library. By default, pylance assumes that an unannotated
decorator retains the original type and signature of the function it is
decorating. That's a good assumption in most cases, but in this particular
case the heuristic fails.
If this library is important to you, please contact the maintainers of the
library and request that they add type annotations to the next version.
Here's our detailed guidance
<https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md>
for library authors.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1534 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC5B4R7GRSNFGQUEIXZCD3TWR6RBANCNFSM4767HQWA>
.
|
Beta Was this translation helpful? Give feedback.
-
Hello all,
I came across this error when I use celery and pylance. Any minimal celery working example will do but this should trigger it and here I assume that you have a celery app defined somewhere.
@app.task
def my_func(x):
pass
def my_func2(x)
my_func.delay(x)
I don't think that the decorator is getting applied correctly here or is there a better way to state that this function can accept a deplay method?
Beta Was this translation helpful? Give feedback.
All reactions