Skip to content

xenopsd: Fix pytype warning on get_words: Name string is not defined #5921

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

Conversation

bernhardkaindl
Copy link
Collaborator

@bernhardkaindl bernhardkaindl commented Aug 7, 2024

For @stephenchengCloud:
FYI: @ashwin9390

In #5896 (review), changes were requested:

Before merging feature/py3 into master, certain warnings in files that weren't checked so far should be fixed.

This PR fixes two of the mentioned pytype warnings:

File "xen-api/ocaml/xenopsd/scripts/common.py", line 198, in get_words: Name 'string' is not defined [name-error]
File "xen-api/ocaml/xenopsd/scripts/common.py", line 201, in get_words: Name 'string' is not defined [name-error]

These uses of the not defined variable string are in an inner function of VIF.get_locking_mode().
This inner function (get_words) isn't used by the method, see:
https://github.com/xapi-project/xen-api/blob/master/ocaml/xenopsd/scripts/common.py#L196

The inner function was never used, it is completely bogus.

Because inner functions cannot be called from outside the containing method, it is 100% safe to remove it:

  • Remove the unused inner function common.VIF.get_locking_mode().get_words() to fix pytype warnings and apply minor clean-ups after adding a test that covers all branches in the method, ensuring that the changes do not change functionality.
  • Apply cosmetic formatting fixes to show the whole function in the review so it can be checked.

Two commits are to be added to this PR:`

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
@bernhardkaindl bernhardkaindl force-pushed the fix-pytype-remove-unused-get_words-and-test-it branch 2 times, most recently from 9014c27 to e7c9da8 Compare August 7, 2024 22:20
@bernhardkaindl bernhardkaindl changed the title xenopsd: Add pytest for common.VIF.get_locking_mode() xenopsd: Fix pytype warning on get_words: Name string is not defined Aug 7, 2024
Copy link
Contributor

@Vincent-lau Vincent-lau left a comment

Choose a reason for hiding this comment

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

this one is a subset of #5923 ?

Copy link
Collaborator Author

@bernhardkaindl bernhardkaindl left a comment

Choose a reason for hiding this comment

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

this one is a subset of #5923 ?

Yes, the first two commits of #5923 use the git commit hashes of this commit as base, because this fixes two of the pytype warnings that it needs to fix for enabling pytype checks on xenopsd's scripts.

Because the code changes in this PR are very minimal, I think we can merge this PR first and then #5923 becomes visually much smaller when it is rebased on the updated feature branch.

@bernhardkaindl bernhardkaindl merged commit be2ad05 into xapi-project:feature/py3 Aug 8, 2024
14 checks passed
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