Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Implement attr.converters.default_if_none #414
So this is a stab at #400 which I find a reasonable usage of converters.
Typing tests fail tho and they also fail for
Yeah this is something the plugin currently doesn't support:
The underlying problem is that it's hard to extract the type of the function call in the mypy pipeline.
A workaround could be to write:
But that's broken also, but I think easier to fix. Now I remember, in our work code, when we started using mypy I removed all our uses of optional and just wrote our own converters.
I guess until mypy opens up it's plugin API (I talked to Jukka here at EuroPython and it's legit on their roadmap) we’ll have to comment stuff out, wait for mypy to release the support? Having hard-coded support is “fine” for now…
Does the signature look correct to you tho? If someone rubber-stamps it, I’ll just comment it out and we open an issue on mypy.
Being completely honest I wouldn't use this feature because if I passed in
None somewhere I would like it to blow up, or have mypy tell me about it so that I can handle it in the caller.
But the code all looks correct and the signature is pretty much what mypy wants it to be.