Skip to content

Commit

Permalink
Testing: pyupgrade, remove unnecessary object inheritance; rucio#6538
Browse files Browse the repository at this point in the history
Since Python 3, all classes inherit from object by default,
so object can be omitted from the list of base classes.

See also:
- https://docs.astral.sh/ruff/rules/useless-object-inheritance/
- https://peps.python.org/pep-3115/
  • Loading branch information
rdimaio authored and voetberg committed Apr 15, 2024
1 parent e47b811 commit 0d72db0
Show file tree
Hide file tree
Showing 31 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lib/rucio/client/baseclient.py
Expand Up @@ -67,7 +67,7 @@ def choice(hosts):
return random.choice(hosts)


class BaseClient(object):
class BaseClient:

"""Main client class for accessing Rucio resources. Handles the authentication."""

Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/common/didtype.py
Expand Up @@ -19,7 +19,7 @@
from rucio.common.exception import DIDError


class DID(object):
class DID:

"""
Class used to store a DID
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/common/dumper/__init__.py
Expand Up @@ -38,7 +38,7 @@ def __init__(self, msg='', code=None):
super(HTTPDownloadFailed, self).__init__(msg)


class LogPipeHandler(logging.Handler, object):
class LogPipeHandler(logging.Handler):
def __init__(self, pipe):
super(LogPipeHandler, self).__init__()
self.pipe = pipe
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/common/dumper/data_models.py
Expand Up @@ -29,7 +29,7 @@
from rucio.common.dumper import DUMPS_CACHE_DIR, HTTPDownloadFailed, get_requests_session, http_download_to_file, smart_open, temp_file, to_datetime


class DataModel(object):
class DataModel:
"""
Data model for the dumps
"""
Expand Down Expand Up @@ -267,7 +267,7 @@ def __init__(self, *args):
assert len(args) <= 9


class Filter(object):
class Filter:
_Condition = collections.namedtuple('_Condition', ('comparator', 'attribute', 'expected'))

def __init__(self, filter_str, record_class):
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/common/types.py
Expand Up @@ -15,7 +15,7 @@
from typing import Any, Callable, Literal, Optional, TypedDict, Union


class InternalType(object):
class InternalType:
'''
Base for Internal representations of string types
'''
Expand Down
Expand Up @@ -23,7 +23,7 @@
from sqlalchemy.orm import Session


class DidMetaPlugin(object, metaclass=ABCMeta):
class DidMetaPlugin(metaclass=ABCMeta):
"""
Interface for plugins managing metadata of DIDs
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/core/rse_expression_parser.py
Expand Up @@ -208,7 +208,7 @@ def __extract_term(expression):
raise SystemError('This point in the code should not be reachable')


class BaseExpressionElement(object, metaclass=abc.ABCMeta):
class BaseExpressionElement(metaclass=abc.ABCMeta):
@abc.abstractmethod
def resolve_elements(self, session):
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/core/transfer.py
Expand Up @@ -927,7 +927,7 @@ def apply(self, ctx: RequestRankingContext, source: RequestSource) -> "Optional[
"""
pass

class _ClassNameDescriptor(object):
class _ClassNameDescriptor:
"""
Automatically set the external_name of the strategy to the class name.
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/daemons/auditor/srmdumps.py
Expand Up @@ -34,7 +34,7 @@
__DUMPERCONFIGDIRS = list(filter(os.path.exists, __DUMPERCONFIGDIRS))


class Parser(ConfigParser.RawConfigParser, object):
class Parser(ConfigParser.RawConfigParser):
'''
RawConfigParser subclass that doesn't modify the the name of the options
and removes any quotes arround the string values.
Expand Down Expand Up @@ -110,7 +110,7 @@ def gfal_links(base_url):
return ['/'.join((base_url, f)) for f in ctxt.listdir(str(base_url))]


class _LinkCollector(HTMLParser.HTMLParser, object):
class _LinkCollector(HTMLParser.HTMLParser):
def __init__(self):
super(_LinkCollector, self).__init__()
self.links = []
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/daemons/c3po/collectors/agis.py
Expand Up @@ -19,11 +19,11 @@
from rucio.common.config import config_get


class MappingCollector(object):
class MappingCollector:
"""
Provides mappings from PanDA / DDM resources to ATLAS sites and back.
"""
class _MappingCollector(object):
class _MappingCollector:
'''
_MappingCollector
'''
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/daemons/c3po/collectors/free_space.py
Expand Up @@ -20,11 +20,11 @@
from rucio.db.sqla.session import read_session


class FreeSpaceCollector(object):
class FreeSpaceCollector:
"""
Collector to get the SRM free and used information for DATADISK RSEs.
"""
class _FreeSpaceCollector(object):
class _FreeSpaceCollector:
"""
Hidden implementation
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/collectors/mock_did.py
Expand Up @@ -19,7 +19,7 @@
from random import choice


class MockDIDCollector(object):
class MockDIDCollector:
"""
Simple collector that reads dids from a file. Used to
test the interface.
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/collectors/network_metrics.py
Expand Up @@ -19,7 +19,7 @@
from rucio.common.config import config_get, config_get_int


class NetworkMetricsCollector(object):
class NetworkMetricsCollector:
"""
Collector to get the bandwidth metrics between two sites.
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/daemons/c3po/collectors/workload.py
Expand Up @@ -26,13 +26,13 @@
from rucio.daemons.c3po.utils.timeseries import RedisTimeSeries


class WorkloadCollector(object):
class WorkloadCollector:
"""
Collector to retrieve the workload from PanDA. It stores it as a time series in Redis and provides
the average and maximum number of running jobs for a sliding window.
"""

class __WorkloadCollector(object):
class __WorkloadCollector:
"""
Private class needed implement singleton.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/utils/dataset_cache.py
Expand Up @@ -17,7 +17,7 @@
from rucio.daemons.c3po.utils.timeseries import RedisTimeSeries


class DatasetCache(object):
class DatasetCache:
"""
Utility to count the accesses of the datasets during the last day.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py
Expand Up @@ -20,7 +20,7 @@
from redis import StrictRedis


class ExpiringDatasetCache(object):
class ExpiringDatasetCache:
"""
Cache with expiring values to keep track of recently created replicas.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/utils/expiring_list.py
Expand Up @@ -20,7 +20,7 @@
from threading import Lock, Timer


class ExpiringList(object):
class ExpiringList:
"""
Simple list with time based element expiration
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/c3po/utils/timeseries.py
Expand Up @@ -21,7 +21,7 @@
from redis import StrictRedis


class RedisTimeSeries(object):
class RedisTimeSeries:
"""
Redis time series abstraction
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/conveyor/receiver.py
Expand Up @@ -46,7 +46,7 @@
DAEMON_NAME = 'conveyor-receiver'


class Receiver(object):
class Receiver:

def __init__(self, broker, id_, total_threads, transfer_stats_manager: request_core.TransferStatsManager, all_vos=False):
self.__all_vos = all_vos
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/daemons/storage/consistency/actions.py
Expand Up @@ -122,7 +122,7 @@ def declare_bad_file_replicas(dids, rse_id, reason, issuer,
# TODO: This is Igor's Stats class.It will be factored out as a separate class in a future version of the code.
# - Igor Mandrichenko <ivm@fnal.gov>, 2018

class Stats(object):
class Stats:

def __init__(self, path):
self.path = path
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/db/sqla/models.py
Expand Up @@ -182,7 +182,7 @@ def _ck_constraint_name(const, table):
const.name = "REQUESTS_HISTORY_STATE_CHK"


class ModelBase(object):
class ModelBase:
"""Base class for Rucio Models"""
__table_initialized__ = False

Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/rse/protocols/protocol.py
Expand Up @@ -261,7 +261,7 @@ def path(self, scope, name):
RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access


class RSEProtocol(object):
class RSEProtocol:
""" This class is virtual and acts as a base to inherit new protocols from. It further provides some common functionality which applies for the amjority of the protocols."""

def __init__(self, protocol_attr, rse_settings, logger=logging.log):
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/rse/protocols/webdav.py
Expand Up @@ -39,7 +39,7 @@ def init_poolmanager(self, connections, maxsize, block=False):
ca_cert_dir="/etc/grid-security/certificates")


class UploadInChunks(object):
class UploadInChunks:
'''
Class to upload by chunks.
'''
Expand Down Expand Up @@ -72,7 +72,7 @@ def __len__(self):
return self.__totalsize


class IterableToFileAdapter(object):
class IterableToFileAdapter:
'''
Class IterableToFileAdapter
'''
Expand Down
6 changes: 3 additions & 3 deletions lib/rucio/transfertool/transfertool.py
Expand Up @@ -26,7 +26,7 @@
from rucio.core.rse import RseData


class TransferToolBuilder(object):
class TransferToolBuilder:
"""
Builder for Transfertool objects.
Stores the parameters needed to create the Transfertool object of the given type/class.
Expand All @@ -53,7 +53,7 @@ def make_transfertool(self, **additional_kwargs):
return self.transfertool_class(**all_kwargs)


class TransferStatusReport(object, metaclass=ABCMeta):
class TransferStatusReport(metaclass=ABCMeta):
"""
Allows to compute the changes which have to be applied to the database
to reflect the current status reported by the external transfertool into
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_db_fields_to_update(self, session, logger=logging.log):
return updates


class Transfertool(object, metaclass=ABCMeta):
class Transfertool(metaclass=ABCMeta):
"""
Interface definition of the Rucio transfertool
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/web/rest/flaskapi/v1/common.py
Expand Up @@ -42,7 +42,7 @@
HeadersType = Union[Headers, dict[str, str], Sequence[tuple[str, str]]]


class CORSMiddleware(object):
class CORSMiddleware:
"""
WebUI 2.0 makes preflight requests to the API, which are not handled by the API.
This middleware intercepts the preflight OPTIONS requests and returns a 200 OK response.
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/gfal2.py
Expand Up @@ -15,13 +15,13 @@
import contextlib


class MockGfal2(object):
class MockGfal2:
"""
This is a mock gfal2 to test the Storage dumper
"""
files = {}

class MockContext(object):
class MockContext:
'''
MockContext
'''
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auditor_hdfs.py
Expand Up @@ -21,7 +21,7 @@
from rucio.daemons.auditor import hdfs


class FakeHDFSGet(object):
class FakeHDFSGet:
def __init__(self, files=[]):
self.files = files

Expand Down
4 changes: 2 additions & 2 deletions tests/test_dumper_data_model.py
Expand Up @@ -214,7 +214,7 @@ def test_raises_exception(self, mock_session_head, mock_session_get, tmp_path):
)


class TestCompleteDataset(object):
class TestCompleteDataset:

@staticmethod
def test_creation_with_7_parameters():
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_empty_size_is_():
assert complete_dataset.size is None # pylint: disable=no-member


class TestReplica(object):
class TestReplica:

@staticmethod
def test_replica_with_8_parameters():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dumper_path_parsing.py
Expand Up @@ -15,7 +15,7 @@
from rucio.common.dumper.path_parsing import components, remove_prefix


class TestPathParsing(object):
class TestPathParsing:
def test_remove_prefix(self):
prefix = ['a', 'b', 'c', 'd']

Expand Down
2 changes: 1 addition & 1 deletion tests/test_hermes.py
Expand Up @@ -29,7 +29,7 @@
from rucio.tests.common import rse_name_generator, skip_missing_elasticsearch_influxdb_in_env


class MyListener(object):
class MyListener:
def __init__(self, conn):
self.conn = conn
self.count = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_oidc.py
Expand Up @@ -185,7 +185,7 @@ def parse_response(cls, AuthorizationResponse, info=None, sformat="urlencoded"):
return None


class MockResponse(object):
class MockResponse:
def __init__(self, json_data):
self.json_data = json_data

Expand Down

0 comments on commit 0d72db0

Please sign in to comment.