for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
class PackageRequirement:
def __init__(self, manager: str, package: str, version):
"""
:param manager: A string with the name of the manager (pip, npm, etc).
:param package: A string with the name of the package to be installed.
:param version: A number that contains the version.
self.manager = manager
self.package = package
self.version = version
def __str__(self):
return "{.package} version {.version} (for {.manager})".format(self)
def check(self):
Check if the requirement is satisfied.
raise NotImplementedError
class PythonRequirement(PackageRequirement):
def __init__(self, package: str, version):
__init__
PackageRequirement
It is generally advisable to initialize the super-class by calling its __init__ method:
class SomeParent: def __init__(self): self.x = 1 class SomeChild(SomeParent): def __init__(self): # Initialize the super class SomeParent.__init__(self)
return "{.package} version {.version}".format(self)
def multiple(self, *args):
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
class Foo: def some_method(self, x, y): return x + y;
could be written as
class Foo: @classmethod def some_method(cls, x, y): return x + y;
return args
It is generally advisable to initialize the super-class by calling its
__init__
method: