mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Merge Code* type stub back to source (#2615)
Co-authored-by: Enrico Minack <github@enrico.minack.dev>
This commit is contained in:
+35
-72
@@ -19,140 +19,103 @@
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import github.CodeScanAlertInstance
|
||||
import github.CodeScanRule
|
||||
import github.CodeScanTool
|
||||
import github.GithubObject
|
||||
import github.NamedUser
|
||||
import github.PaginatedList
|
||||
from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
|
||||
from github.PaginatedList import PaginatedList
|
||||
|
||||
|
||||
class CodeScanAlert(github.GithubObject.NonCompletableGithubObject):
|
||||
class CodeScanAlert(NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents alerts from code scanning.
|
||||
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.
|
||||
"""
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._number: Attribute[int] = NotSet
|
||||
self._rule: Attribute[github.CodeScanRule.CodeScanRule] = NotSet
|
||||
self._tool: Attribute[github.CodeScanTool.CodeScanTool] = NotSet
|
||||
self._created_at: Attribute[datetime] = NotSet
|
||||
self._dismissed_at: Attribute[datetime | None] = NotSet
|
||||
self._dismissed_by: Attribute[dict | None] = NotSet
|
||||
self._dismissed_reason: Attribute[str | None] = NotSet
|
||||
self._url: Attribute[str] = NotSet
|
||||
self._html_url: Attribute[str] = NotSet
|
||||
self._instances_url: Attribute[str] = NotSet
|
||||
self._most_recent_instance: Attribute[github.CodeScanAlertInstance.CodeScanAlertInstance] = NotSet
|
||||
self._state: Attribute[str] = NotSet
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.get__repr__({"number": self.number})
|
||||
|
||||
@property
|
||||
def number(self):
|
||||
"""
|
||||
:type: int
|
||||
"""
|
||||
def number(self) -> int:
|
||||
return self._number.value
|
||||
|
||||
@property
|
||||
def rule(self):
|
||||
"""
|
||||
:type: :class: `github.CodeScanRule.CodeScanRule`
|
||||
"""
|
||||
def rule(self) -> github.CodeScanRule.CodeScanRule:
|
||||
return self._rule.value
|
||||
|
||||
@property
|
||||
def tool(self):
|
||||
"""
|
||||
:type: :class: `github.CodeScanTool.CodeScanTool`
|
||||
"""
|
||||
def tool(self) -> github.CodeScanTool.CodeScanTool:
|
||||
return self._tool.value
|
||||
|
||||
@property
|
||||
def created_at(self):
|
||||
"""
|
||||
:type: datetime
|
||||
"""
|
||||
def created_at(self) -> datetime:
|
||||
return self._created_at.value
|
||||
|
||||
@property
|
||||
def dismissed_at(self):
|
||||
"""
|
||||
:type: datetime
|
||||
"""
|
||||
def dismissed_at(self) -> datetime | None:
|
||||
return self._dismissed_at.value
|
||||
|
||||
@property
|
||||
def dismissed_by(self):
|
||||
"""
|
||||
:type: :class: `github.NamedUser.NamedUser`
|
||||
"""
|
||||
def dismissed_by(self) -> dict | None:
|
||||
return self._dismissed_by.value
|
||||
|
||||
@property
|
||||
def dismissed_reason(self):
|
||||
"""
|
||||
:type: str
|
||||
"""
|
||||
def dismissed_reason(self) -> str | None:
|
||||
return self._dismissed_reason.value
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def url(self) -> str:
|
||||
return self._url.value
|
||||
|
||||
@property
|
||||
def html_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def html_url(self) -> str:
|
||||
return self._html_url.value
|
||||
|
||||
@property
|
||||
def instances_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def instances_url(self) -> str:
|
||||
return self._instances_url.value
|
||||
|
||||
@property
|
||||
def most_recent_instance(self):
|
||||
"""
|
||||
:type: :class: github.CodeScanAlertInstance.CodeScanAlertInstance
|
||||
"""
|
||||
def most_recent_instance(self) -> github.CodeScanAlertInstance.CodeScanAlertInstance:
|
||||
return self._most_recent_instance.value
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""
|
||||
:type: str
|
||||
"""
|
||||
def state(self) -> str:
|
||||
return self._state.value
|
||||
|
||||
def get_instances(self):
|
||||
def get_instances(self) -> PaginatedList[github.CodeScanAlertInstance.CodeScanAlertInstance]:
|
||||
"""
|
||||
:calls: `GET` on the URL for instances as provided by Github
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CodeScanAlertInstance.CodeScanAlertInstance`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
return PaginatedList(
|
||||
github.CodeScanAlertInstance.CodeScanAlertInstance,
|
||||
self._requester,
|
||||
self.instances_url,
|
||||
None,
|
||||
)
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._number = github.GithubObject.NotSet
|
||||
self._rule = github.GithubObject.NotSet
|
||||
self._tool = github.GithubObject.NotSet
|
||||
|
||||
self._created_at = github.GithubObject.NotSet
|
||||
self._dismissed_at = github.GithubObject.NotSet
|
||||
self._dismissed_by = github.GithubObject.NotSet
|
||||
self._dismissed_reason = github.GithubObject.NotSet
|
||||
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._instances_url = github.GithubObject.NotSet
|
||||
|
||||
self._most_recent_instance = github.GithubObject.NotSet
|
||||
self._state = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
|
||||
def _useAttributes(self, attributes: dict[str, Any]) -> None:
|
||||
if "number" in attributes: # pragma no branch
|
||||
self._number = self._makeIntAttribute(attributes["number"])
|
||||
if "rule" in attributes: # pragma no branch
|
||||
|
||||
Reference in New Issue
Block a user