diff options
author | John L. Villalovos <john@sodarock.com> | 2021-02-26 17:35:02 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2021-02-28 08:48:31 -0800 |
commit | 907634fe4d0d30706656b8bc56260b5532613e62 (patch) | |
tree | 364677392e08928753133128174d049ff2c8c41d /gitlab/base.py | |
parent | d8b8a0a010b41465586dccf198582ae127a31530 (diff) | |
download | gitlab-907634fe4d0d30706656b8bc56260b5532613e62.tar.gz |
chore: disallow incomplete type defs
Don't allow a partially annotated function definition. Either none of
the function is annotated or all of it must be.
Update code to ensure no-more partially annotated functions.
Update gitlab/cli.py with better type-hints. Changed Tuple[Any, ...]
to Tuple[str, ...]
Diffstat (limited to 'gitlab/base.py')
-rw-r--r-- | gitlab/base.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gitlab/base.py b/gitlab/base.py index a3fdcf7..6334a6f 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -98,7 +98,7 @@ class RESTObject(object): except KeyError: raise AttributeError(name) - def __setattr__(self, name: str, value) -> None: + def __setattr__(self, name: str, value: Any) -> None: self.__dict__["_updated_attrs"][name] = value def __str__(self) -> str: @@ -116,12 +116,16 @@ class RESTObject(object): else: return "<%s>" % self.__class__.__name__ - def __eq__(self, other) -> bool: + def __eq__(self, other: object) -> bool: + if not isinstance(other, RESTObject): + return NotImplemented if self.get_id() and other.get_id(): return self.get_id() == other.get_id() return super(RESTObject, self) == other - def __ne__(self, other) -> bool: + def __ne__(self, other: object) -> bool: + if not isinstance(other, RESTObject): + return NotImplemented if self.get_id() and other.get_id(): return self.get_id() != other.get_id() return super(RESTObject, self) != other @@ -144,7 +148,7 @@ class RESTObject(object): manager = cls(self.manager.gitlab, parent=self) self.__dict__[attr] = manager - def _update_attrs(self, new_attrs) -> None: + def _update_attrs(self, new_attrs: Dict[str, Any]) -> None: self.__dict__["_updated_attrs"] = {} self.__dict__["_attrs"] = new_attrs |