diff options
author | John L. Villalovos <john@sodarock.com> | 2021-03-07 11:31:23 -0800 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-04-17 17:09:41 +0200 |
commit | aee1f496c1f414c1e30909767d53ae624fe875e7 (patch) | |
tree | 04a7fe9d8f77cffeae733bb8dd3447911995f3a1 /gitlab/base.py | |
parent | 8603248f73d8c751023fbfd2a394c5b7d939af7f (diff) | |
download | gitlab-aee1f496c1f414c1e30909767d53ae624fe875e7.tar.gz |
chore: have _create_attrs & _update_attrs be a namedtuple
Convert _create_attrs and _update_attrs to use a NamedTuple
(RequiredOptional) to help with code readability. Update all code to
use the NamedTuple.
Diffstat (limited to 'gitlab/base.py')
-rw-r--r-- | gitlab/base.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gitlab/base.py b/gitlab/base.py index 5eb1118..7b4e3f8 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -17,12 +17,13 @@ import importlib from types import ModuleType -from typing import Any, Dict, Optional, Tuple, Type +from typing import Any, Dict, NamedTuple, Optional, Tuple, Type from .client import Gitlab, GitlabList from gitlab import types as g_types __all__ = [ + "RequiredOptional", "RESTObject", "RESTObjectList", "RESTManager", @@ -249,6 +250,11 @@ class RESTObjectList(object): return self._list.total +class RequiredOptional(NamedTuple): + required: Tuple[str, ...] = tuple() + optional: Tuple[str, ...] = tuple() + + class RESTManager(object): """Base class for CRUD operations on objects. @@ -258,8 +264,8 @@ class RESTManager(object): ``_obj_cls``: The class of objects that will be created """ - _create_attrs: Tuple[Tuple[str, ...], Tuple[str, ...]] = (tuple(), tuple()) - _update_attrs: Tuple[Tuple[str, ...], Tuple[str, ...]] = (tuple(), tuple()) + _create_attrs: RequiredOptional = RequiredOptional() + _update_attrs: RequiredOptional = RequiredOptional() _path: Optional[str] = None _obj_cls: Optional[Type[RESTObject]] = None _from_parent_attrs: Dict[str, Any] = {} |