Skip to content

Commit

Permalink
Change: Use StrEnum for all GitHub models
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks committed Nov 17, 2023
1 parent d98108e commit a4df543
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 58 deletions.
15 changes: 7 additions & 8 deletions pontos/github/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from dataclasses import dataclass
from enum import Enum
from typing import List, Optional

from pontos.models import Model
from pontos.models import Model, StrEnum

__all__ = (
"App",
Expand All @@ -35,7 +34,7 @@
)


class FileStatus(Enum):
class FileStatus(StrEnum):
"""
File status
Expand Down Expand Up @@ -110,7 +109,7 @@ class User(GitHubModel):
site_admin: bool


class TeamPrivacy(Enum):
class TeamPrivacy(StrEnum):
"""
Team privacy
Expand All @@ -123,7 +122,7 @@ class TeamPrivacy(Enum):
CLOSED = "closed"


class TeamRole(Enum):
class TeamRole(StrEnum):
"""
A user's role withing a team
Expand All @@ -137,7 +136,7 @@ class TeamRole(Enum):
MAINTAINER = "maintainer"


class Permission(Enum):
class Permission(StrEnum):
# pylint: disable=line-too-long
"""
Permissions on a repository/project at GitHub
Expand Down Expand Up @@ -225,7 +224,7 @@ class App(GitHubModel):
events: List[str]


class Event(Enum):
class Event(StrEnum):
"""
A GitHub event type
Expand Down Expand Up @@ -309,7 +308,7 @@ class Event(Enum):
WORKFLOW_RUN = "workflow_run"


class SortOrder(Enum):
class SortOrder(StrEnum):
"""
Sort order: asc or desc
Expand Down
22 changes: 11 additions & 11 deletions pontos/github/models/code_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Optional

from pontos.github.models.base import GitHubModel, User
from pontos.github.models.organization import Repository
from pontos.models import StrEnum


class AlertState(Enum):
class AlertState(StrEnum):
"""
State of a code scanning alert
"""
Expand All @@ -21,7 +21,7 @@ class AlertState(Enum):
FIXED = "fixed"


class AlertSort(Enum):
class AlertSort(StrEnum):
"""
The property by which to sort the alerts
"""
Expand All @@ -30,7 +30,7 @@ class AlertSort(Enum):
UPDATED = "updated"


class DismissedReason(Enum):
class DismissedReason(StrEnum):
"""
The reason for dismissing or closing the alert
"""
Expand All @@ -40,7 +40,7 @@ class DismissedReason(Enum):
USED_IN_TESTS = "used in tests"


class Severity(Enum):
class Severity(StrEnum):
"""
The severity of the alert
"""
Expand All @@ -51,7 +51,7 @@ class Severity(Enum):
ERROR = "error"


class SecuritySeverityLevel(Enum):
class SecuritySeverityLevel(StrEnum):
"""
The security severity of the alert
"""
Expand All @@ -62,7 +62,7 @@ class SecuritySeverityLevel(Enum):
CRITICAL = "critical"


class Classification(Enum):
class Classification(StrEnum):
"""
A classification of the file. For example to identify it as generated
"""
Expand Down Expand Up @@ -316,7 +316,7 @@ class CodeQLDatabase(GitHubModel):
commit_oid: Optional[str] = None


class DefaultSetupState(Enum):
class DefaultSetupState(StrEnum):
"""
State of a default setup
"""
Expand All @@ -325,7 +325,7 @@ class DefaultSetupState(Enum):
NOT_CONFIGURED = "not-configured"


class Language(Enum):
class Language(StrEnum):
"""
Analyzed Language
"""
Expand All @@ -342,7 +342,7 @@ class Language(Enum):
SWIFT = "swift"


class QuerySuite(Enum):
class QuerySuite(StrEnum):
"""
Used code scanning query suite
"""
Expand Down Expand Up @@ -371,7 +371,7 @@ class DefaultSetup(GitHubModel):
schedule: Optional[str] = None


class SarifProcessingStatus(Enum):
class SarifProcessingStatus(StrEnum):
"""
`pending` files have not yet been processed, while `complete` means results
from the SARIF have been stored. `failed` files have either not been
Expand Down
14 changes: 7 additions & 7 deletions pontos/github/models/dependabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Optional

from pontos.github.models.base import GitHubModel, User
from pontos.github.models.organization import Repository
from pontos.models import StrEnum


class AlertSort(Enum):
class AlertSort(StrEnum):
"""
The property by which to sort the alerts
"""
Expand All @@ -20,7 +20,7 @@ class AlertSort(Enum):
UPDATED = "updated"


class AlertState(Enum):
class AlertState(StrEnum):
"""
State of the GitHub Dependabot Security Alert
"""
Expand All @@ -31,7 +31,7 @@ class AlertState(Enum):
OPEN = "open"


class DismissedReason(Enum):
class DismissedReason(StrEnum):
"""
Reason phrase for a dismissed Dependabot alert
"""
Expand All @@ -43,7 +43,7 @@ class DismissedReason(Enum):
TOLERABLE_RISK = "tolerable_risk"


class DependencyScope(Enum):
class DependencyScope(StrEnum):
"""
The execution scope of the vulnerable dependency
"""
Expand All @@ -52,7 +52,7 @@ class DependencyScope(Enum):
RUNTIME = "runtime"


class Severity(Enum):
class Severity(StrEnum):
"""
The severity of the vulnerability
"""
Expand All @@ -63,7 +63,7 @@ class Severity(Enum):
CRITICAL = "critical"


class IdentifierType(Enum):
class IdentifierType(StrEnum):
"""
The type of advisory identifier
"""
Expand Down
24 changes: 12 additions & 12 deletions pontos/github/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import List, Optional

from pontos.github.models.base import GitHubModel, User
from pontos.models import StrEnum

__all__ = (
"CodeOfConduct",
Expand All @@ -44,7 +44,7 @@
)


class MergeCommitTitle(Enum):
class MergeCommitTitle(StrEnum):
"""
Merge commit title
Expand All @@ -57,7 +57,7 @@ class MergeCommitTitle(Enum):
MERGE_MESSAGE = "MERGE_MESSAGE"


class MergeCommitMessage(Enum):
class MergeCommitMessage(StrEnum):
"""
Merge commit message setting
Expand All @@ -72,7 +72,7 @@ class MergeCommitMessage(Enum):
BLANK = "BLANK"


class SquashMergeCommitTitle(Enum):
class SquashMergeCommitTitle(StrEnum):
"""
Squash merge commit title
Expand All @@ -85,7 +85,7 @@ class SquashMergeCommitTitle(Enum):
COMMIT_OR_PR_TITLE = "COMMIT_OR_PR_TITLE"


class SquashMergeCommitMessage(Enum):
class SquashMergeCommitMessage(StrEnum):
"""
Squash merge commit message setting
Expand All @@ -100,7 +100,7 @@ class SquashMergeCommitMessage(Enum):
BLANK = "BLANK"


class RepositoryType(Enum):
class RepositoryType(StrEnum):
"""
A repository type
Expand Down Expand Up @@ -235,7 +235,7 @@ class CodeOfConduct(GitHubModel):
html_url: str


class SecurityAndAnalysisStatus(Enum):
class SecurityAndAnalysisStatus(StrEnum):
"""
Security and analysis status
Expand Down Expand Up @@ -486,7 +486,7 @@ class Repository(GitHubModel):
web_commit_signoff_required: Optional[bool] = None


class MemberFilter(Enum):
class MemberFilter(StrEnum):
"""
A member filter
Expand All @@ -499,7 +499,7 @@ class MemberFilter(Enum):
ALL = "all"


class MemberRole(Enum):
class MemberRole(StrEnum):
"""
A member role
Expand All @@ -514,7 +514,7 @@ class MemberRole(Enum):
MEMBER = "member"


class InvitationRole(Enum):
class InvitationRole(StrEnum):
"""
A invitation role
Expand All @@ -530,7 +530,7 @@ class InvitationRole(Enum):
BILLING_MANAGER = "billing_manager"


class GitIgnoreTemplate(Enum):
class GitIgnoreTemplate(StrEnum):
"""
Just a small part of the available gitignore templates at
https://github.com/github/gitignore
Expand Down Expand Up @@ -558,7 +558,7 @@ class GitIgnoreTemplate(Enum):
RUST = "Rust"


class LicenseType(Enum):
class LicenseType(StrEnum):
"""
License Type
Expand Down
10 changes: 5 additions & 5 deletions pontos/github/models/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import List, Optional

from pontos.github.models.base import FileStatus, GitHubModel, Team, User
from pontos.github.models.organization import Repository
from pontos.models import StrEnum

__all__ = (
"AuthorAssociation",
Expand Down Expand Up @@ -237,7 +237,7 @@ class Label(GitHubModel):
description: Optional[str] = None


class MilestoneState(Enum):
class MilestoneState(StrEnum):
"""
State of a pull request milestone (open, closed)
Expand Down Expand Up @@ -312,7 +312,7 @@ class PullRequestRef(GitHubModel):
repo: Repository


class PullRequestState(Enum):
class PullRequestState(StrEnum):
"""
Pull request state
Expand All @@ -325,7 +325,7 @@ class PullRequestState(Enum):
CLOSED = "closed"


class AuthorAssociation(Enum):
class AuthorAssociation(StrEnum):
"""
Pull request author association
Expand Down Expand Up @@ -408,7 +408,7 @@ class Comment(GitHubModel):
reactions: Optional[Reactions] = None


class MergeMethod(Enum):
class MergeMethod(StrEnum):
"""
The (auto) merge method
Expand Down
Loading

0 comments on commit a4df543

Please sign in to comment.