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

Typing files from scripts folder #16493

Merged
merged 21 commits into from
Nov 13, 2022
Merged

Conversation

aasiffaizal
Copy link
Contributor

@aasiffaizal aasiffaizal commented Nov 5, 2022

Overview

  1. This PR fixes or fixes part of #[].
  2. This PR does the following: This PR covers type annotation for the files scripts/linters/pre_commit_linter, scripts/linters/python_linter, scripts/run_backend_tests.py and their test files.

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Proof that changes are correct

Screenshot 2022-11-06 at 2 44 51 PM

Proof of changes on desktop with slow/throttled network

Proof of changes on mobile phone

Proof of changes in Arabic language

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL". Oppiabot will help assign that person for you.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@oppiabot
Copy link

oppiabot bot commented Nov 5, 2022

Hi @aasiffaizal, can you complete the following:

  1. The body of this PR is missing the required description, please update the body with a description of what this PR does.
  2. The karma and linter checklist has not been checked, please make sure to run the frontend tests and lint tests before pushing.
    Thanks!

@oppiabot
Copy link

oppiabot bot commented Nov 5, 2022

Hi, @aasiffaizal, this pull request does not have a "CHANGELOG: ..." label as mentioned in the PR pointers. Assigning @aasiffaizal to add the required label. PRs without this label will not be merged. If you are unsure of which label to add, please ask the reviewers for guidance. Thanks!

@aasiffaizal aasiffaizal marked this pull request as ready for review November 6, 2022 19:37
@aasiffaizal aasiffaizal requested a review from a team November 6, 2022 19:37
@aasiffaizal aasiffaizal requested a review from a team as a code owner November 6, 2022 19:37
@aasiffaizal aasiffaizal requested a review from U8NWXD November 6, 2022 19:37
@aasiffaizal aasiffaizal changed the title Typed scripts folder Typing files from scripts folder Nov 6, 2022
"""Print summary of linter error messages.

Args:
lint_messages: list(str). List of linter error messages.
"""
if lint_messages != '':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lint_messages is a list of str and hence this condition is not necessary

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if the lint_messages is non-empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added that check

@@ -367,6 +397,8 @@ def check_test_results(tasks, task_to_taskspec, generate_coverage_report):
)

try:
if not tests_failed_regex_match:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Raising an attribute error since there is an exception handler below to handle if there are no matches

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some description to the errors, I know it is going to be lost when we handle it but it still make sense for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the description

Copy link
Contributor

Choose a reason for hiding this comment

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

No I meant do Exception('<description>')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@aasiffaizal
Copy link
Contributor Author

@vojtechjelinek @sahiljoster32 @U8NWXD Could you, please take a look?

Copy link
Contributor

@sahiljoster32 sahiljoster32 left a comment

Choose a reason for hiding this comment

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

LGTM!

@oppiabot
Copy link

oppiabot bot commented Nov 10, 2022

Unassigning @sahiljoster32 since they have already approved the PR.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few nits.

scripts/linters/codeowner_linter.py Outdated Show resolved Hide resolved
scripts/linters/pre_commit_linter.py Outdated Show resolved Hide resolved
@@ -532,11 +578,11 @@ def _get_task_output(lint_messages, failed, task):
return failed


def _print_errors_stacktrace(errors_stacktrace):
def _print_errors_stacktrace(errors_stacktrace: List[Optional[str]]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can the items be 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.

It can be None because the type of stack_trace is as follows

self.stacktrace: Optional[str] = None

It is appended to the list over here

ALL_ERRORS.append(task.stacktrace)

should I append to the list only if the stacktrace is present?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I would say that if we have task.exception but no task.stacktrace then we probably have some kind of issue and we should print something else instead of the stacktrace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that makes sense.

done

@@ -367,6 +397,8 @@ def check_test_results(tasks, task_to_taskspec, generate_coverage_report):
)

try:
if not tests_failed_regex_match:
Copy link
Contributor

Choose a reason for hiding this comment

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

No I meant do Exception('<description>')

@oppiabot
Copy link

oppiabot bot commented Nov 10, 2022

Hi @aasiffaizal, the build of this PR is stale and this could result in tests failing in develop. Please update this pull request with the latest changes from develop. Thanks!

@aasiffaizal
Copy link
Contributor Author

@vojtechjelinek, Addressed all the comments. PTAL!

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Took a pass.

scripts/run_backend_tests.py Outdated Show resolved Hide resolved
scripts/run_backend_tests.py Outdated Show resolved Hide resolved
@aasiffaizal
Copy link
Contributor Author

Addressed all the comments @vojtechjelinek. PTAL

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

LGTM!

@U8NWXD
Copy link
Member

U8NWXD commented Nov 21, 2022

@aasiffaizal it looks like this PR introduced a backend flake (documented in #16600). Can you investigate? We can't do a clean revert, so if you can fix it fast, that might be faster than reverting manually

@aasiffaizal
Copy link
Contributor Author

Replied in the issue. I'll take a look at it

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.

4 participants