Skip to content

Commit

Permalink
Stop subclassing 'object'
Browse files Browse the repository at this point in the history
New-style classes are the only type of classes available in Python 3,
and they already inherit from 'object'. Hence, drop all the manual
'object' subclassing, which is redundant now.

This only removes the 'object' subclassing, without changing any
leftover of support for old-style classes; hence, there should be no
behaviour changes.

Card ID: ENT-5406
  • Loading branch information
ptoscano committed Mar 3, 2023
1 parent 82a44c3 commit 1f41923
Show file tree
Hide file tree
Showing 83 changed files with 178 additions and 178 deletions.
4 changes: 2 additions & 2 deletions build_ext/build_ext/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run(self):
spawn(["flake8"])


class AstVisitor(object):
class AstVisitor:
"""Visitor pattern for looking at specific nodes in an AST. Basically a copy of
ast.NodeVisitor, but with the additional feature of appending return values onto a result
list that is ultimately returned.
Expand Down Expand Up @@ -163,7 +163,7 @@ def visit_Call(self, node):
)


class AstChecker(object):
class AstChecker:
name = "SubscriptionManagerAstChecker"
version = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion build_ext/build_ext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def finalize_options(self):
pass


class Utils(object):
class Utils:
@staticmethod
def run_if_new(src, dest, callback):
src_mtime = os.stat(src)[8]
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_test_en_po.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


class PotFile(object):
class PotFile:
def __init__(self):

self.msgids = []
Expand Down
2 changes: 1 addition & 1 deletion src/cloud_what/_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
log = logging.getLogger(__name__)


class BaseCloudProvider(object):
class BaseCloudProvider:
"""
Base class of cloud provider. This class is used for cloud detecting
and collecting metadata/signature.
Expand Down
4 changes: 2 additions & 2 deletions src/cloud_what/fact_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
log = logging.getLogger(__name__)


class MiniHostCollector(object):
class MiniHostCollector:
"""
Minimalistic collector of host facts
"""
Expand Down Expand Up @@ -124,7 +124,7 @@ def get_all(self) -> dict:


# We do not need this collector for cloud-what, so it is really dummy
class MiniCustomFactsCollector(object):
class MiniCustomFactsCollector:
@staticmethod
def get_all() -> dict:
return {}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/zypper/services/rhsm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RepoLocker(Locker):
self.lock.release()


class ZypperService(object):
class ZypperService:

ZYPP_RHSM_PLUGIN_CONFIG_FILE = '/etc/rhsm/zypper.conf'

Expand Down
10 changes: 5 additions & 5 deletions src/rct/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def xstr(value):
return str(value)


class ProductPrinter(object):
class ProductPrinter:
def as_str(self, product):
s = []
s.append("%s:" % _("Product"))
Expand All @@ -56,7 +56,7 @@ def as_str(self, product):
return "%s\n" % "\n".join(s)


class OrderPrinter(object):
class OrderPrinter:
def as_str(self, order):

if order is None:
Expand Down Expand Up @@ -90,7 +90,7 @@ def as_str(self, order):
return "%s\n" % "\n".join(s)


class ContentPrinter(object):
class ContentPrinter:
def as_str(self, content):
s = []
s.append("%s:" % _("Content"))
Expand All @@ -109,7 +109,7 @@ def as_str(self, content):
return "\n".join(s)


class CertificatePrinter(object):
class CertificatePrinter:
def cert_to_str(self, cert):
s = []
s.append("\n+-------------------------------------------+")
Expand Down Expand Up @@ -228,7 +228,7 @@ def _get_paths(self, cert):
return "%s" % "\n".join(s)


class CertificatePrinterFactory(object):
class CertificatePrinterFactory:
def get_printer(self, cert, **kwargs):
if isinstance(cert, EntitlementCertificate):
return EntitlementCertificatePrinter(**kwargs)
Expand Down
10 changes: 5 additions & 5 deletions src/rhsm/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def new_func(*args, **kwargs):
return new_func


class Certificate(object):
class Certificate:
"""
Represents and x.509 certificate.
Expand Down Expand Up @@ -505,7 +505,7 @@ def __str__(self) -> str:
return "\n".join(s)


class Key(object):
class Key:
"""
The (private|public) key.
Expand Down Expand Up @@ -572,7 +572,7 @@ def __str__(self) -> str:
return self.content


class DateRange(object):
class DateRange:
"""
Date range object.
Expand Down Expand Up @@ -906,7 +906,7 @@ def __str__(self) -> str:
return self._str


class Order(object):
class Order:
@deprecated
def __init__(self, ext):
self.ext = ext
Expand Down Expand Up @@ -996,7 +996,7 @@ def __str__(self):
return "\n".join(s)


class Product(object):
class Product:
@deprecated
def __init__(self, p_hash: str, ext: Extensions) -> None:
self.hash = p_hash
Expand Down
4 changes: 2 additions & 2 deletions src/rhsm/certificate2.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def __str__(self):
return "<Order: name=%s number=%s sku=%s>" % (self.name, self.number, self.sku)


class Content(object):
class Content:
def __init__(
self,
content_type=None,
Expand Down Expand Up @@ -929,7 +929,7 @@ def __hash__(self):
return hash(self.label)


class Pool(object):
class Pool:
"""
Represents the pool an entitlement originates from.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/rhsm/pathtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
LISTING = "listing"


class PathTree(object):
class PathTree:
"""
This builds and makes available a tree that represents matchable paths. A
path must be matched starting from its root and the root of the tree,
Expand Down
10 changes: 5 additions & 5 deletions src/rhsm/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InvalidProfileType(Exception):
pass


class ModulesProfile(object):
class ModulesProfile:
def __init__(self) -> None:
self.content: List[dict] = self.__generate()

Expand Down Expand Up @@ -191,7 +191,7 @@ def collect(self) -> List[dict]:
return self.content


class EnabledRepos(object):
class EnabledRepos:
def __generate(self) -> List[dict]:
if not os.path.exists(self.repofile):
return []
Expand Down Expand Up @@ -279,7 +279,7 @@ def _obtain_mappings_yum(self) -> dict:
return {"releasever": self.yb.conf.yumvar["releasever"], "basearch": self.yb.conf.yumvar["basearch"]}


class EnabledReposProfile(object):
class EnabledReposProfile:
"""
Collect information about enabled repositories
"""
Expand All @@ -298,7 +298,7 @@ def collect(self) -> List[dict]:
return self._enabled_repos.content


class Package(object):
class Package:
"""
Represents a package installed on the system.
"""
Expand Down Expand Up @@ -354,7 +354,7 @@ def _normalize_string(value: Union[str, bytes]) -> str:
return value


class RPMProfile(object):
class RPMProfile:
def __init__(self, from_file: _io.TextIOWrapper = None) -> None:
"""
Load the RPM package profile from a given file, or from rpm itself.
Expand Down
2 changes: 1 addition & 1 deletion src/rhsm_debug/debug_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _makedir(self, dest_dir_name):
os.makedirs(dest_dir_name, ROOT_READ_ONLY_DIR)


class SaferFileMove(object):
class SaferFileMove:
"""Try to copy a file avoiding race conditions.
Opens the dest file os.O_RDWR | os.O_CREAT | os.O_EXCL, which
Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/candlepin/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CandlepinApiNetworkError(CandlepinApiError):
pass


class Candlepin(object):
class Candlepin:
def __init__(self, uep):
self.uep = uep
self._default_args = ()
Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/dbus/facts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, *args, **kwargs):
self.action_id = action_id


class FactsClient(object):
class FactsClient:
bus_name = facts_constants.FACTS_DBUS_NAME
object_path = facts_constants.FACTS_DBUS_PATH
interface_name = facts_constants.FACTS_DBUS_INTERFACE
Expand Down
4 changes: 2 additions & 2 deletions src/rhsmlib/dbus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
conf = config.Config(parser)


class Server(object):
class Server:
"""
Class used for rhsm.service providing D-Bus API
"""
Expand Down Expand Up @@ -246,7 +246,7 @@ def enable_dir_watchers(cls, watcher_set: set = None) -> None:
dir_watcher.enable()


class DomainSocketServer(object):
class DomainSocketServer:
"""This class sets up a DBus server on a domain socket. That server can then be used to perform
registration. The issue is that we can't send registration credentials over the regular system or
session bus since those aren't really locked down. The work-around is the client asks our service
Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/facts/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def compare_with_graylist(dict_a: dict, dict_b: dict, graylist: Set[str]) -> boo
return ka == kb and all(dict_a[k] == dict_b[k] for k in ka)


class FactsCollection(object):
class FactsCollection:
def __init__(self, facts_dict: FactsDict = None):
self.data: FactsDict = facts_dict or FactsDict()
self.collection_datetime = datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/facts/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_arch(prefix: str = None) -> str:
# An empty FactsCollector should just return an empty dict on get_all()


class FactsCollector(object):
class FactsCollector:
def __init__(
self,
arch: str = None,
Expand Down
14 changes: 7 additions & 7 deletions src/rhsmlib/facts/cpuinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
log = logging.getLogger("rhsm-app." + __name__)


class DefaultCpuFields(object):
class DefaultCpuFields:
"""Maps generic cpuinfo fields to the corresponding field from ProcessorModel.
For, a cpu MODEL (a number or string that the cpu vendor assigns to that model of
Expand All @@ -121,23 +121,23 @@ class DefaultCpuFields(object):
MODEL: str = "model"


class X86_64Fields(object):
class X86_64Fields:
MODEL_NAME: str = "model_name"
MODEL: str = "model"


class Aarch64Fields(object):
class Aarch64Fields:
MODEL: str = "cpu_part"
MODEL_NAME: str = "model_name"


class Ppc64Fields(object):
class Ppc64Fields:
MODEL: str = "model"
MODEL_NAME: str = "machine"


# represent the data in /proc/cpuinfo, which may include multiple processors
class CpuinfoModel(object):
class CpuinfoModel:
fields_class: type = DefaultCpuFields

def __init__(self, cpuinfo_data: str = None):
Expand Down Expand Up @@ -347,7 +347,7 @@ def split_kv_list_by_field(
"""


class BaseCpuInfo(object):
class BaseCpuInfo:
cpu_info: CpuinfoModel

@classmethod
Expand Down Expand Up @@ -473,7 +473,7 @@ def _not_timebase_key(self, item: str) -> bool:
return item[0] != "timebase"


class SystemCpuInfoFactory(object):
class SystemCpuInfoFactory:
uname_to_cpuinfo: Dict[str, type(BaseCpuInfo)] = {
"x86_64": X86_64CpuInfo,
"aarch64": Aarch64CpuInfo,
Expand Down
8 changes: 4 additions & 4 deletions src/rhsmlib/facts/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
log = logging.getLogger(__name__)


class CustomFacts(object):
class CustomFacts:
def __init__(self, data: Dict[str, Any] = None):
self.data: Dict[str, Any] = data

Expand Down Expand Up @@ -52,7 +52,7 @@ class CustomFactsFileError(Exception):
pass


class CustomFactsFile(object):
class CustomFactsFile:
def __init__(self, path: str = None):
self.path: str = path
self.buf = None
Expand All @@ -73,7 +73,7 @@ def close(self) -> None:
pass


class CustomFactsDirectory(object):
class CustomFactsDirectory:
def __init__(self, path: str = None, glob_pattern: str = None):
self.path: str = path
self.glob_pattern: str = glob_pattern
Expand All @@ -94,7 +94,7 @@ def __iter__(self) -> Generator[CustomFacts, None, None]:
yield CustomFacts.from_json(fact_file.read())


class CustomFactsDirectories(object):
class CustomFactsDirectories:
def __init__(self, path_and_globs: Dict[str, str]):
self.path_and_globs: Dict[str, str] = path_and_globs

Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/facts/firmware_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# This doesn't really do anything other than provide a null/noop provider for
# non-DMI platforms.
class NullFirmwareInfoCollector(object):
class NullFirmwareInfoCollector:
"""Default provider for platform without a specific platform info provider.
ie, all platforms except those with DMI (ie, intel platforms)"""
Expand Down
Loading

0 comments on commit 1f41923

Please sign in to comment.