-
-
Notifications
You must be signed in to change notification settings - Fork 385
Bunch of typing issues #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Stubs issue (i.e. typeshed) Though I'm a little surprised that it doesn't already work.
Hmm. This one is supposed to work in the plugin. What error do you get? Which version of mypy? Can you post some code?
Plugin issue. Not something I handle correctly.
Plugin issue. Not so much on purpose as in they are fairly difficult to implement in mypy. Feel free to file mypy bugs for the plugin issues, and typeshed bugs for the Factory issue. |
import attr
import yarl
@attr.s
class C:
url = attr.ib(converter=yarl.URL) gives me: |
Can you try replacing yarl.URL with another class? One that has type
annotations? Something in click, yaml or attrs?
…On Tue, Jun 5, 2018 at 6:31 AM, Hynek Schlawack ***@***.***> wrote:
import attrimport yarl
@attr.sclass C:
url = attr.ib(converter=yarl.URL)
gives me: error: Unsupported converter function, only named functions are
currently supported on mypy 0.600.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCCAgkLqYGTA_KX00OJhDOx0txOewK2ks5t5og5gaJpZM4UarmJ>
.
|
yarl actually has type annotations: https://github.com/aio-libs/yarl/blob/master/yarl/__init__.pyi#L6 It was the first pkg I ran into that shipped them. :) |
(I tried an attrs class and the result was the same. Given the error message, it doesn’t look like it even looks at the types.) |
Ah it looks like they haven't released in a bit. It works correctly on
mypy master.
…On Tue, Jun 5, 2018 at 6:38 AM, Hynek Schlawack ***@***.***> wrote:
(I tried an attrs class and the result was the same. Given the error
message, it doesn’t look like it even looks at the types.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCCAl8nSjUB6d-BLjsccSEZoM5vjCt9ks5t5onfgaJpZM4UarmJ>
.
|
Cool! Will enums work too? Just ran into it and it’s super useful. :) |
Sure looks like it does:
```
import attr
from enum import Enum
class Em(Enum):
x = 'x'
y = 'y'
@attr.s
class C:
url: Em = attr.ib(converter=Em)
```
…On Tue, Jun 5, 2018 at 7:18 AM, Hynek Schlawack ***@***.***> wrote:
Cool! Will enums work too? *Just* ran into it and it’s super useful. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCCAn6ojf8Mj8Itwijo7BiYYRe0KbZXks5t5pMpgaJpZM4UarmJ>
.
|
So it’s basically just the partial thing. We should try to close #238 ASAP because right now I’m not sure where to report. |
from functools import partial
import attr
f = partial(int, 42)
@attr.s
class C:
x = attr.ib(factory=f) works too now…I didn’t see anything in changelogs, but it doesn’t just work by accident, does it? |
lambdas still won't work as converters though. |
Coolio! |
So this is mostly a meta ticket in which I ask @chadrik and @euresti (others of course too :)) for help to tell me where to direct them:
error: No overload variant of "Factory" matches argument types [functools.partial[Any]]
init=False
makes it impossible to add more attributes. Like this:It works perfectly fine to run but mypy will complain:
error: Non-default attributes not allowed after default attributes.
Minor:
The text was updated successfully, but these errors were encountered: