diff --git a/github/Label.py b/github/Label.py
index c8703cd3..9473a796 100644
--- a/github/Label.py
+++ b/github/Label.py
@@ -28,79 +28,61 @@
# along with PyGithub. If not, see . #
# #
################################################################################
-
import urllib.parse
from typing import Any, Dict
-import github.GithubObject
-
-from . import Consts
+from github import Consts
+from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_optional
-class Label(github.GithubObject.CompletableGithubObject):
+class Label(CompletableGithubObject):
"""
This class represents Labels. The reference can be found here https://docs.github.com/en/rest/reference/issues#labels
"""
+ def _initAttributes(self) -> None:
+ self._color: Attribute[str] = NotSet
+ self._description: Attribute[str] = NotSet
+ self._name: Attribute[str] = NotSet
+ self._url: Attribute[str] = NotSet
+
def __repr__(self) -> str:
return self.get__repr__({"name": self._name.value})
@property
- def color(self):
- """
- :type: string
- """
+ def color(self) -> str:
self._completeIfNotSet(self._color)
return self._color.value
@property
- def description(self):
- """
- :type: string
- """
+ def description(self) -> str:
self._completeIfNotSet(self._description)
return self._description.value
@property
- def name(self):
- """
- :type: string
- """
+ def name(self) -> str:
self._completeIfNotSet(self._name)
return self._name.value
@property
- def url(self):
- """
- :type: string
- """
+ def url(self) -> str:
self._completeIfNotSet(self._url)
return self._url.value
- def delete(self):
+ def delete(self) -> None:
"""
:calls: `DELETE /repos/{owner}/{repo}/labels/{name} `_
- :rtype: None
"""
headers, data = self._requester.requestJsonAndCheck("DELETE", self.url)
- def edit(self, name, color, description=github.GithubObject.NotSet):
+ def edit(self, name: str, color: str, description: Opt[str] = NotSet) -> None:
"""
:calls: `PATCH /repos/{owner}/{repo}/labels/{name} `_
- :param name: string
- :param color: string
- :param description: string
- :rtype: None
"""
assert isinstance(name, str), name
assert isinstance(color, str), color
- assert description is github.GithubObject.NotSet or isinstance(description, str), description
- post_parameters = {
- "new_name": name,
- "color": color,
- }
- if description is not github.GithubObject.NotSet:
- post_parameters["description"] = description
+ assert is_optional(description, str), description
+ post_parameters = NotSet.remove_unset_items({"new_name": name, "color": color, "description": description})
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
@@ -110,15 +92,9 @@ class Label(github.GithubObject.CompletableGithubObject):
self._useAttributes(data)
@property
- def _identity(self):
+ def _identity(self) -> str:
return urllib.parse.quote(self.name)
- def _initAttributes(self) -> None:
- self._color = github.GithubObject.NotSet
- self._description = github.GithubObject.NotSet
- self._name = github.GithubObject.NotSet
- self._url = github.GithubObject.NotSet
-
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
if "color" in attributes: # pragma no branch
self._color = self._makeStringAttribute(attributes["color"])
diff --git a/github/Label.pyi b/github/Label.pyi
deleted file mode 100644
index f205c8b6..00000000
--- a/github/Label.pyi
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any, Dict, Optional, Union
-
-from github.GithubObject import CompletableGithubObject, _NotSetType
-
-class Label(CompletableGithubObject):
- def __repr__(self) -> str: ...
- @property
- def _identity(self) -> str: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
- @property
- def color(self) -> str: ...
- def delete(self) -> None: ...
- @property
- def description(self) -> Optional[str]: ...
- def edit(self, name: str, color: str, description: Union[str, _NotSetType] = ...) -> None: ...
- @property
- def name(self) -> str: ...
- @property
- def url(self) -> str: ...