Skip to content

Commit

Permalink
Remove pylint ignore comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aris-aiven committed Oct 19, 2024
1 parent 5933e23 commit 955a533
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 30 deletions.
1 change: 0 additions & 1 deletion astacus/common/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions astacus/common/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion astacus/common/rohmustorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion astacus/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions astacus/coordinator/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 3 additions & 6 deletions astacus/node/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions astacus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/asyncio_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/common/cassandra/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/common/test_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/unit/coordinator/plugins/cassandra/test_backup_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/unit/coordinator/plugins/clickhouse/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/unit/coordinator/test_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 955a533

Please sign in to comment.