Skip to content

Commit

Permalink
[pylint] Fix abstract-method and unnecessary-pass
Browse files Browse the repository at this point in the history
Signed-off-by: Ponnuvel Palaniyappan <[email protected]>
  • Loading branch information
pponnuvel authored and TurboTurtle committed Aug 19, 2024
1 parent a2b9c4c commit e81bdb4
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 19 deletions.
2 changes: 0 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ disable=
###################### VV things we should fix VV
W0719, # broad-exception-raised
W1203, # logging-fstring-interpolation
W0107, # unnecessary-pass
W0718, # broad-exception-caught
W0102, # dangerous-default-value
C0201, # consider-iterating-dictionary
W1201, # logging-not-lazy
W0707, # raise-missing-from
W0212, # protected-access
W0223, # abstract-method
W1509, # subprocess-popen-preexec-fn
6 changes: 3 additions & 3 deletions sos/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ def get_archive_path(self):
directory based cache prior to packaging should return the
path to the temporary directory where the report content is
located"""
pass
raise NotImplementedError

def cleanup(self):
"""Clean up any temporary resources used by an Archive class."""
pass
raise NotImplementedError

def finalize(self, method):
"""Finalize an archive object via method. This may involve creating
An archive that is subsequently compressed or simply closing an
archive that supports in-line handling. If method is automatic then
the following methods are tried in order: xz, gzip"""
pass
raise NotImplementedError


class FileCacheArchive(Archive):
Expand Down
4 changes: 0 additions & 4 deletions sos/collector/clusters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def set_node_options(self, node):
:param node: The non-primary node
:type node: ``SoSNode``
"""
pass

def set_transport_type(self):
"""The default connection type used by sos collect is to leverage the
Expand All @@ -280,7 +279,6 @@ def set_primary_options(self, node):
:param node: The primary node
:type node: ``SoSNode``
"""
pass

def check_node_is_primary(self, node):
"""In the event there are multiple primaries, or if the collect command
Expand Down Expand Up @@ -324,7 +322,6 @@ def setup(self):
extra commands to be run even if a node list is given by the user, and
thus get_nodes() would not be called
"""
pass

def check_enabled(self):
"""
Expand Down Expand Up @@ -352,7 +349,6 @@ def cleanup(self):
This helps ensure that sos does make lasting changes to the environment
in which we are running
"""
pass

def get_nodes(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def add_parser_options(cls, parser):
"""This should be overridden by each subcommand to add its own unique
options to the parser
"""
pass
raise NotImplementedError

def apply_options_from_cmdline(self, opts):
"""(Re-)apply options specified via the cmdline to an options instance
Expand Down
3 changes: 0 additions & 3 deletions sos/policies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def dist_version(self):
"""
Return the OS version
"""
pass

def get_preferred_archive(self):
"""
Expand Down Expand Up @@ -308,13 +307,11 @@ def pre_work(self):
"""
This function is called prior to collection.
"""
pass

def post_work(self):
"""
This function is called after the sos report has been generated.
"""
pass

def pkg_by_name(self, pkg):
"""Wrapper to retrieve a package from the Policy's package manager
Expand Down
15 changes: 15 additions & 0 deletions sos/policies/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def set_forbidden_paths(cls):
'/etc/shadow'
]

@classmethod
def check(cls, remote=''):
"""
This function is responsible for determining if the underlying system
is supported by this policy.
"""
raise NotImplementedError

def kernel_version(self):
return self.release

Expand Down Expand Up @@ -1063,5 +1071,12 @@ class GenericLinuxPolicy(LinuxPolicy):
'users are encouraged to request a new distribution-specifc'
' policy at the GitHub project above.\n')

@classmethod
def check(cls, remote=''):
"""
This function is responsible for determining if the underlying system
is supported by this policy.
"""
raise NotImplementedError

# vim: set et ts=4 sw=4 :
2 changes: 1 addition & 1 deletion sos/policies/init_systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_all_services(self):
This must be overridden by anything that subclasses `InitSystem` in
order for service methods to function properly
"""
pass
raise NotImplementedError

def _query_service(self, name):
"""Query an individual service"""
Expand Down
17 changes: 17 additions & 0 deletions sos/policies/package_managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,23 @@ def __init__(self, primary, fallbacks, chroot=None, remote_exec=None):
self._managers = [self.primary]
self._managers.extend(self.fallbacks)

def _parse_pkg_list(self, pkg_list):
"""
Using the output of `query_command`, build the _packages dict.
This should be overridden by distinct package managers and be a
generator for _generate_pkg_list which will insert the packages into
the _packages dict.
This method should yield a tuple of name, version, release for each
package parsed. If the package manager or distribution does not use a
release field, set it to None.
:param pkg_list: The output of the result of `query_command`
:type pkg_list: ``str``
"""
raise NotImplementedError

def all_files(self):
if not self.files:
for pm in self._managers:
Expand Down
2 changes: 0 additions & 2 deletions sos/report/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,6 @@ def collect(self):
are more likely to be interrupted by timeouts than file or command
output collections.
"""
pass

@contextlib.contextmanager
def collection_file(self, fname, subdir=None, tags=[]):
Expand Down Expand Up @@ -3470,7 +3469,6 @@ def path_join(self, path, *p):
def postproc(self):
"""Perform any postprocessing. To be replaced by a plugin if required.
"""
pass

def check_process_by_name(self, process):
"""Checks if a named process is found in /proc/[0-9]*/cmdline.
Expand Down
3 changes: 0 additions & 3 deletions tests/sos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,17 @@ def post_test_tear_down(self):
"""Called at the end of a test run to ensure that any needed per-test
cleanup can be done.
"""
pass

def setup_mocking(self):
"""Since we need to use setUp() in our overrides of avocado.Test,
provide an alternate method for test cases that subclass BaseSoSTest
to use.
"""
pass

def pre_sos_setup(self):
"""Do any needed non-mocking setup prior to the sos execution that is
called in setUp()
"""
pass

def assertFileExists(self, fname):
"""Asserts that fname exists on the filesystem"""
Expand Down
8 changes: 8 additions & 0 deletions tests/unittests/policy_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@
class FauxPolicy(Policy):
distro = "Faux"

@classmethod
def check(cls, remote=''):
return False


class FauxLinuxPolicy(LinuxPolicy):
distro = "FauxLinux"

@classmethod
def check(cls, remote=''):
return False

@classmethod
def set_forbidden_paths(cls):
return ['/etc/secret']
Expand Down

0 comments on commit e81bdb4

Please sign in to comment.