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

chore(pipelined): Make mypy green #12950

Merged
merged 1 commit into from Jun 10, 2022

Conversation

sebathomas
Copy link
Contributor

@sebathomas sebathomas commented Jun 9, 2022

Summary

Fix various type issues for pipelined.

  • Correct a few wrong argument or variable types
  • Add type stubs for mixins
  • Ignore a false positive
  • Raise ValueError instead of NPE
  • Extract method to handle all types of error in tc_ops_pyroute2
  • Add null checks in test code

Test Plan

cd $MAGMA_ROOT/lte/gateway
mypy --ignore-missing-imports python/magma/pipelined/
Success: no issues found in 131 source files

Additional Information

  • This change is backwards-breaking

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines. label Jun 9, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added the component: agw Access gateway-related issue label Jun 9, 2022
@@ -137,7 +137,7 @@ def get_hash(s, hash_function) -> bytes:

def encode_str(s: str, encoding_type) -> str:
if encoding_type == PipelineD.HEConfig.BASE64:
s = codecs.encode(codecs.decode(s, 'hex'), 'base64').decode()
s = codecs.encode(codecs.decode(s, 'hex'), 'base64').decode() # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be an issue in mypy, see: python/typeshed#300

@sebathomas sebathomas marked this pull request as ready for review June 9, 2022 15:50
@sebathomas sebathomas requested review from a team and koolzz June 9, 2022 15:50
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

feg-workflow

    2 files  202 suites   39s ⏱️
371 tests 371 ✔️ 0 💤 0
385 runs  385 ✔️ 0 💤 0

Results for commit 64290b3.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

dp-workflow

18 tests   18 ✔️  5m 1s ⏱️
  2 suites    0 💤
  2 files      0

Results for commit 64290b3.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

agw-workflow

     78 files     123 suites   6m 34s ⏱️
1 152 tests 1 148 ✔️ 4 💤 0
1 154 runs  1 150 ✔️ 4 💤 0

Results for commit 64290b3.

♻️ This comment has been updated with latest results.

@sebathomas sebathomas force-pushed the pipelined-mypy-green branch 2 times, most recently from 49c149f to 0e1e2ca Compare June 10, 2022 07:19
@sebathomas sebathomas requested review from a team and electronjoe June 10, 2022 07:19
@LKreutzer LKreutzer requested review from LKreutzer and removed request for electronjoe June 10, 2022 08:00
@@ -204,6 +204,9 @@ py_library(
py_library(
name = "restart_mixin",
srcs = ["restart_mixin.py"],
deps = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why was this not needed before? I see that you added the import to restart_mixin, but the _startup_flow_controller was there before, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

The import from magma.pipelined.app.startup_flows import StartupFlows was newly added

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you added the import to restart_mixin

My question was, why the import was not needed before.

Copy link
Contributor

Choose a reason for hiding this comment

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

To me it looks like both lines are new?

Copy link
Contributor

Choose a reason for hiding this comment

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

Current master does this: Screenshot from 2022-06-10 13-05-01

Copy link
Contributor

Choose a reason for hiding this comment

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

but the _startup_flow_controller was there before

yes, but the object that contains the StartupFlows was existing before

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 but it wasn't typed here before so the Python code didn't know what it was in the abstract superclass.

@pull-request-size pull-request-size bot added size/L Denotes a Pull Request that changes 100-499 lines. and removed size/M Denotes a PR that changes 30-99 lines. labels Jun 10, 2022
@nstng nstng self-requested a review June 10, 2022 12:18
Copy link
Contributor

@nstng nstng left a comment

Choose a reason for hiding this comment

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

lgtm (feel free to ignore the nit if you do not plan to do other changes). sudo tests locally green.

Fix various type issues for pipelined.
- Correct a few wrong argument or variable types
- Add type stubs for mixins
- Ignore some false positives
- Raise ValueError instead of NPE
- Extract method to handle all types of error in tc_ops_pyroute2
- Add null checks in test code

Signed-off-by: Sebastian Thomas <sebastian.thomas@tngtech.com>
@sebathomas sebathomas enabled auto-merge (squash) June 10, 2022 14:40
@sebathomas sebathomas merged commit 1abd2ae into magma:master Jun 10, 2022
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
Fix various type issues for pipelined.
- Correct a few wrong argument or variable types
- Add type stubs for mixins
- Ignore some false positives
- Raise ValueError instead of NPE
- Extract method to handle all types of error in tc_ops_pyroute2
- Add null checks in test code

Signed-off-by: Sebastian Thomas <sebastian.thomas@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: agw Access gateway-related issue size/L Denotes a Pull Request that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants