From 0d72db01ac3db95d238243f0ed197389c53ce64d Mon Sep 17 00:00:00 2001 From: rdimaio Date: Mon, 18 Mar 2024 17:18:11 +0100 Subject: [PATCH] Testing: pyupgrade, remove unnecessary object inheritance; #6538 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/ --- lib/rucio/client/baseclient.py | 2 +- lib/rucio/common/didtype.py | 2 +- lib/rucio/common/dumper/__init__.py | 2 +- lib/rucio/common/dumper/data_models.py | 4 ++-- lib/rucio/common/types.py | 2 +- .../core/did_meta_plugins/did_meta_plugin_interface.py | 2 +- lib/rucio/core/rse_expression_parser.py | 2 +- lib/rucio/core/transfer.py | 2 +- lib/rucio/daemons/auditor/srmdumps.py | 4 ++-- lib/rucio/daemons/c3po/collectors/agis.py | 4 ++-- lib/rucio/daemons/c3po/collectors/free_space.py | 4 ++-- lib/rucio/daemons/c3po/collectors/mock_did.py | 2 +- lib/rucio/daemons/c3po/collectors/network_metrics.py | 2 +- lib/rucio/daemons/c3po/collectors/workload.py | 4 ++-- lib/rucio/daemons/c3po/utils/dataset_cache.py | 2 +- lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py | 2 +- lib/rucio/daemons/c3po/utils/expiring_list.py | 2 +- lib/rucio/daemons/c3po/utils/timeseries.py | 2 +- lib/rucio/daemons/conveyor/receiver.py | 2 +- lib/rucio/daemons/storage/consistency/actions.py | 2 +- lib/rucio/db/sqla/models.py | 2 +- lib/rucio/rse/protocols/protocol.py | 2 +- lib/rucio/rse/protocols/webdav.py | 4 ++-- lib/rucio/transfertool/transfertool.py | 6 +++--- lib/rucio/web/rest/flaskapi/v1/common.py | 2 +- tests/mocks/gfal2.py | 4 ++-- tests/test_auditor_hdfs.py | 2 +- tests/test_dumper_data_model.py | 4 ++-- tests/test_dumper_path_parsing.py | 2 +- tests/test_hermes.py | 2 +- tests/test_oidc.py | 2 +- 31 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py index c512625b4c..9c93e01cc1 100644 --- a/lib/rucio/client/baseclient.py +++ b/lib/rucio/client/baseclient.py @@ -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.""" diff --git a/lib/rucio/common/didtype.py b/lib/rucio/common/didtype.py index ffb52a6797..4e463e5644 100755 --- a/lib/rucio/common/didtype.py +++ b/lib/rucio/common/didtype.py @@ -19,7 +19,7 @@ from rucio.common.exception import DIDError -class DID(object): +class DID: """ Class used to store a DID diff --git a/lib/rucio/common/dumper/__init__.py b/lib/rucio/common/dumper/__init__.py index 4e530480e5..c18193a3f9 100644 --- a/lib/rucio/common/dumper/__init__.py +++ b/lib/rucio/common/dumper/__init__.py @@ -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 diff --git a/lib/rucio/common/dumper/data_models.py b/lib/rucio/common/dumper/data_models.py index 90e68fc7c4..dfb4f20022 100644 --- a/lib/rucio/common/dumper/data_models.py +++ b/lib/rucio/common/dumper/data_models.py @@ -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 """ @@ -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): diff --git a/lib/rucio/common/types.py b/lib/rucio/common/types.py index aa3b9a9b8c..d085839695 100644 --- a/lib/rucio/common/types.py +++ b/lib/rucio/common/types.py @@ -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 ''' diff --git a/lib/rucio/core/did_meta_plugins/did_meta_plugin_interface.py b/lib/rucio/core/did_meta_plugins/did_meta_plugin_interface.py index 862b97b53e..d43a4eaa1f 100644 --- a/lib/rucio/core/did_meta_plugins/did_meta_plugin_interface.py +++ b/lib/rucio/core/did_meta_plugins/did_meta_plugin_interface.py @@ -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 """ diff --git a/lib/rucio/core/rse_expression_parser.py b/lib/rucio/core/rse_expression_parser.py index d44417d8bd..eb19b738c0 100644 --- a/lib/rucio/core/rse_expression_parser.py +++ b/lib/rucio/core/rse_expression_parser.py @@ -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): """ diff --git a/lib/rucio/core/transfer.py b/lib/rucio/core/transfer.py index 1854936587..f16eec3fd9 100644 --- a/lib/rucio/core/transfer.py +++ b/lib/rucio/core/transfer.py @@ -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. """ diff --git a/lib/rucio/daemons/auditor/srmdumps.py b/lib/rucio/daemons/auditor/srmdumps.py index e87ed06682..50bcbd68f4 100644 --- a/lib/rucio/daemons/auditor/srmdumps.py +++ b/lib/rucio/daemons/auditor/srmdumps.py @@ -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. @@ -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 = [] diff --git a/lib/rucio/daemons/c3po/collectors/agis.py b/lib/rucio/daemons/c3po/collectors/agis.py index ab8be9a45d..cd405736c8 100644 --- a/lib/rucio/daemons/c3po/collectors/agis.py +++ b/lib/rucio/daemons/c3po/collectors/agis.py @@ -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 ''' diff --git a/lib/rucio/daemons/c3po/collectors/free_space.py b/lib/rucio/daemons/c3po/collectors/free_space.py index 3b8db0ea62..6f0fcec1a7 100644 --- a/lib/rucio/daemons/c3po/collectors/free_space.py +++ b/lib/rucio/daemons/c3po/collectors/free_space.py @@ -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 """ diff --git a/lib/rucio/daemons/c3po/collectors/mock_did.py b/lib/rucio/daemons/c3po/collectors/mock_did.py index 07a6efe616..a98b79f39b 100644 --- a/lib/rucio/daemons/c3po/collectors/mock_did.py +++ b/lib/rucio/daemons/c3po/collectors/mock_did.py @@ -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. diff --git a/lib/rucio/daemons/c3po/collectors/network_metrics.py b/lib/rucio/daemons/c3po/collectors/network_metrics.py index f62881ee9f..6608c84d3e 100644 --- a/lib/rucio/daemons/c3po/collectors/network_metrics.py +++ b/lib/rucio/daemons/c3po/collectors/network_metrics.py @@ -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. """ diff --git a/lib/rucio/daemons/c3po/collectors/workload.py b/lib/rucio/daemons/c3po/collectors/workload.py index 45634eaec4..808355f9d8 100644 --- a/lib/rucio/daemons/c3po/collectors/workload.py +++ b/lib/rucio/daemons/c3po/collectors/workload.py @@ -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. """ diff --git a/lib/rucio/daemons/c3po/utils/dataset_cache.py b/lib/rucio/daemons/c3po/utils/dataset_cache.py index f7784a96a4..96cc59f1d3 100644 --- a/lib/rucio/daemons/c3po/utils/dataset_cache.py +++ b/lib/rucio/daemons/c3po/utils/dataset_cache.py @@ -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. """ diff --git a/lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py b/lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py index 532aadce61..a504918377 100644 --- a/lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py +++ b/lib/rucio/daemons/c3po/utils/expiring_dataset_cache.py @@ -20,7 +20,7 @@ from redis import StrictRedis -class ExpiringDatasetCache(object): +class ExpiringDatasetCache: """ Cache with expiring values to keep track of recently created replicas. """ diff --git a/lib/rucio/daemons/c3po/utils/expiring_list.py b/lib/rucio/daemons/c3po/utils/expiring_list.py index 9663c9e928..c90969dc99 100644 --- a/lib/rucio/daemons/c3po/utils/expiring_list.py +++ b/lib/rucio/daemons/c3po/utils/expiring_list.py @@ -20,7 +20,7 @@ from threading import Lock, Timer -class ExpiringList(object): +class ExpiringList: """ Simple list with time based element expiration """ diff --git a/lib/rucio/daemons/c3po/utils/timeseries.py b/lib/rucio/daemons/c3po/utils/timeseries.py index 4c38a652a2..75ed02ae53 100644 --- a/lib/rucio/daemons/c3po/utils/timeseries.py +++ b/lib/rucio/daemons/c3po/utils/timeseries.py @@ -21,7 +21,7 @@ from redis import StrictRedis -class RedisTimeSeries(object): +class RedisTimeSeries: """ Redis time series abstraction """ diff --git a/lib/rucio/daemons/conveyor/receiver.py b/lib/rucio/daemons/conveyor/receiver.py index 3d61f89eb4..5db6badc95 100644 --- a/lib/rucio/daemons/conveyor/receiver.py +++ b/lib/rucio/daemons/conveyor/receiver.py @@ -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 diff --git a/lib/rucio/daemons/storage/consistency/actions.py b/lib/rucio/daemons/storage/consistency/actions.py index a765bf67d8..2a548a59ff 100644 --- a/lib/rucio/daemons/storage/consistency/actions.py +++ b/lib/rucio/daemons/storage/consistency/actions.py @@ -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 , 2018 -class Stats(object): +class Stats: def __init__(self, path): self.path = path diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py index c4ac717e42..c811714843 100644 --- a/lib/rucio/db/sqla/models.py +++ b/lib/rucio/db/sqla/models.py @@ -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 diff --git a/lib/rucio/rse/protocols/protocol.py b/lib/rucio/rse/protocols/protocol.py index 2c9ed4c2e5..063d5ae4c6 100644 --- a/lib/rucio/rse/protocols/protocol.py +++ b/lib/rucio/rse/protocols/protocol.py @@ -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): diff --git a/lib/rucio/rse/protocols/webdav.py b/lib/rucio/rse/protocols/webdav.py index e9f8b243e2..61ddba3d09 100644 --- a/lib/rucio/rse/protocols/webdav.py +++ b/lib/rucio/rse/protocols/webdav.py @@ -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. ''' @@ -72,7 +72,7 @@ def __len__(self): return self.__totalsize -class IterableToFileAdapter(object): +class IterableToFileAdapter: ''' Class IterableToFileAdapter ''' diff --git a/lib/rucio/transfertool/transfertool.py b/lib/rucio/transfertool/transfertool.py index 87ebf4e236..f9852250a0 100644 --- a/lib/rucio/transfertool/transfertool.py +++ b/lib/rucio/transfertool/transfertool.py @@ -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. @@ -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 @@ -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 """ diff --git a/lib/rucio/web/rest/flaskapi/v1/common.py b/lib/rucio/web/rest/flaskapi/v1/common.py index ae7409f28b..3ab1a1f6b0 100644 --- a/lib/rucio/web/rest/flaskapi/v1/common.py +++ b/lib/rucio/web/rest/flaskapi/v1/common.py @@ -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. diff --git a/tests/mocks/gfal2.py b/tests/mocks/gfal2.py index 0026940225..12b0388d41 100644 --- a/tests/mocks/gfal2.py +++ b/tests/mocks/gfal2.py @@ -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 ''' diff --git a/tests/test_auditor_hdfs.py b/tests/test_auditor_hdfs.py index fa895f00cd..4f6d1a2081 100644 --- a/tests/test_auditor_hdfs.py +++ b/tests/test_auditor_hdfs.py @@ -21,7 +21,7 @@ from rucio.daemons.auditor import hdfs -class FakeHDFSGet(object): +class FakeHDFSGet: def __init__(self, files=[]): self.files = files diff --git a/tests/test_dumper_data_model.py b/tests/test_dumper_data_model.py index bad2bab773..25cd68f0fa 100644 --- a/tests/test_dumper_data_model.py +++ b/tests/test_dumper_data_model.py @@ -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(): @@ -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(): diff --git a/tests/test_dumper_path_parsing.py b/tests/test_dumper_path_parsing.py index 6bbd25a1e3..cfe93102a5 100644 --- a/tests/test_dumper_path_parsing.py +++ b/tests/test_dumper_path_parsing.py @@ -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'] diff --git a/tests/test_hermes.py b/tests/test_hermes.py index 25ec7e6e87..f10e905a46 100644 --- a/tests/test_hermes.py +++ b/tests/test_hermes.py @@ -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 diff --git a/tests/test_oidc.py b/tests/test_oidc.py index 18a1ff8d37..54e04516a5 100644 --- a/tests/test_oidc.py +++ b/tests/test_oidc.py @@ -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