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

Fix Python linters and clean up run-bmv2-ptf-test.py, testutils, and ebpfenv #4437

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Feb 20, 2024

  • Modernize the way we lint our Python code. Like in our C++ code, imports should be relative to the project root. The advantage is that this way linters such as pylint and mypy can also pick up the imports and do not throw errors.
  • Add a mypy config to pyproject.toml and add an init hook to pylint. This way both tools understand that the folder of the pyproject.toml is the root folder.
  • Fold the .pylintrc file into the pyproject.toml file. Reduces the amount of files we have in the root folder.
  • Fix up typing and linting complains in run-bmv2-ptf-test.py, testutils.py, and ebpfenv.py. These fixes are a direct consequence of getting the linters to work. There were lots of subtle typing mistakes which could have lead to bugs.

There is still a lot of work left to make mypy and pylint standard but I think this is a step in the right direction.

@fruffy fruffy force-pushed the fruffy/python_linter_cleanup branch from 894caf8 to b30bb6e Compare February 20, 2024 15:24
@fruffy fruffy added run-ubuntu18 Use this tag to trigger a Ubuntu-18 CI run. run-validation Use this tag to trigger a Validation CI run. run-sanitizer Use this tag to run a Clang+Sanitzers CI run. infrastructure Topics related to code style and build and test infrastructure. labels Feb 20, 2024
Copy link
Contributor

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

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

I looked through all of the Python code changes, and they looked reasonable to me.

@fruffy fruffy force-pushed the fruffy/python_linter_cleanup branch from b30bb6e to e4e6d8c Compare February 20, 2024 17:34
@fruffy fruffy force-pushed the fruffy/python_linter_cleanup branch from e4e6d8c to 67c8144 Compare February 20, 2024 17:34
@fruffy fruffy marked this pull request as ready for review February 20, 2024 18:02
@fruffy fruffy merged commit a8ac5f1 into main Feb 21, 2024
16 checks passed
@fruffy fruffy deleted the fruffy/python_linter_cleanup branch February 21, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Topics related to code style and build and test infrastructure. run-sanitizer Use this tag to run a Clang+Sanitzers CI run. run-ubuntu18 Use this tag to trigger a Ubuntu-18 CI run. run-validation Use this tag to trigger a Validation CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants