-
Notifications
You must be signed in to change notification settings - Fork 671
mypy type checker fails on 5.4.0 ProjectFileManager raw method #3104
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
Thanks for the report @kesmik. Seems like we're not fully addressing all the variants of |
@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 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. |
I need to test if |
Thanks @igorp-collabora I was also just looking at this and looks like that would work, though maybe the new |
@nejch @JohnVillalovos using I created this typing file: from gitlab import Gitlab
import tempfile
def test(api: Gitlab, prj_id: int, suffix: str, path: str, ref: str) -> None:
with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as f:
project = api.projects.get(prj_id, lazy=True)
project.files.raw(
file_path=path,
ref=ref,
streamed=True,
action=f.write,
)
def test2(api: Gitlab, prj_id: int, suffix: str, path: str, ref: str) -> None:
with open("test.file", "wb") as f:
project = api.projects.get(prj_id, lazy=True)
project.files.raw(
file_path=path,
ref=ref,
streamed=True,
action=f.write,
) Before it would raise the same type checking errors. After this patch there are no errors: diff --git a/gitlab/v4/objects/files.py b/gitlab/v4/objects/files.py
index ce2193c2..e1f7b229 100644
--- a/gitlab/v4/objects/files.py
+++ b/gitlab/v4/objects/files.py
@@ -308,7 +308,7 @@ class ProjectFileManager(CreateMixin, UpdateMixin, DeleteMixin, RESTManager):
file_path: str,
ref: Optional[str] = None,
streamed: Literal[True] = True,
- action: Optional[Callable[[bytes], None]] = None,
+ action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
|
I triggered a new release in case this is affecting version bumps out in the wild. |
Uh oh!
There was an error while loading. Please reload this page.
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?
Expected Behavior
Passing mypy
Actual Behavior
Specifications
The text was updated successfully, but these errors were encountered: