diff --git a/astacus/common/ipc.py b/astacus/common/ipc.py index 43dd7eb1..a82315e9 100644 --- a/astacus/common/ipc.py +++ b/astacus/common/ipc.py @@ -17,7 +17,6 @@ import socket # pydantic validators are class methods in disguise -# pylint: disable=no-self-argument # These are the database plugins we support; list is intentionally diff --git a/astacus/common/op.py b/astacus/common/op.py index 643a1d9e..a45d94bd 100644 --- a/astacus/common/op.py +++ b/astacus/common/op.py @@ -121,7 +121,7 @@ async def _async_wrapper(): except asyncio.CancelledError: with contextlib.suppress(ExpiredOperationException): op.set_status_fail() - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: logger.warning("Unexpected exception during async %s %s %r", op, fun, ex) with contextlib.suppress(ExpiredOperationException): op.set_status_fail() @@ -134,7 +134,7 @@ def _sync_wrapper(): op.set_status(Op.Status.done, from_status=Op.Status.running) except ExpiredOperationException: pass - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: logger.warning("Unexpected exception during sync %s %s %r", op, fun, ex) with contextlib.suppress(ExpiredOperationException): op.set_status_fail() diff --git a/astacus/common/rohmustorage.py b/astacus/common/rohmustorage.py index 557b18d0..29606823 100644 --- a/astacus/common/rohmustorage.py +++ b/astacus/common/rohmustorage.py @@ -108,7 +108,7 @@ def _f(*a, **kw): return fun(*a, **kw) except errors.FileNotFoundFromStorageError as ex: raise exceptions.NotFoundException from ex - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: raise exceptions.RohmuException from ex return _f diff --git a/astacus/common/storage.py b/astacus/common/storage.py index 4cf16b6b..5e023e13 100644 --- a/astacus/common/storage.py +++ b/astacus/common/storage.py @@ -95,7 +95,6 @@ def download_json(self, name, struct_type: type[ST]) -> ST: class Storage(HexDigestStorage, JsonStorage, ABC): - # pylint: disable=abstract-method # This is abstract class which has whatever APIs necessary. Due to that, # it is expected not to implement the abstract methods. @abstractmethod diff --git a/astacus/coordinator/plugins/__init__.py b/astacus/coordinator/plugins/__init__.py index 383eb7c3..ae805616 100644 --- a/astacus/coordinator/plugins/__init__.py +++ b/astacus/coordinator/plugins/__init__.py @@ -3,8 +3,6 @@ def get_plugin(plugin: Plugin) -> type[CoordinatorPlugin]: - # pylint: disable=import-outside-toplevel - if plugin == Plugin.cassandra: from .cassandra.plugin import CassandraPlugin diff --git a/astacus/node/api.py b/astacus/node/api.py index cf55bd32..9d6e8929 100644 --- a/astacus/node/api.py +++ b/astacus/node/api.py @@ -310,8 +310,7 @@ def cassandra_start_cassandra( replace_address_first_boot=replace_address_first_boot, skip_bootstrap_streaming=skip_bootstrap_streaming, ) - # pylint: disable=import-outside-toplevel - # pylint: disable=raise-missing-from + try: from .cassandra import CassandraStartOp except ImportError: @@ -336,8 +335,7 @@ def cassandra_restore_sstables( match_tables_by=match_tables_by, expect_empty_target=expect_empty_target, ) - # pylint: disable=import-outside-toplevel - # pylint: disable=raise-missing-from + try: from .cassandra import CassandraRestoreSSTablesOp except ImportError: @@ -349,8 +347,7 @@ def cassandra_restore_sstables( @router.post("/cassandra/{subop}") def cassandra(subop: ipc.CassandraSubOp, result_url: Annotated[str, Body(embed=True)] = "", n: Node = Depends()): req = ipc.NodeRequest(result_url=result_url) - # pylint: disable=import-outside-toplevel - # pylint: disable=raise-missing-from + try: from .cassandra import CassandraGetSchemaHashOp, SimpleCassandraSubOp except ImportError: diff --git a/astacus/server.py b/astacus/server.py index 9806d6ed..b6ddb916 100644 --- a/astacus/server.py +++ b/astacus/server.py @@ -53,9 +53,9 @@ async def _shutdown_event(): gconfig = config.set_global_config_from_path(api, config_path) sentry_dsn = os.environ.get("SENTRY_DSN", gconfig.sentry_dsn) if sentry_dsn: - sentry_sdk.init(dsn=sentry_dsn) # pylint: disable=abstract-class-instantiated + sentry_sdk.init(dsn=sentry_dsn) api.add_middleware(SentryAsgiMiddleware) - global app # pylint: disable=global-statement + global app app = api return api @@ -68,7 +68,7 @@ def _systemd_notify_ready(): if not os.environ.get("NOTIFY_SOCKET"): return try: - from systemd import daemon # pylint: disable=no-name-in-module,disable=import-outside-toplevel + from systemd import daemon daemon.notify("READY=1") except ImportError: diff --git a/tests/plugins/asyncio_loop.py b/tests/plugins/asyncio_loop.py index 34411f7d..f1c78a95 100644 --- a/tests/plugins/asyncio_loop.py +++ b/tests/plugins/asyncio_loop.py @@ -79,7 +79,7 @@ def finalizer() -> Any: def pytest_pycollect_makeitem(collector: PyCollector, name: str, obj: Any) -> list[Function] | None: """Auto-add a "loop" fixture to all async test functions.""" if collector.funcnamefilter(name) and asyncio.iscoroutinefunction(obj): - functions = list(collector._genfunctions(name, obj)) # pylint: disable=protected-access + functions = list(collector._genfunctions(name, obj)) for function in functions: if "loop" not in function.fixturenames: function.fixturenames.append("loop") @@ -91,7 +91,7 @@ def pytest_pyfunc_call(pyfuncitem: Function) -> bool | None: """Run coroutines in an event loop instead of a normal function call.""" if asyncio.iscoroutinefunction(pyfuncitem.function): with _runtime_warning_context(): - fixture_info = pyfuncitem._fixtureinfo # pylint: disable=protected-access + fixture_info = pyfuncitem._fixtureinfo test_args = {arg: pyfuncitem.funcargs[arg] for arg in fixture_info.argnames} loop = cast(asyncio.AbstractEventLoop, pyfuncitem.funcargs["loop"]) loop.run_until_complete(pyfuncitem.obj(**test_args)) @@ -161,7 +161,7 @@ def pytest_collection_modifyitems(session: pytest.Session, config: Config, items def get_scope_identifiers(item: pytest.Function) -> Iterator[Sequence[str]]: """Enumerate all scopes of all the async fixtures required for a test function.""" - fixture_info = item._fixtureinfo # pylint: disable=protected-access + fixture_info = item._fixtureinfo for fixture_name in fixture_info.initialnames: if fixture_name == "request": continue @@ -185,7 +185,7 @@ def get_scope_identifiers(item: pytest.Function) -> Iterator[Sequence[str]]: def get_loop(request: SubRequest) -> Iterator[asyncio.AbstractEventLoop]: """Create a new async loop or reuse one from the outermost async scope.""" - tested_function_request = request._pyfuncitem._request # pylint: disable=protected-access + tested_function_request = request._pyfuncitem._request async_scopes = tested_function_request.node.async_scope.connected_scopes for scope in FIXTURE_SCOPES: if scope == request.scope: diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 74c2128e..c6ae6cc1 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -49,7 +49,6 @@ class TestNode(AstacusModel): @asynccontextmanager async def background_process(program: str | Path, *args: str | Path, **kwargs) -> AsyncIterator[asyncio.subprocess.Process]: - # pylint: disable=bare-except proc = await asyncio.create_subprocess_exec(program, *args, **kwargs) try: yield proc diff --git a/tests/unit/common/cassandra/test_schema.py b/tests/unit/common/cassandra/test_schema.py index 62544d45..7d157eca 100644 --- a/tests/unit/common/cassandra/test_schema.py +++ b/tests/unit/common/cassandra/test_schema.py @@ -9,8 +9,6 @@ import pytest -# pylint: disable=protected-access - def test_schema(mocker: MockerFixture) -> None: cut = schema.CassandraUserType(name="cut", cql_create_self="CREATE-USER-TYPE", field_types=["type1", "type2"]) diff --git a/tests/unit/common/test_op.py b/tests/unit/common/test_op.py index e4e3ffc8..ba251273 100644 --- a/tests/unit/common/test_op.py +++ b/tests/unit/common/test_op.py @@ -51,7 +51,7 @@ async def _async(): else: mixin.start_op(op=op_obj, op_name="dummy", fun=_sync) await mixin.background_tasks() - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: assert expect_ex assert isinstance(ex, expect_ex) assert op_obj.info.op_status == expect_status diff --git a/tests/unit/coordinator/plugins/cassandra/test_backup_steps.py b/tests/unit/coordinator/plugins/cassandra/test_backup_steps.py index 954abdb2..def8e24d 100644 --- a/tests/unit/coordinator/plugins/cassandra/test_backup_steps.py +++ b/tests/unit/coordinator/plugins/cassandra/test_backup_steps.py @@ -2,8 +2,6 @@ See LICENSE for details. """ -# pylint: disable=protected-access - from astacus.common.cassandra.schema import CassandraSchema from astacus.coordinator.plugins.cassandra import backup_steps from astacus.coordinator.plugins.cassandra.model import CassandraConfigurationNode diff --git a/tests/unit/coordinator/plugins/cassandra/test_restore_steps.py b/tests/unit/coordinator/plugins/cassandra/test_restore_steps.py index 267dbcb4..dfed0ad2 100644 --- a/tests/unit/coordinator/plugins/cassandra/test_restore_steps.py +++ b/tests/unit/coordinator/plugins/cassandra/test_restore_steps.py @@ -211,7 +211,7 @@ def test_rewrite_datacenters() -> None: .with_cql_create_self(pre_rewrite_cql) .with_network_topology_strategy_dcs({"new_dc": "3"}), ] - restore_steps._rewrite_datacenters(keyspaces) # pylint: disable=protected-access + restore_steps._rewrite_datacenters(keyspaces) unchanged_keyspace, rewritten_keyspace = keyspaces[0], keyspaces[1] assert unchanged_keyspace.cql_create_self == pre_rewrite_cql assert "'new_dc': '3'" in rewritten_keyspace.cql_create_self diff --git a/tests/unit/coordinator/plugins/clickhouse/test_steps.py b/tests/unit/coordinator/plugins/clickhouse/test_steps.py index 1defe3a2..3cea6f05 100644 --- a/tests/unit/coordinator/plugins/clickhouse/test_steps.py +++ b/tests/unit/coordinator/plugins/clickhouse/test_steps.py @@ -85,7 +85,7 @@ from tests.unit.storage import MemoryJsonStorage from typing import Any from unittest import mock -from unittest.mock import _Call as MockCall, patch # pylint: disable=protected-access +from unittest.mock import _Call as MockCall, patch import asyncio import base64 diff --git a/tests/unit/coordinator/test_restore.py b/tests/unit/coordinator/test_restore.py index 25bdf9e9..10517ce5 100644 --- a/tests/unit/coordinator/test_restore.py +++ b/tests/unit/coordinator/test_restore.py @@ -71,7 +71,6 @@ class RestoreTest: ], ) def test_restore(rt: RestoreTest, app: FastAPI, client: TestClient, tmp_path: Path) -> None: - # pylint: disable=too-many-statements # Create fake backup (not pretty but sufficient?) storage_factory = StorageFactory( storage_config=app.state.coordinator_config.object_storage, diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 40c71e15..1ea1ab2e 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -46,7 +46,7 @@ def sleep(duration: float) -> None: with mock.patch.object(time, "sleep", new=sleep): # mypy wants a return for this function but pylint doesn't - # pylint: disable=useless-return + def http_request(*args, timeout: float = 10, **kwargs) -> Mapping[str, Any] | None: time_since_start = time.monotonic() - start_time assert time_since_start + timeout <= wait_completion_secs, "request could end after completion"