diff --git a/github/CodeScanAlert.py b/github/CodeScanAlert.py
index 5abe1403..f31c77e8 100644
--- a/github/CodeScanAlert.py
+++ b/github/CodeScanAlert.py
@@ -19,140 +19,103 @@
# 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.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
diff --git a/github/CodeScanAlert.pyi b/github/CodeScanAlert.pyi
deleted file mode 100644
index 51a42047..00000000
--- a/github/CodeScanAlert.pyi
+++ /dev/null
@@ -1,62 +0,0 @@
-############################ Copyrights and license ############################
-# #
-# Copyright 2022 Eric Nieuwland #
-# #
-# This file is part of PyGithub. #
-# http://pygithub.readthedocs.io/ #
-# #
-# PyGithub is free software: you can redistribute it and/or modify it under #
-# the terms of the GNU Lesser General Public License as published by the Free #
-# Software Foundation, either version 3 of the License, or (at your option) #
-# any later version. #
-# #
-# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
-# details. #
-# #
-# You should have received a copy of the GNU Lesser General Public License #
-# along with PyGithub. If not, see . #
-# #
-################################################################################
-
-from typing import Any, Dict
-from datetime import datetime
-
-import github.GithubObject
-import github.PaginatedList
-import github.CodeScanRule
-import github.CodeScanTool
-import github.CodeScanAlertInstance
-
-class CodeScanAlert(github.GithubObject.NonCompletableGithubObject):
- def __repr__(self) -> str: ...
- @property
- def number(self) -> int: ...
- @property
- def rule(self) -> github.CodeScanRule.CodeScanRule: ...
- @property
- def tool(self) -> github.CodeScanTool.CodeScanTool: ...
- @property
- def created_at(self) -> datetime: ...
- @property
- def dismissed_at(self) -> datetime: ...
- @property
- def dismissed_by(self) -> dict: ...
- @property
- def dismissed_reason(self) -> str: ...
- @property
- def url(self) -> str: ...
- @property
- def html_url(self) -> str: ...
- @property
- def instances_url(self) -> str: ...
- @property
- def most_recent_instance(
- self,
- ) -> github.CodeScanAlertInstance.CodeScanAlertInstance: ...
- @property
- def state(self) -> str: ...
- def get_instances(self) -> github.PaginatedList.PaginatedList: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
diff --git a/github/CodeScanAlertInstance.py b/github/CodeScanAlertInstance.py
index f3bbda0f..75ee0f54 100644
--- a/github/CodeScanAlertInstance.py
+++ b/github/CodeScanAlertInstance.py
@@ -19,89 +19,69 @@
# along with PyGithub. If not, see . #
# #
################################################################################
+from __future__ import annotations
-from typing import Any, Dict
+from typing import TYPE_CHECKING, Any
import github.CodeScanAlertInstanceLocation
-import github.GithubObject
+from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
+
+if TYPE_CHECKING:
+ from github.CodeScanAlertInstanceLocation import CodeScanAlertInstanceLocation
-class CodeScanAlertInstance(github.GithubObject.NonCompletableGithubObject):
+class CodeScanAlertInstance(NonCompletableGithubObject):
"""
This class represents code scanning alert instances.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.
"""
+ def _initAttributes(self) -> None:
+ self._ref: Attribute[str] = NotSet
+ self._analysis_key: Attribute[str] = NotSet
+ self._environment: Attribute[str] = NotSet
+ self._state: Attribute[str] = NotSet
+ self._commit_sha: Attribute[str] = NotSet
+ self._message: Attribute[dict[str, Any]] = NotSet
+ self._location: Attribute[CodeScanAlertInstanceLocation] = NotSet
+ self._classifications: Attribute[list[str]] = NotSet
+
def __repr__(self) -> str:
return self.get__repr__({"ref": self.ref, "analysis_key": self.analysis_key})
@property
- def ref(self):
- """
- :type: str
- """
+ def ref(self) -> str:
return self._ref.value
@property
- def analysis_key(self):
- """
- :type: str
- """
+ def analysis_key(self) -> str:
return self._analysis_key.value
@property
- def environment(self):
- """
- :type: str
- """
+ def environment(self) -> str:
return self._environment.value
@property
- def state(self):
- """
- :type: str
- """
+ def state(self) -> str:
return self._state.value
@property
- def commit_sha(self):
- """
- :type: str
- """
+ def commit_sha(self) -> str:
return self._commit_sha.value
@property
- def message(self):
- """
- :type: str
- """
+ def message(self) -> dict[str, Any]:
return self._message.value
@property
- def location(self):
- """
- :type: :class: `github.CodeScanAlertInstanceLocation.CodeScanAlertInstanceLocation`
- """
+ def location(self) -> CodeScanAlertInstanceLocation:
return self._location.value
@property
- def classifications(self):
- """
- :type: list of str
- """
+ def classifications(self) -> list[str]:
return self._classifications.value
- def _initAttributes(self) -> None:
- self._ref = github.GithubObject.NotSet
- self._analysis_key = github.GithubObject.NotSet
- self._environment = github.GithubObject.NotSet
- self._state = github.GithubObject.NotSet
- self._commit_sha = github.GithubObject.NotSet
- self._message = github.GithubObject.NotSet
- self._location = github.GithubObject.NotSet
- self._classifications = github.GithubObject.NotSet
-
- def _useAttributes(self, attributes: Dict[str, Any]) -> None:
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "ref" in attributes: # pragma no branch
self._ref = self._makeStringAttribute(attributes["ref"])
if "analysis_key" in attributes: # pragma no branch
diff --git a/github/CodeScanAlertInstance.pyi b/github/CodeScanAlertInstance.pyi
deleted file mode 100644
index b4b7e0e5..00000000
--- a/github/CodeScanAlertInstance.pyi
+++ /dev/null
@@ -1,49 +0,0 @@
-############################ Copyrights and license ############################
-# #
-# Copyright 2022 Eric Nieuwland #
-# #
-# This file is part of PyGithub. #
-# http://pygithub.readthedocs.io/ #
-# #
-# PyGithub is free software: you can redistribute it and/or modify it under #
-# the terms of the GNU Lesser General Public License as published by the Free #
-# Software Foundation, either version 3 of the License, or (at your option) #
-# any later version. #
-# #
-# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
-# details. #
-# #
-# You should have received a copy of the GNU Lesser General Public License #
-# along with PyGithub. If not, see . #
-# #
-################################################################################
-
-from typing import Any, Dict
-
-import github.GithubObject
-import github.CodeScanAlertInstanceLocation
-
-class CodeScanAlertInstance(github.GithubObject.NonCompletableGithubObject):
- def __repr__(self) -> str: ...
- @property
- def ref(self) -> str: ...
- @property
- def analysis_key(self) -> str: ...
- @property
- def environment(self) -> str: ...
- @property
- def state(self) -> str: ...
- @property
- def commit_sha(self) -> str: ...
- @property
- def message(self) -> str: ...
- @property
- def location(
- self,
- ) -> github.CodeScanAlertInstanceLocation.CodeScanAlertInstanceLocation: ...
- @property
- def classifications(self) -> list[str]: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
diff --git a/github/CodeScanAlertInstanceLocation.py b/github/CodeScanAlertInstanceLocation.py
index ce210bef..fad74665 100644
--- a/github/CodeScanAlertInstanceLocation.py
+++ b/github/CodeScanAlertInstanceLocation.py
@@ -19,19 +19,25 @@
# along with PyGithub. If not, see . #
# #
################################################################################
-
from typing import Any, Dict
-import github.GithubObject
+from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
-class CodeScanAlertInstanceLocation(github.GithubObject.NonCompletableGithubObject):
+class CodeScanAlertInstanceLocation(NonCompletableGithubObject):
"""
This class represents code scanning alert instance locations.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.
"""
- def __str__(self):
+ def _initAttributes(self) -> None:
+ self._path: Attribute[str] = NotSet
+ self._start_line: Attribute[int] = NotSet
+ self._start_column: Attribute[int] = NotSet
+ self._end_line: Attribute[int] = NotSet
+ self._end_column: Attribute[int] = NotSet
+
+ def __str__(self) -> str:
return f"{self.path} @ l{self.start_line}:c{self.start_column}-l{self.end_line}:c{self.end_column}"
def __repr__(self) -> str:
@@ -46,47 +52,25 @@ class CodeScanAlertInstanceLocation(github.GithubObject.NonCompletableGithubObje
)
@property
- def path(self):
- """
- :type: str
- """
+ def path(self) -> str:
return self._path.value
@property
- def start_line(self):
- """
- :type: int
- """
+ def start_line(self) -> int:
return self._start_line.value
@property
- def start_column(self):
- """
- :type: int
- """
+ def start_column(self) -> int:
return self._start_column.value
@property
- def end_line(self):
- """
- :type: int
- """
+ def end_line(self) -> int:
return self._end_line.value
@property
- def end_column(self):
- """
- :type: int
- """
+ def end_column(self) -> int:
return self._end_column.value
- def _initAttributes(self) -> None:
- self._path = github.GithubObject.NotSet
- self._start_line = github.GithubObject.NotSet
- self._start_column = github.GithubObject.NotSet
- self._end_line = github.GithubObject.NotSet
- self._end_column = github.GithubObject.NotSet
-
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
if "path" in attributes: # pragma no branch
self._path = self._makeStringAttribute(attributes["path"])
diff --git a/github/CodeScanAlertInstanceLocation.pyi b/github/CodeScanAlertInstanceLocation.pyi
deleted file mode 100644
index 0d8ab5e0..00000000
--- a/github/CodeScanAlertInstanceLocation.pyi
+++ /dev/null
@@ -1,41 +0,0 @@
-############################ Copyrights and license ############################
-# #
-# Copyright 2022 Eric Nieuwland #
-# #
-# This file is part of PyGithub. #
-# http://pygithub.readthedocs.io/ #
-# #
-# PyGithub is free software: you can redistribute it and/or modify it under #
-# the terms of the GNU Lesser General Public License as published by the Free #
-# Software Foundation, either version 3 of the License, or (at your option) #
-# any later version. #
-# #
-# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
-# details. #
-# #
-# You should have received a copy of the GNU Lesser General Public License #
-# along with PyGithub. If not, see . #
-# #
-################################################################################
-
-from typing import Any, Dict
-
-import github.GithubObject
-
-class CodeScanAlertInstanceLocation(github.GithubObject.NonCompletableGithubObject):
- def __str__(self) -> str: ...
- def __repr__(self) -> str: ...
- @property
- def path(self) -> str: ...
- @property
- def start_line(self) -> int: ...
- @property
- def start_column(self) -> int: ...
- @property
- def end_line(self) -> int: ...
- @property
- def end_column(self) -> int: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
diff --git a/github/CodeScanRule.py b/github/CodeScanRule.py
index 6af74862..98eb0f76 100644
--- a/github/CodeScanRule.py
+++ b/github/CodeScanRule.py
@@ -19,64 +19,50 @@
# along with PyGithub. If not, see . #
# #
################################################################################
+from __future__ import annotations
-from typing import Any, Dict
+from typing import Any
-import github.GithubObject
+from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
-class CodeScanRule(github.GithubObject.NonCompletableGithubObject):
+class CodeScanRule(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._id: Attribute[str] = NotSet
+ self._name: Attribute[str] = NotSet
+ self._severity: Attribute[str] = NotSet
+ self._security_severity_level: Attribute[str] = NotSet
+ self._description: Attribute[str] = NotSet
+
def __repr__(self) -> str:
return self.get__repr__({"id": self.id, "name": self.name})
@property
- def id(self):
- """
- :type: str
- """
+ def id(self) -> str:
return self._id.value
@property
- def name(self):
- """
- :type: str
- """
+ def name(self) -> str:
return self._name.value
@property
- def severity(self):
- """
- :type: str
- """
+ def severity(self) -> str:
return self._severity.value
@property
- def security_severity_level(self):
- """
- :type: str
- """
+ def security_severity_level(self) -> str:
return self._security_severity_level.value
@property
- def description(self):
- """
- :type: str
- """
+ def description(self) -> str:
return self._description.value
- def _initAttributes(self) -> None:
- self._id = github.GithubObject.NotSet
- self._name = github.GithubObject.NotSet
- self._severity = github.GithubObject.NotSet
- self._security_severity_level = github.GithubObject.NotSet
- self._description = github.GithubObject.NotSet
-
- def _useAttributes(self, attributes: Dict[str, Any]) -> None:
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "id" in attributes: # pragma no branch
self._id = self._makeStringAttribute(attributes["id"])
if "name" in attributes: # pragma no branch
diff --git a/github/CodeScanRule.pyi b/github/CodeScanRule.pyi
deleted file mode 100644
index c4b30feb..00000000
--- a/github/CodeScanRule.pyi
+++ /dev/null
@@ -1,40 +0,0 @@
-############################ Copyrights and license ############################
-# #
-# Copyright 2022 Eric Nieuwland #
-# #
-# This file is part of PyGithub. #
-# http://pygithub.readthedocs.io/ #
-# #
-# PyGithub is free software: you can redistribute it and/or modify it under #
-# the terms of the GNU Lesser General Public License as published by the Free #
-# Software Foundation, either version 3 of the License, or (at your option) #
-# any later version. #
-# #
-# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
-# details. #
-# #
-# You should have received a copy of the GNU Lesser General Public License #
-# along with PyGithub. If not, see . #
-# #
-################################################################################
-
-from typing import Any, Dict
-
-import github.GithubObject
-
-class CodeScanRule(github.GithubObject.NonCompletableGithubObject):
- def __repr__(self) -> str: ...
- @property
- def id(self) -> str: ...
- @property
- def name(self) -> str: ...
- @property
- def severity(self) -> str: ...
- @property
- def security_severity_level(self) -> str: ...
- @property
- def description(self) -> str: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
diff --git a/github/CodeScanTool.py b/github/CodeScanTool.py
index 0f5b2cd2..d944c8cb 100644
--- a/github/CodeScanTool.py
+++ b/github/CodeScanTool.py
@@ -22,15 +22,20 @@
from typing import Any, Dict
-import github.GithubObject
+from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
-class CodeScanTool(github.GithubObject.NonCompletableGithubObject):
+class CodeScanTool(NonCompletableGithubObject):
"""
This class represents code scanning tools.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.
"""
+ def _initAttributes(self) -> None:
+ self._name: Attribute[str] = NotSet
+ self._version: Attribute[str] = NotSet
+ self._guid: Attribute[str] = NotSet
+
def __repr__(self) -> str:
return self.get__repr__(
{
@@ -41,31 +46,17 @@ class CodeScanTool(github.GithubObject.NonCompletableGithubObject):
)
@property
- def name(self):
- """
- :type: str
- """
+ def name(self) -> str:
return self._name.value
@property
- def version(self):
- """
- :type: str
- """
+ def version(self) -> str:
return self._version.value
@property
- def guid(self):
- """
- :type: str
- """
+ def guid(self) -> str:
return self._guid.value
- def _initAttributes(self) -> None:
- self._name = github.GithubObject.NotSet
- self._version = github.GithubObject.NotSet
- self._guid = github.GithubObject.NotSet
-
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
if "name" in attributes: # pragma no branch
self._name = self._makeStringAttribute(attributes["name"])
diff --git a/github/CodeScanTool.pyi b/github/CodeScanTool.pyi
deleted file mode 100644
index 21a6b8dc..00000000
--- a/github/CodeScanTool.pyi
+++ /dev/null
@@ -1,36 +0,0 @@
-############################ Copyrights and license ############################
-# #
-# Copyright 2022 Eric Nieuwland #
-# #
-# This file is part of PyGithub. #
-# http://pygithub.readthedocs.io/ #
-# #
-# PyGithub is free software: you can redistribute it and/or modify it under #
-# the terms of the GNU Lesser General Public License as published by the Free #
-# Software Foundation, either version 3 of the License, or (at your option) #
-# any later version. #
-# #
-# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
-# details. #
-# #
-# You should have received a copy of the GNU Lesser General Public License #
-# along with PyGithub. If not, see . #
-# #
-################################################################################
-
-from typing import Any, Dict
-
-import github.GithubObject
-
-class CodeScanTool(github.GithubObject.NonCompletableGithubObject):
- def __repr__(self) -> str: ...
- @property
- def name(self) -> str: ...
- @property
- def version(self) -> str: ...
- @property
- def guid(self) -> str: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
diff --git a/github/GithubObject.py b/github/GithubObject.py
index 0f075cdb..60a71aae 100644
--- a/github/GithubObject.py
+++ b/github/GithubObject.py
@@ -221,7 +221,7 @@ class GithubObject:
return GithubObject.__makeSimpleAttribute(value, bool)
@staticmethod
- def _makeDictAttribute(value: Dict[str, Any]) -> Attribute[dict]:
+ def _makeDictAttribute(value: Dict[str, Any]) -> Attribute[Dict[str, Any]]:
return GithubObject.__makeSimpleAttribute(value, dict)
@staticmethod