You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mypy type checker fails on 5.4.0 ProjectFileManager raw method #3104
Description of the problem, including code/CLI snippet
After update to 5.4.0 I have noticed that overloaded methods break my file download raw method type checking for both: tempfile and regular file stream.
Is this something I am doing something wrong, or 36d9b24 commit break this and needs to be addressed?
Thanks for the report @kesmik. Seems like we're not fully addressing all the variants of action that can be passed. I'll take a quick look at this and re-release after merge if necessary.
@JohnVillalovos@igorp-collabora this was my fear with typing overloads, I think we have to provide all the variations of preceding arguments (str or None) as well as the action which in this case is Callable[[Buffer], int] for f.write.
There's probably more elegant ways to overload hopefully at this point, as long as it's an option for us in the versions we support.
Edit: sorry ok it's easier than this, I think. WIll have a PR soon.
hi, @nejch thanks for update if you guys are busy, I can create a pull request, I am just not sure what is the proper way to fix it. I would just use in overload: [Callable[..., Any]], but not sure if it is ok.
action= can take any callable that accepts a single bytes argument. The return is not used at all and can be set to Any.
I need to test if Callable[[bytes], int] would accept the f.write method or if a protocol would be needed.
Thanks @igorp-collabora I was also just looking at this and looks like that would work, though maybe the new Buffer protocol from 3.12 would be better in the long run. I was wondering why we had that specific signature from #2211. I've added this in #3106 for now.
Activity
nejch commentedon Jan 28, 2025
Thanks for the report @kesmik. Seems like we're not fully addressing all the variants of
actionthat can be passed. I'll take a quick look at this and re-release after merge if necessary.nejch commentedon Jan 28, 2025
@JohnVillalovos @igorp-collabora this was my fear with typing overloads, I think we have to provide all the variations of preceding arguments (str or None) as well as the
actionwhich in this case isCallable[[Buffer], int]forf.write.There's probably more elegant ways to overload hopefully at this point, as long as it's an option for us in the versions we support.
Edit: sorry ok it's easier than this, I think. WIll have a PR soon.
kesmik commentedon Jan 28, 2025
hi, @nejch thanks for update if you guys are busy, I can create a pull request, I am just not sure what is the proper way to fix it. I would just use in overload: [Callable[..., Any]], but not sure if it is ok.
igorp-collabora commentedon Jan 28, 2025
action=can take any callable that accepts a singlebytesargument. The return is not used at all and can be set toAny.I need to test if
Callable[[bytes], Any]would accept thef.writemethod or if a protocol would be needed.nejch commentedon Jan 28, 2025
Thanks @igorp-collabora I was also just looking at this and looks like that would work, though maybe the new
Bufferprotocol from 3.12 would be better in the long run. I was wondering why we had that specific signature from #2211. I've added this in #3106 for now.igorp-collabora commentedon Jan 28, 2025
@nejch @JohnVillalovos using
Callable[[bytes], Any]fixes this issue.I created this typing file:
Before it would raise the same type checking errors.
After this patch there are no errors:
nejch commentedon Jan 28, 2025
I triggered a new release in case this is affecting version bumps out in the wild.