-
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
Conversation
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
What's left after this one to add typechecking to the entire python codebase? |
We are tracking with meta issue, #1237, ~3 more PRs to go |
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.
I'm approving so you can merge when you are ready, but there are a number of little issues that should be quick to clean up, or you could make a new PR if desired. Thanks!
|
||
|
||
class CiCheck(ABC): | ||
def __init__(self, component, target, args=None): | ||
def __init__(self, component: Any, target: CiTarget, args: Any = None) -> None: |
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.
def __init__(self, component: Any, target: CiTarget, args: Any = None) -> None: | |
def __init__(self, component: Component, target: CiTarget, args: Any = None) -> None: |
Seems like component should be a Component
type instead of any
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make args
more specific?
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.
I was using CiArgs
type for this args
, however, for example CiCheckGradleDependencies
inherits from this CiCheckSource
isn't necessarily taking CiArgs
input; it was just a simple string. This is the test case we have
opensearch-build/tests/tests_ci_workflow/test_ci_check_gradle_dependencies_opensearch.py
Lines 62 to 68 in 4a3660e
def test_executes_gradle_command_with_arg(self): | |
check = CiCheckGradleDependenciesOpenSearchVersion( | |
component=MagicMock(), | |
git_repo=MagicMock(), | |
target=CiTarget(version="1.1.0", name="opensearch", snapshot=True), | |
args="plugin", | |
) |
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Note; I'm OK with this as a follow up issue.
|
||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do component: Component
?
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 comment
The reason will be displayed to describe this comment to others. Learn more.
component: Component
?
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should be a manifest type, maybe an InputManifest
?
I'll be merging this now to unblock the process and will create a separate PR for any followup issues Thanks. |
…i_workflow (opensearch-project#1582) * Add python typechecking for ci-workflo Signed-off-by: Zelin Hao <[email protected]>
Description
pipenv run mypy src/ci_workflow tests/tests_ci_workflow
runs without errorIssues Resolved
#1508
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.