Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs=4
[MESSAGES CONTROL]

# Errors and warings with some filtered:
# W0107(unnecessary-pass)
# W0201(attribute-defined-outside-init)
# W0212(protected-access)
# W0221(arguments-differ)
Expand All @@ -19,15 +18,14 @@ jobs=4
# W0602(global-variable-not-assigned)
# W0603(global-statement)
# W0611(unused-import)
# W0612(unused-variable)
# W0613(unused-argument)
# W0621(redefined-outer-name)
# W0622(redefined-builtin)
# W0631(undefined-loop-variable)
# W0703(broad-except)
# W1401(anomalous-backslash-in-string)

disable=C, F, I, R, W0107, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0613, W0621, W0622, W0631, W0703, W1401
disable=C, F, I, R, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0613, W0621, W0622, W0631, W0703, W1401


[REPORTS]
Expand Down
1 change: 0 additions & 1 deletion cloudinit/config/cc_set_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class SetHostnameError(Exception):
This may happen if we attempt to set the hostname early in cloud-init's
init-local timeframe as certain services may not be running yet.
"""
pass


def handle(name, cfg, cloud, log, _args):
Expand Down
3 changes: 0 additions & 3 deletions cloudinit/distros/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def is_physical(self, devname: DeviceName) -> bool:
Examples of non-physical network devices: bonds, bridges, tunnels,
loopback devices.
"""
pass

def is_renamed(self, devname: DeviceName) -> bool:
return net.is_renamed(devname)
Expand All @@ -117,7 +116,6 @@ def settle(self, *, exists=None) -> None:
process entirely, if the device already exists.)
:type exists: Optional[DeviceName]
"""
pass

def wait_for_physdevs(
self, netcfg: NetworkConfig, *, strict: bool = True
Expand Down Expand Up @@ -182,7 +180,6 @@ def is_physical(self, devname: DeviceName) -> bool:

def settle(self, *, exists=None) -> None:
"""BSD has no equivalent to `udevadm settle`; noop."""
pass


class LinuxNetworking(Networking):
Expand Down
2 changes: 0 additions & 2 deletions cloudinit/distros/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ def preferred_ntp_clients(self):
copy.deepcopy(PREFERRED_NTP_CLIENTS))
return self._preferred_ntp_clients

pass


# vi: ts=4 expandtab
2 changes: 0 additions & 2 deletions cloudinit/net/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ class InitramfsNetworkConfigSource(metaclass=abc.ABCMeta):
@abc.abstractmethod
def is_applicable(self) -> bool:
"""Is this initramfs config source applicable to the current system?"""
pass

@abc.abstractmethod
def render_config(self) -> dict:
"""Render a v1 network config from the initramfs configuration"""
pass


class KlibcNetworkConfigSource(InitramfsNetworkConfigSource):
Expand Down
2 changes: 0 additions & 2 deletions cloudinit/net/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ class InvalidDHCPLeaseFileError(Exception):
Current uses are DataSourceAzure and DataSourceEc2 during ephemeral
boot to scrape metadata.
"""
pass


class NoDHCPLeaseError(Exception):
"""Raised when unable to get a DHCP lease."""
pass


class EphemeralDHCPv4(object):
Expand Down
1 change: 0 additions & 1 deletion cloudinit/reporting/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def publish_event(self, event):

def flush(self):
"""Ensure ReportingHandler has published all events"""
pass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i understand how the abstract methods don't need pass, but i'm surprised regular methods don't need it either

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The docstring is part of the body of the method; the pass is extraneous. Given these two definitions:

def before():
  """docstring"""
  pass


def after():
  """docstring"""

we can use Python's ast module to examine them (though note that as the parser operates on strings, before and after here are actually strings containing the above definitions):

>>> ast.dump(ast.parse(before))                                                                                                                                                                                                                                                      
"Module(body=[FunctionDef(name='flush', args=arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Expr(value=Constant(value='docstring', kind=None)), Pass()], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])"
>>> ast.dump(ast.parse(after))
"Module(body=[FunctionDef(name='after', args=arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Expr(value=Constant(value='docstring', kind=None))], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])"

The key differences here are the body of the FunctionDef. For before, it's two statements: [Expr(value=Constant(value='docstring', kind=None)), Pass()], whereas for after it is just a single one: [Expr(value=Constant(value='docstring', kind=None))]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(Also, plugging the definitions into https://vpyast.appspot.com/ will give you a nice graphical indicator of this.)



class LogHandler(ReportingHandler):
Expand Down
1 change: 0 additions & 1 deletion cloudinit/sources/DataSourceAzure.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@ def exc_cb(msg, exception):
except UrlError:
# Teardown our EphemeralDHCPv4 context on failure as we retry
self._ephemeral_dhcp_ctx.clean_network()
pass
finally:
if nl_sock:
nl_sock.close()
Expand Down
2 changes: 0 additions & 2 deletions cloudinit/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class DataSourceNotFoundException(Exception):

class InvalidMetaDataException(Exception):
"""Raised when metadata is broken, unavailable or disabled."""
pass


def process_instance_metadata(metadata, key_path='', sensitive_keys=()):
Expand Down Expand Up @@ -511,7 +510,6 @@ def publish_host_keys(self, hostkeys):
(e.g. 'ssh-rsa') and key_value is the key itself
(e.g. 'AAAAB3NzaC1y...').
"""
pass

def _remap_device(self, short_name):
# LP: #611137
Expand Down
1 change: 0 additions & 1 deletion cloudinit/sources/helpers/netlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

class NetlinkCreateSocketError(RuntimeError):
'''Raised if netlink socket fails during create or bind.'''
pass


def create_bound_netlink_socket():
Expand Down
1 change: 0 additions & 1 deletion cloudinit/sources/helpers/vmware/imc/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ConfigFile(ConfigSource, dict):

def __init__(self, filename):
self._loadConfigFile(filename)
pass

def _insertKey(self, key, val):
"""
Expand Down
1 change: 0 additions & 1 deletion cloudinit/sources/helpers/vmware/imc/config_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@

class ConfigNamespace(ConfigSource):
"""Specifies the Config Namespace."""
pass

# vi: ts=4 expandtab
1 change: 0 additions & 1 deletion cloudinit/sources/helpers/vmware/imc/config_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

class ConfigSource(object):
"""Specifies a source for the Config Content."""
pass

# vi: ts=4 expandtab
1 change: 0 additions & 1 deletion cloudinit/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@ def _pkl_load(fname):
except Exception as e:
if os.path.isfile(fname):
LOG.warning("failed loading pickle in %s: %s", fname, e)
pass

# This is allowed so just return nothing successfully loaded...
if not pickle_contents:
Expand Down
2 changes: 0 additions & 2 deletions tests/cloud_tests/platforms/azurecloud/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def start(self, wait=True, wait_for_cloud_init=False):
except CloudError:
LOG.debug(('image not found, launching instance with base image, '
'image_id=%s'), self.image_id)
pass

vm_params = {
'name': self.vm_name,
Expand Down Expand Up @@ -169,7 +168,6 @@ def shutdown(self, wait=True):
sleep(15)
else:
LOG.warning('Could not find console log: %s', e)
pass

LOG.debug('stopping instance %s', self.image_id)
vm_deallocate = \
Expand Down
1 change: 0 additions & 1 deletion tests/cloud_tests/platforms/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ def snapshot(self):

def destroy(self):
"""Clean up data associated with image."""
pass

# vi: ts=4 expandtab
1 change: 0 additions & 1 deletion tests/cloud_tests/platforms/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ def launch(self, user_data, meta_data=None, block=True, start=True,

def destroy(self):
"""Clean up snapshot data."""
pass

# vi: ts=4 expandtab
1 change: 0 additions & 1 deletion tests/cloud_tests/testcases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def is_distro(self, distro_name):
@classmethod
def maybeSkipTest(cls):
"""Present to allow subclasses to override and raise a skipTest."""
pass

def assertPackageInstalled(self, name, version=None):
"""Check dpkg-query --show output for matching package name.
Expand Down
7 changes: 0 additions & 7 deletions tests/unittests/test_datasource/test_ibmcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
D_PATH = "cloudinit.sources.DataSourceIBMCloud."


class TestIBMCloud(test_helpers.CiTestCase):
"""Test the datasource."""
def setUp(self):
super(TestIBMCloud, self).setUp()
pass


@mock.patch(D_PATH + "_is_xen", return_value=True)
@mock.patch(D_PATH + "_is_ibm_provisioning")
@mock.patch(D_PATH + "util.blkid")
Expand Down
1 change: 0 additions & 1 deletion tests/unittests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ def test_reporting_child_default_to_parent(
with parent:
with child:
pass
pass
self.assertEqual(report_start.call_count, 0)
self.assertEqual(report_finish.call_count, 0)

Expand Down