diff options
| author | John L. Villalovos <john@sodarock.com> | 2022-02-06 11:37:51 -0800 |
|---|---|---|
| committer | John L. Villalovos <john@sodarock.com> | 2022-02-06 11:37:51 -0800 |
| commit | 6ca9aa2960623489aaf60324b4709848598aec91 (patch) | |
| tree | aa1fffb8cd926cc3c096684b0f07475b5f60bec5 /gitlab/v4/objects | |
| parent | 4cb7d9224fb24e4a13fdff8271de5ce083ad7757 (diff) | |
| download | gitlab-6ca9aa2960623489aaf60324b4709848598aec91.tar.gz | |
chore: create a custom `warnings.warn` wrapper
Create a custom `warnings.warn` wrapper that will walk the stack trace
to find the first frame outside of the `gitlab/` path to print the
warning against. This will make it easier for users to find where in
their code the error is generated from
Diffstat (limited to 'gitlab/v4/objects')
| -rw-r--r-- | gitlab/v4/objects/artifacts.py | 11 | ||||
| -rw-r--r-- | gitlab/v4/objects/projects.py | 21 |
2 files changed, 18 insertions, 14 deletions
diff --git a/gitlab/v4/objects/artifacts.py b/gitlab/v4/objects/artifacts.py index dee2880..55d762b 100644 --- a/gitlab/v4/objects/artifacts.py +++ b/gitlab/v4/objects/artifacts.py @@ -2,7 +2,6 @@ GitLab API: https://docs.gitlab.com/ee/api/job_artifacts.html """ -import warnings from typing import Any, Callable, Optional, TYPE_CHECKING import requests @@ -34,10 +33,12 @@ class ProjectArtifactManager(RESTManager): *args: Any, **kwargs: Any, ) -> Optional[bytes]: - warnings.warn( - "The project.artifacts() method is deprecated and will be " - "removed in a future version. Use project.artifacts.download() instead.\n", - DeprecationWarning, + utils.warn( + message=( + "The project.artifacts() method is deprecated and will be removed in a " + "future version. Use project.artifacts.download() instead.\n" + ), + category=DeprecationWarning, ) return self.download( *args, diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index d1e993b..81eb624 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -1,4 +1,3 @@ -import warnings from typing import Any, Callable, cast, Dict, List, Optional, TYPE_CHECKING, Union import requests @@ -548,10 +547,12 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO @cli.register_custom_action("Project", ("to_namespace",)) def transfer_project(self, *args: Any, **kwargs: Any) -> None: - warnings.warn( - "The project.transfer_project() method is deprecated and will be " - "removed in a future version. Use project.transfer() instead.", - DeprecationWarning, + utils.warn( + message=( + "The project.transfer_project() method is deprecated and will be " + "removed in a future version. Use project.transfer() instead." + ), + category=DeprecationWarning, ) return self.transfer(*args, **kwargs) @@ -562,10 +563,12 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO *args: Any, **kwargs: Any, ) -> Optional[bytes]: - warnings.warn( - "The project.artifact() method is deprecated and will be " - "removed in a future version. Use project.artifacts.raw() instead.", - DeprecationWarning, + utils.warn( + message=( + "The project.artifact() method is deprecated and will be " + "removed in a future version. Use project.artifacts.raw() instead." + ), + category=DeprecationWarning, ) return self.artifacts.raw(*args, **kwargs) |
