-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add python typechecking for mypy on src/ci_workflow and tests/tests_ci_workflow #1582
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,16 +5,21 @@ | |||||||||||||||
# compatible open source license. | ||||||||||||||||
|
||||||||||||||||
from abc import ABC, abstractmethod | ||||||||||||||||
from typing import Any | ||||||||||||||||
|
||||||||||||||||
from ci_workflow.ci_target import CiTarget | ||||||||||||||||
from git.git_repository import GitRepository | ||||||||||||||||
from manifests.input_manifest import Component | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
class CiCheck(ABC): | ||||||||||||||||
def __init__(self, component, target, args=None): | ||||||||||||||||
def __init__(self, component: Any, target: CiTarget, args: Any = None) -> None: | ||||||||||||||||
self.component = component | ||||||||||||||||
self.target = target | ||||||||||||||||
self.args = args | ||||||||||||||||
|
||||||||||||||||
@abstractmethod | ||||||||||||||||
def check(self): | ||||||||||||||||
def check(self) -> None: | ||||||||||||||||
pass | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
@@ -23,6 +28,6 @@ class CiCheckDist(CiCheck): | |||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
class CiCheckSource(CiCheck): | ||||||||||||||||
def __init__(self, component, git_repo, target, args=None): | ||||||||||||||||
def __init__(self, component: Component, git_repo: GitRepository, target: CiTarget, args: Any = None) -> None: | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using opensearch-build/tests/tests_ci_workflow/test_ci_check_gradle_dependencies_opensearch.py Lines 62 to 68 in 4a3660e
|
||||||||||||||||
super().__init__(component, target, args) | ||||||||||||||||
self.git_repo = git_repo |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,22 @@ | |
|
||
import logging | ||
import re | ||
from typing import Any | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see 14 imports of Any, let's try to get this to zero or have an explanation for it. Even an untyped Dict/List is better than nothing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note; I'm OK with this as a follow up issue. |
||
|
||
from ci_workflow.ci_check import CiCheckSource | ||
from ci_workflow.ci_target import CiTarget | ||
from git.git_repository import GitRepository | ||
from manifests.input_manifest import InputComponent | ||
from system.properties_file import PropertiesFile | ||
|
||
|
||
class CiCheckGradleDependencies(CiCheckSource): | ||
def __init__(self, component, git_repo, target, args): | ||
def __init__(self, component: InputComponent, git_repo: GitRepository, target: CiTarget, args: Any) -> None: | ||
super().__init__(component, git_repo, target, args) | ||
self.gradle_project = args if args else None | ||
self.dependencies = self.__get_dependencies() | ||
|
||
def __get_dependencies(self): | ||
def __get_dependencies(self) -> PropertiesFile: | ||
cmd = " ".join( | ||
[ | ||
f"./gradlew {self.gradle_project or ''}:dependencies", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,20 @@ | |
# compatible open source license. | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import Any | ||
|
||
from ci_workflow.ci_target import CiTarget | ||
|
||
|
||
class CiCheckList(ABC): | ||
def __init__(self, component, target): | ||
def __init__(self, component: Any, target: CiTarget) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do |
||
self.component = component | ||
self.target = target | ||
|
||
@abstractmethod | ||
def checkout(self, work_dir): | ||
def checkout(self, work_dir: str) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def check(self): | ||
def check(self) -> None: | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,18 @@ | |
# compatible open source license. | ||
|
||
from abc import ABC | ||
from typing import Any | ||
|
||
from ci_workflow.ci_check_list_dist import CiCheckListDist | ||
from ci_workflow.ci_check_list_source import CiCheckListSource | ||
from ci_workflow.ci_check_list_source_ref import CiCheckListSourceRef | ||
from ci_workflow.ci_target import CiTarget | ||
from manifests.input_manifest import InputComponentFromDist, InputComponentFromSource | ||
|
||
|
||
class CiCheckLists(ABC): | ||
@classmethod | ||
def from_component(self, component, target): | ||
def from_component(self, component: Any, target: CiTarget) -> Any: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if type(component) is InputComponentFromDist: | ||
return CiCheckListDist(component, target) | ||
elif type(component) is InputComponentFromSource: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,25 @@ | |
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import abc | ||
import logging | ||
from abc import ABC, abstractmethod | ||
from typing import Any | ||
|
||
from ci_workflow.ci_args import CiArgs | ||
|
||
class CiManifest(abc.ABC): | ||
def __init__(self, manifest, args): | ||
|
||
class CiManifest(ABC): | ||
def __init__(self, manifest: Any, args: CiArgs) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this should be a manifest type, maybe an |
||
self.manifest = manifest | ||
self.args = args | ||
|
||
def check(self): | ||
def check(self) -> None: | ||
try: | ||
self.__check__() | ||
except: | ||
logging.error("CI Manifest check failed") | ||
raise | ||
|
||
@abstractmethod | ||
def __check__(self) -> None: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like component should be a
Component
type instead of any