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(mobilityd): Fix type errors shown by mypy #11963

Merged
merged 1 commit into from
Mar 4, 2022

Conversation

sebathomas
Copy link
Contributor

Summary

I tried static type checking of mobilityd using mypy and fixed some of the errors it found. Mostly these were minor issues (missing return statements or null checks).

The only bigger change is the introduction of dedicated types for IP addresses and networks. Before this PR, they referred to functions as variable types, which is not a valid type hint.

Test Plan

Install mypy in a virtualenv and execute it via

cd $MAGMA_ROOT/lte/gateway
mypy --ignore-missing-imports python/magma/mobilityd/

Error count on master:

Found 108 errors in 16 files (checked 31 source files)

Error count after the changes:

Found 24 errors in 5 files (checked 31 source files)

Additional Information

  • This change is backwards-breaking

@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 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 Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

Oops! Looks like you failed the DCO check. Be sure to sign all your commits.

Howto

♻️ Updated: ✅ The check is passing the DCO check after the last commit.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

feg-workflow

    2 files  202 suites   33s ⏱️
363 tests 363 ✔️ 0 💤 0
377 runs  377 ✔️ 0 💤 0

Results for commit df4e3e9.

♻️ This comment has been updated with latest results.

I tried static type checking of mobilityd using mypy and fixed
some of the errors it found. Mostly these were minor issues
(missing return statements or null checks). The only bigger
change is the introduction of dedicated types for IP addresses
and networks.

Signed-off-by: Sebastian Thomas <sebastian.thomas@tngtech.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

agw-workflow

  54 files    84 suites   3m 38s ⏱️
738 tests 729 ✔️ 9 💤 0
923 runs  914 ✔️ 9 💤 0

Results for commit df4e3e9.

@sebathomas sebathomas marked this pull request as ready for review March 4, 2022 15:57
@sebathomas sebathomas requested review from a team and pshelar March 4, 2022 15:57
Copy link
Contributor

@ardzoht ardzoht left a comment

Choose a reason for hiding this comment

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

lgtm

@sebathomas sebathomas added the ready2merge This PR is ready to be merged (is approved and passes all required checks) label Mar 4, 2022
@themarwhal themarwhal enabled auto-merge (squash) March 4, 2022 17:03
@themarwhal
Copy link
Member

Thanks for this Sebastian!!! Is there a way to add linters / test coverage for these types of things?

@themarwhal themarwhal merged commit 32ac5a3 into magma:master Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

Unit Test Results

157 files  157 suites   2h 10m 43s ⏱️
307 tests 303 ✔️ 3 💤 1

For more details on these failures, see this check.

Results for commit 32ac5a3.

♻️ This comment has been updated with latest results.

@sebathomas
Copy link
Contributor Author

Thanks for this Sebastian!!! Is there a way to add linters / test coverage for these types of things?

I'd love to have it in the CI. It would be easy to set up if we could fix all warnings first and then keep it green. Getting to a green state might take a lot of work though.

I'm not sure if there is any support for a mode with existing issues, e.g. where it checks that the number of errors doesn't increase so you could lower the allowed error count over time.

I'll look into it a bit more...

nicarl added a commit to nicarl/magma that referenced this pull request Mar 8, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
nicarl added a commit to nicarl/magma that referenced this pull request Mar 8, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
@nicarl nicarl mentioned this pull request Mar 8, 2022
1 task
nicarl added a commit to nicarl/magma that referenced this pull request Mar 9, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
nicarl added a commit to nicarl/magma that referenced this pull request Mar 9, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
nicarl added a commit to nicarl/magma that referenced this pull request Mar 9, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
nicarl added a commit to nicarl/magma that referenced this pull request Mar 9, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
nicarl added a commit to nicarl/magma that referenced this pull request Mar 11, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
themarwhal pushed a commit that referenced this pull request Mar 11, 2022
I added some more type hints based on the work from #11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
ardzoht pushed a commit that referenced this pull request Mar 30, 2022
I added some more type hints based on the work from #11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.com>
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
I tried static type checking of mobilityd using mypy and fixed
some of the errors it found. Mostly these were minor issues
(missing return statements or null checks). The only bigger
change is the introduction of dedicated types for IP addresses
and networks.

Signed-off-by: Sebastian Thomas <sebastian.thomas@tngtech.com>
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
I added some more type hints based on the work from magma#11963. Furthermore, I created an MVP for a mypy.ini, which is a first step for adding a type checking step to the CI.

Signed-off-by: Nico Carl <nicocarl@protonmail.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 ready2merge This PR is ready to be merged (is approved and passes all required checks) 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

3 participants