diff --git a/github/Project.py b/github/Project.py
index b443b9e7..711fafec 100644
--- a/github/Project.py
+++ b/github/Project.py
@@ -19,131 +19,110 @@
# along with PyGithub. If not, see . #
# #
################################################################################
+from __future__ import annotations
-from typing import Any, Dict
+from datetime import datetime
+from typing import Any
import github.GithubObject
+import github.NamedUser
import github.ProjectColumn
-
-from . import Consts
+from github import Consts
+from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt
+from github.PaginatedList import PaginatedList
-class Project(github.GithubObject.CompletableGithubObject):
+class Project(CompletableGithubObject):
"""
This class represents Projects. The reference can be found here https://docs.github.com/en/rest/reference/projects
"""
+ def _initAttributes(self) -> None:
+ self._body: Attribute[str] = NotSet
+ self._columns_url: Attribute[str] = NotSet
+ self._created_at: Attribute[datetime] = NotSet
+ self._creator: Attribute[github.NamedUser.NamedUser] = NotSet
+ self._html_url: Attribute[str] = NotSet
+ self._id: Attribute[int] = NotSet
+ self._name: Attribute[str] = NotSet
+ self._node_id: Attribute[str] = NotSet
+ self._number: Attribute[int] = NotSet
+ self._owner_url: Attribute[str] = NotSet
+ self._state: Attribute[str] = NotSet
+ self._updated_at: Attribute[datetime] = NotSet
+ self._url: Attribute[str] = NotSet
+
def __repr__(self) -> str:
return self.get__repr__({"name": self._name.value})
@property
- def body(self):
- """
- :type: string
- """
+ def body(self) -> str:
self._completeIfNotSet(self._body)
return self._body.value
@property
- def columns_url(self):
- """
- :type: string
- """
+ def columns_url(self) -> str:
self._completeIfNotSet(self._columns_url)
return self._columns_url.value
@property
- def created_at(self):
- """
- :type: datetime.datetime
- """
+ def created_at(self) -> datetime:
self._completeIfNotSet(self._created_at)
return self._created_at.value
@property
- def creator(self):
- """
- :type: :class:`github.NamedUser.NamedUser`
- """
+ def creator(self) -> github.NamedUser.NamedUser:
self._completeIfNotSet(self._creator)
return self._creator.value
@property
- def html_url(self):
- """
- :type: string
- """
+ def html_url(self) -> str:
self._completeIfNotSet(self._html_url)
return self._html_url.value
@property
- def id(self):
- """
- :type: integer
- """
+ def id(self) -> int:
self._completeIfNotSet(self._id)
return self._id.value
@property
- def name(self):
- """
- :type: string
- """
+ def name(self) -> str:
self._completeIfNotSet(self._name)
return self._name.value
@property
- def node_id(self):
- """
- :type: string
- """
+ def node_id(self) -> str:
self._completeIfNotSet(self._node_id)
return self._node_id.value
@property
- def number(self):
- """
- :type: integer
- """
+ def number(self) -> int:
self._completeIfNotSet(self._number)
return self._number.value
@property
- def owner_url(self):
- """
- :type: string
- """
+ def owner_url(self) -> str:
self._completeIfNotSet(self._owner_url)
return self._owner_url.value
@property
- def state(self):
- """
- :type: string
- """
+ def state(self) -> str:
self._completeIfNotSet(self._state)
return self._state.value
@property
- def updated_at(self):
- """
- :type: datetime.datetime
- """
+ def updated_at(self) -> datetime:
self._completeIfNotSet(self._updated_at)
return self._updated_at.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 /projects/{project_id} `_
- :rtype: None
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview}
@@ -151,39 +130,30 @@ class Project(github.GithubObject.CompletableGithubObject):
def edit(
self,
- name=github.GithubObject.NotSet,
- body=github.GithubObject.NotSet,
- state=github.GithubObject.NotSet,
- organization_permission=github.GithubObject.NotSet,
- private=github.GithubObject.NotSet,
- ):
+ name: Opt[str] = NotSet,
+ body: Opt[str] = NotSet,
+ state: Opt[str] = NotSet,
+ organization_permission: Opt[str] = NotSet,
+ private: Opt[bool] = NotSet,
+ ) -> None:
"""
:calls: `PATCH /projects/{project_id} `_
- :param name: string
- :param body: string
- :param state: string
- :param organization_permission: string
- :param private: bool
- :rtype: None
"""
- assert name is github.GithubObject.NotSet or isinstance(name, str), name
- assert body is github.GithubObject.NotSet or isinstance(body, str), body
- assert state is github.GithubObject.NotSet or isinstance(state, str), state
- assert organization_permission is github.GithubObject.NotSet or isinstance(
- organization_permission, str
- ), organization_permission
- assert private is github.GithubObject.NotSet or isinstance(private, bool), private
- patch_parameters = dict()
- if name is not github.GithubObject.NotSet:
- patch_parameters["name"] = name
- if body is not github.GithubObject.NotSet:
- patch_parameters["body"] = body
- if state is not github.GithubObject.NotSet:
- patch_parameters["state"] = state
- if organization_permission is not github.GithubObject.NotSet:
- patch_parameters["organization_permission"] = organization_permission
- if private is not github.GithubObject.NotSet:
- patch_parameters["private"] = private
+ assert name is NotSet or isinstance(name, str), name
+ assert body is NotSet or isinstance(body, str), body
+ assert state is NotSet or isinstance(state, str), state
+ assert organization_permission is NotSet or isinstance(organization_permission, str), organization_permission
+ assert private is NotSet or isinstance(private, bool), private
+ patch_parameters = NotSet.remove_unset_items(
+ {
+ "name": name,
+ "body": body,
+ "state": state,
+ "organization_permission": organization_permission,
+ "private": private,
+ }
+ )
+
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
@@ -192,13 +162,12 @@ class Project(github.GithubObject.CompletableGithubObject):
)
self._useAttributes(data)
- def get_columns(self):
+ def get_columns(self) -> PaginatedList[github.ProjectColumn.ProjectColumn]:
"""
:calls: `GET /projects/{project_id}/columns `_
- :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectColumn.ProjectColumn`
"""
- return github.PaginatedList.PaginatedList(
+ return PaginatedList(
github.ProjectColumn.ProjectColumn,
self._requester,
self.columns_url,
@@ -206,10 +175,9 @@ class Project(github.GithubObject.CompletableGithubObject):
{"Accept": Consts.mediaTypeProjectsPreview},
)
- def create_column(self, name):
+ def create_column(self, name: str) -> github.ProjectColumn.ProjectColumn:
"""
calls: `POST /projects/{project_id}/columns `_
- :param name: string
"""
assert isinstance(name, str), name
post_parameters = {"name": name}
@@ -219,22 +187,7 @@ class Project(github.GithubObject.CompletableGithubObject):
)
return github.ProjectColumn.ProjectColumn(self._requester, headers, data, completed=True)
- def _initAttributes(self) -> None:
- self._body = github.GithubObject.NotSet
- self._columns_url = github.GithubObject.NotSet
- self._created_at = github.GithubObject.NotSet
- self._creator = github.GithubObject.NotSet
- self._html_url = github.GithubObject.NotSet
- self._id = github.GithubObject.NotSet
- self._name = github.GithubObject.NotSet
- self._node_id = github.GithubObject.NotSet
- self._number = github.GithubObject.NotSet
- self._owner_url = github.GithubObject.NotSet
- self._state = github.GithubObject.NotSet
- self._updated_at = github.GithubObject.NotSet
- self._url = github.GithubObject.NotSet
-
- def _useAttributes(self, attributes: Dict[str, Any]) -> None:
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "body" in attributes: # pragma no branch
self._body = self._makeStringAttribute(attributes["body"])
if "columns_url" in attributes: # pragma no branch
diff --git a/github/Project.pyi b/github/Project.pyi
deleted file mode 100644
index 9ab38c30..00000000
--- a/github/Project.pyi
+++ /dev/null
@@ -1,40 +0,0 @@
-from datetime import datetime
-from typing import Any, Dict
-
-from github.GithubObject import CompletableGithubObject
-from github.NamedUser import NamedUser
-from github.PaginatedList import PaginatedList
-from github.ProjectColumn import ProjectColumn
-
-class Project(CompletableGithubObject):
- def __repr__(self) -> str: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
- @property
- def body(self) -> str: ...
- @property
- def columns_url(self) -> str: ...
- def create_column(self, name: str) -> ProjectColumn: ...
- @property
- def created_at(self) -> datetime: ...
- @property
- def creator(self) -> NamedUser: ...
- def get_columns(self) -> PaginatedList[ProjectColumn]: ...
- @property
- def html_url(self) -> str: ...
- @property
- def id(self) -> int: ...
- @property
- def name(self) -> str: ...
- @property
- def node_id(self) -> str: ...
- @property
- def number(self) -> int: ...
- @property
- def owner_url(self) -> str: ...
- @property
- def state(self) -> str: ...
- @property
- def updated_at(self) -> datetime: ...
- @property
- def url(self) -> str: ...