Skip to content

chore: relax typing constraints for response action #3106

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

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gitlab/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def download(
def download(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -652,7 +652,7 @@ def download(
def download(
self,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion gitlab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def format(self, record: logging.LogRecord) -> str:
def response_content(
response: requests.Response,
streamed: bool,
action: Optional[Callable[[bytes], None]],
action: Optional[Callable[[bytes], Any]],
chunk_size: int,
*,
iterator: bool,
Expand Down
8 changes: 4 additions & 4 deletions gitlab/v4/objects/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def download(
ref_name: str,
job: str,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -102,7 +102,7 @@ def download(
ref_name: str,
job: str,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down Expand Up @@ -177,7 +177,7 @@ def raw(
artifact_path: str,
job: str,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -195,7 +195,7 @@ def raw(
artifact_path: str,
job: str,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion gitlab/v4/objects/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def raw(
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,
Expand Down
6 changes: 3 additions & 3 deletions gitlab/v4/objects/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def artifacts(
def artifacts(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down Expand Up @@ -229,7 +229,7 @@ def artifact(
self,
path: str,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down Expand Up @@ -305,7 +305,7 @@ def trace(
def trace(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def download(
package_version: str,
file_name: str,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -177,7 +177,7 @@ def download(
package_version: str,
file_name: str,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def snapshot(
self,
wiki: bool = False,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -536,7 +536,7 @@ def snapshot(
self,
wiki: bool = False,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def repository_raw_blob(
self,
sha: str,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down Expand Up @@ -273,7 +273,7 @@ def repository_archive(
self,
sha: 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,
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/secure_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def download(
def download(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand All @@ -66,7 +66,7 @@ def download(
def download(
self,
streamed: bool = False,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: bool = False,
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def content(
def content(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down Expand Up @@ -237,7 +237,7 @@ def content(
def content(
self,
streamed: Literal[True] = True,
action: Optional[Callable[[bytes], None]] = None,
action: Optional[Callable[[bytes], Any]] = None,
chunk_size: int = 1024,
*,
iterator: Literal[False] = False,
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/api/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_project_import_export(gl, project, temp_dir):
raise Exception("Project export taking too much time")

with open(temp_dir / "gitlab-export.tgz", "wb") as f:
export.download(streamed=True, action=f.write) # type: ignore[call-overload]
export.download(streamed=True, action=f.write)

output = gl.projects.import_project(
open(temp_dir / "gitlab-export.tgz", "rb"),
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/objects/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,13 @@ def test_transfer_project(project, resp_transfer_project):


def test_project_pull_mirror(project, resp_start_pull_mirroring_project):
project.mirror_pull()
with pytest.warns(DeprecationWarning, match="is deprecated"):
project.mirror_pull()


def test_project_pull_mirror_details(project, resp_pull_mirror_details_project):
details = project.mirror_pull_details()
with pytest.warns(DeprecationWarning, match="is deprecated"):
details = project.mirror_pull_details()
assert details["last_error"] is None
assert details["update_status"] == "finished"

Expand Down
Loading