Skip to content

Commit

Permalink
Remove typing refs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdnaneKhan committed May 15, 2024
1 parent 208f361 commit 4a243a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion gato/github/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ def get_org_secrets(self, org_name: str):

return secrets

def retrieve_composite_actions(self, repo_name: str, composite_actions: list):
def retrieve_composite_actions(self, repo_name: str, composite_actions: list[dict]):
"""Uses the repository contents API to retrieve the contents of the composite action.
"""

Expand Down
10 changes: 4 additions & 6 deletions gato/models/execution.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime

from typing import List

from gato.models.organization import Organization
from gato.models.organization import Repository

Expand All @@ -15,19 +13,19 @@ def __init__(self):
"""Initialize wrapper class.
"""
self.user_details = None
self.organizations: List[Organization] = []
self.repositories: List[Repository] = []
self.organizations: list[Organization] = []
self.repositories: list[Repository] = []
self.timestamp = datetime.datetime.now()

def add_organizations(self, organizations: List[Organization]):
def add_organizations(self, organizations: list[Organization]):
"""Add list of organization wrapper objects.
Args:
organizations (List[Organization]): List of org wrappers.
"""
self.organizations = organizations

def add_repositories(self, repositories: List[Repository]):
def add_repositories(self, repositories: list[Repository]):
"""Add list of organization wrapper objects.
Args:
Expand Down
14 changes: 6 additions & 8 deletions gato/models/organization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from gato.models.runner import Runner
from gato.models.repository import Repository
from gato.models.secret import Secret
Expand All @@ -19,8 +17,8 @@ def __init__(self, org_data: dict, user_scopes: list, limited_data: bool = False
self.org_admin_user = False
self.org_admin_scopes = False
self.org_member = False
self.secrets: List[Secret] = []
self.runners: List[Runner] = []
self.secrets: list[Secret] = []
self.runners: list[Runner] = []
self.sso_enabled = False

self.limited_data = limited_data
Expand All @@ -46,31 +44,31 @@ def __init__(self, org_data: dict, user_scopes: list, limited_data: bool = False
self.org_admin_user = False
self.org_member = False

def set_secrets(self, secrets: List[Secret]):
def set_secrets(self, secrets: list[Secret]):
"""Set repo-level secrets.
Args:
secrets (list): List of secrets at the organization level.
"""
self.secrets = secrets

def set_public_repos(self, repos: List[Repository]):
def set_public_repos(self, repos: list[Repository]):
"""List of public repos for the org.
Args:
repos (List[Repository]): List of Repository wrapper objects.
"""
self.public_repos = repos

def set_private_repos(self, repos: List[Repository]):
def set_private_repos(self, repos: list[Repository]):
"""List of private repos for the org.
Args:
repos (List[Repository]): List of Repository wrapper objects.
"""
self.private_repos = repos

def set_runners(self, runners: List[Runner]):
def set_runners(self, runners: list[Runner]):
"""Set a list of runners that the organization can access.
Args:
Expand Down
16 changes: 7 additions & 9 deletions gato/models/repository.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime

from typing import List

from gato.models.runner import Runner
from gato.models.secret import Secret

Expand All @@ -21,15 +19,15 @@ def __init__(self, repo_data: dict):
self.repo_data = repo_data
self.name = self.repo_data['full_name']
self.org_name = self.name.split('/')[0]
self.secrets: List[Secret] = []
self.org_secrets: List[Secret] = []
self.secrets: list[Secret] = []
self.org_secrets: list[Secret] = []
self.sh_workflow_names = []
self.enum_time = datetime.datetime.now()

self.permission_data = self.repo_data['permissions']
self.sh_runner_access = False
self.accessible_runners: List[Runner] = []
self.runners: List[Runner] = []
self.accessible_runners: list[Runner] = []
self.runners: list[Runner] = []
self.pwn_req_risk = []
self.injection_risk = []

Expand Down Expand Up @@ -71,7 +69,7 @@ def update_time(self):
"""
self.enum_time = datetime.datetime.now()

def set_accessible_org_secrets(self, secrets: List[Secret]):
def set_accessible_org_secrets(self, secrets: list[Secret]):
"""Sets organization secrets that can be read using a workflow in
this repository.
Expand Down Expand Up @@ -103,15 +101,15 @@ def has_injection(self):
"""
return len(self.injection_risk) > 0

def set_secrets(self, secrets: List[Secret]):
def set_secrets(self, secrets: list[Secret]):
"""Sets secrets that are attached to this repository.
Args:
secrets (List[Secret]): List of repo level secret wrapper objects.
"""
self.secrets = secrets

def set_runners(self, runners: List[Runner]):
def set_runners(self, runners: list[Runner]):
"""Sets list of self-hosted runners attached at the repository level.
"""
self.sh_runner_access = True
Expand Down
4 changes: 2 additions & 2 deletions gato/workflow_parser/components/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, step_data: dict):
else:
raise ValueError("Step must have either a 'run' or 'uses' key")

def __process_run(self, contents):
def __process_run(self, contents: str):
"""Processes run steps for additional context
"""
if not contents:
Expand Down Expand Up @@ -105,7 +105,7 @@ def __process_run(self, contents):
elif 'yarn ' in contents:
self.is_sink = True

def __process_action(self, uses):
def __process_action(self, uses: str):
"""Processes actions referenced by a step to classify it. Currently, Gato-X
attempts to classify it based on behavior like gating, checkouts, scripts, and sinks.
"""
Expand Down

0 comments on commit 4a243a3

Please sign in to comment.