Skip to content
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

adding mypy to parametric tests #3405

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

rachelyangdog
Copy link
Contributor

Motivation

Update the ./format.sh script to run static analysis checks on parametric tests (via mypy).

Changes

Updated mypy and fixed all errors. (as of now a lot of fixes are # type: ignore)

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes (if something not related to your task is failing, you can ignore it)
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner. We're working on refining the codeowners file quickly.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • If PR title starts with [<language>], double-check that only <language> is impacted by the change
  • No system-tests internal is modified. Otherwise, I have the approval from R&P team
  • CI is green, or failing jobs are not related to this change (and you are 100% sure about this statement)
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added (or removed)?

@rachelyangdog rachelyangdog requested review from mabdinur and a team as code owners November 7, 2024 20:54
@cbeauchesne cbeauchesne self-requested a review November 8, 2024 08:47
Copy link
Collaborator

@cbeauchesne cbeauchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do the fix only for utils/parametric and tests/parametric

format.sh Outdated Show resolved Hide resolved
mypy.ini Outdated Show resolved Hide resolved
utils/build/docker/golang/go.work.sum Outdated Show resolved Hide resolved
format.sh Outdated Show resolved Hide resolved
@cbeauchesne cbeauchesne marked this pull request as draft November 8, 2024 16:46
@rachelyangdog rachelyangdog marked this pull request as ready for review November 13, 2024 18:59
@@ -102,6 +102,12 @@ allow_no_jira_ticket_for_bugs = [
"tests/parametric/test_config_consistency.py::Test_Config_TraceLogDirectory",
]

[tool.mypy]
files = ["utils/parametric", "tests/parametric"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To perform a proper migration to this tools, could you revert any change that are not in those two folders ?

@@ -257,13 +261,14 @@ def _build_apm_test_server_image(self) -> str:
check=False,
)

failure_text: str = None
failure_text: Optional[str] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed, as the variable is used only in the if block

utils/_context/_scenarios/parametric.py Outdated Show resolved Hide resolved
if p.returncode != 0:
log_file.seek(0)
failure_text = "".join(log_file.readlines())
pytest.exit(f"Failed to build the container: {failure_text}", 1)

logger.debug("Build tested container finished")
return None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does mypy requires to explicitly return None ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, mypy will generate errors when a function is missing return statements

@@ -77,8 +77,8 @@ class V06StatsAggr(TypedDict):
TopLevelHits: int
Duration: int
Errors: int
OkSummary: BaseDDSketch
ErrorSummary: BaseDDSketch
OkSummary: Optional[BaseDDSketch]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because OkSummary is set to None sometimes when it is used and mypy doesn't like that the type is set to BaseDDSketch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants