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

Pylint fixes #606

Merged
merged 3 commits into from
Feb 27, 2024
Merged

Pylint fixes #606

merged 3 commits into from
Feb 27, 2024

Conversation

ydirson
Copy link
Contributor

@ydirson ydirson commented Mar 7, 2023

This is a first quick pass on errors raised by pylint 2.16.4. Nothing critical, mostly cleanups that also improve readability (and as a side effect can help in the future to enable type checking).

The goal is to make #605 mergeable - we're not there yet, but a few similar fixes should do.

@MarkSymsCtx
Copy link
Contributor

Looks like we might want some combination of this and #607 (which is the recreation of #605 having got it to actually complete the actions properly)

@ydirson
Copy link
Contributor Author

ydirson commented Mar 8, 2023

Nice! How should we handle this? #607 is more complete, it could make sense that you pick the things you like from this one and we'll close it?

@MarkSymsCtx
Copy link
Contributor

Nice! How should we handle this? #607 is more complete, it could make sense that you pick the things you like from this one and we'll close it?

Now that #607 is merged rebase this and then we're re-review it.

drivers/VDI.py Outdated
@@ -858,13 +858,13 @@ def _create_cbt_log(self):

return logpath

def _activate_cbt_log(self, logname):
def _activate_cbt_log(self, logname) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't, currently at least, have typing enabled so this is going to have much affect but should be innocuous.

def getVdiInfo(self, Dict, generateSector=0):
return
def getVdiInfo(self, Dict, generateSector=0) -> str:
raise NotImplementedError()
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause failures, the correct resolution was in #607 so just drop this and the similar change in getSRInfoForSectors

drivers/util.py Outdated
try:
XE_IOFI_IORETRY
XE_IOFI_IORETRY # pylint: disable=used-before-assignment
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole thing looks truly weird, it was weird before so it's not a reflection of this change but I wonder whether we might not be better seeing if this is actually even used and removing it if not.

Copy link
Contributor

Choose a reason for hiding this comment

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

This does indeed seem to be entirely unused and legacy cruft so please just delete the entire if __debug__: block

@ydirson
Copy link
Contributor Author

ydirson commented Mar 22, 2023

While I was at it I tackled as much as the remaining pylint 2.13.9 errors are possible. A few of them are not so obviously fixed, and I flagged those commits as WIP for discussion.

@@ -492,6 +492,9 @@ def delete(self, sr_uuid):
def attach(self, sr_uuid):
try:
connected = False
if not self.iscsiSRs:
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of if not self.iscsiSRs: you might have better results with if len(self.iscsiSRs) == 0:.

It could also be confused by the try: except: else: construct to set connected=True, that could be moved into the main block and the else: removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed connected mostly duplicates the info of stored_exception, and only using the latter makes the code clearer, helping pylint enough to make sense of it

@MarkSymsCtx
Copy link
Contributor

While I was at it I tackled as much as the remaining pylint 2.13.9 errors are possible. A few of them are not so obviously fixed, and I flagged those commits as WIP for discussion.

I think (but will need to dig a bit furtherthat _genArrayIdentifier` is entirely unused dead code as it's only called under conditions relating to MPP multipath which is no longer used and we now only use device-mapper-multipath for multipath devices. Expunging all of that dead code could be a chunk of work.

@ydirson
Copy link
Contributor Author

ydirson commented Mar 23, 2023

While I was at it I tackled as much as the remaining pylint 2.13.9 errors are possible. A few of them are not so obviously fixed, and I flagged those commits as WIP for discussion.

I think (but will need to dig a bit furtherthat _genArrayIdentifier` is entirely unused dead code as it's only called under conditions relating to MPP multipath which is no longer used and we now only use device-mapper-multipath for multipath devices. Expunging all of that dead code could be a chunk of work.

You mean that's better left for a separate PR ? I guess that would amount to reworking the elif obj.hba == 'mpp': block to warn as ba13384 does, and select some fallback behavior so we can get rid of the dead code, but I don't fee confident enough to propose said fallback behavior :)

@MarkSymsCtx
Copy link
Contributor

While I was at it I tackled as much as the remaining pylint 2.13.9 errors are possible. A few of them are not so obviously fixed, and I flagged those commits as WIP for discussion.

I think (but will need to dig a bit furtherthat _genArrayIdentifier` is entirely unused dead code as it's only called under conditions relating to MPP multipath which is no longer used and we now only use device-mapper-multipath for multipath devices. Expunging all of that dead code could be a chunk of work.

You mean that's better left for a separate PR ? I guess that would amount to reworking the elif obj.hba == 'mpp': block to warn as ba13384 does, and select some fallback behavior so we can get rid of the dead code, but I don't fee confident enough to propose said fallback behavior :)

Yeah, I'm doing it now. About to run some tests to make sure nothing explodes in multipath testing, it all seemed to be dangling dead code with no way of triggering the relevant code paths. 207 lines of dead code removed.

@MarkSymsCtx
Copy link
Contributor

@ydirson FYI - #613

@MarkSymsCtx
Copy link
Contributor

@ydirson FYI - #613

Now merged.

MarkSymsCtx
MarkSymsCtx previously approved these changes Jul 5, 2023
TimSmithCtx
TimSmithCtx previously approved these changes Oct 18, 2023
Launching once per module takes much more time, produces more noise,
and forces to compute a global result code, for no obvious value.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
A long time ago there was no support for try blocks with both
except and finally clauses, but that's the past.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
pylint 2.13.9 does not see that the try block cannot exit before the first
line completes:

 drivers/SMBSR.py:211:37: E0601: Using variable 'err' before assignment (used-before-assignment)

Moving the variable out of the try block would not make sense here, so
just ignore the error.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
@MarkSymsCtx MarkSymsCtx merged commit 808760b into xapi-project:master Feb 27, 2024
2 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.

4 participants