-
Notifications
You must be signed in to change notification settings - Fork 372
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
Fixing Linter errors: undefined-variables<E0602>. #1999
Fixing Linter errors: undefined-variables<E0602>. #1999
Conversation
@@ -58,7 +59,7 @@ def publish_hostname(self, hostname): | |||
Restart NetworkManager first before publishing hostname | |||
""" | |||
shellutil.run("service NetworkManager restart") | |||
super(RedhatOSUtil, self).publish_hostname(hostname) # pylint: disable=E0602 | |||
super(IosxeOSUtil, self).publish_hostname(hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it was copy-pasted from Redhat. Anyone know if this is the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, most of these distro-specific modules that are not endorsed came from external contributors.
@@ -79,13 +80,13 @@ def get_instance_id(self): | |||
If that is missing, then extracts from dmidecode | |||
If nothing works (for old VMs), return the empty string | |||
''' | |||
if os.path.isfile(PRODUCT_ID_FILE): # pylint: disable=E0602 | |||
if os.path.isfile(PRODUCT_ID_FILE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os
and PRODUCT_ID_FILE
both seem like they were straight-up just not imported into this module...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol whoever wrote the code (and reviewed it) didnt do a good job :p
rc, s = shellutil.run_get_output(DMIDECODE_CMD) # pylint: disable=E0602,C0103 | ||
if rc != 0 or UUID_PATTERN.match(s) is None: # pylint: disable=E0602 | ||
rc, s = shellutil.run_get_output(DMIDECODE_CMD) # pylint: disable=C0103 | ||
if rc != 0 or UUID_PATTERN.match(s) is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this time with DMIDECODE_CMD
and UUID_PATTERN
.
@@ -126,7 +126,7 @@ def restart_ssh_service(self): # pylint: disable=R1710 | |||
if os.path.exists("/etc/init.d/sshd"): # pylint: disable=R1705 | |||
return shellutil.run("/etc/init.d/sshd restart", chk_err=True) | |||
else: | |||
logger.warn("sshd service does not exists", username) # pylint: disable=E0602 | |||
logger.warn("sshd service does not exists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like this was just copy-pasted from a method with username
in scope.
@@ -25,16 +25,38 @@ | |||
|
|||
bytebuffer = memoryview # pylint: disable=C0103 | |||
|
|||
# We aren't using these imports in this file, but we want them to be available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning these up!
ustr = unicode # Rename Python2 unicode to ustr | ||
bytebuffer = buffer | ||
range = xrange | ||
int = long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these all for Py2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right.
# to import from this module in others. | ||
# Additionally, python2 doesn't have this, so we need to disable import-error | ||
# as well. | ||
from builtins import int, range # pylint: disable=unused-import,import-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wont this throw if py2 doesnt have these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just off screen in the GitHub view, but we're in a if sys.version_info[0] == 3:
, so this shouldn't be executed in a python2 env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh got it! Thanks!
@@ -79,13 +80,13 @@ def get_instance_id(self): | |||
If that is missing, then extracts from dmidecode | |||
If nothing works (for old VMs), return the empty string | |||
''' | |||
if os.path.isfile(PRODUCT_ID_FILE): # pylint: disable=E0602 | |||
if os.path.isfile(PRODUCT_ID_FILE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol whoever wrote the code (and reviewed it) didnt do a good job :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple of questions
a99e95a
to
7f0707c
Compare
Description
PR information
Quality of Code and Contribution Guidelines