Skip to content

Fix Ruff B007 fix Loop control variable not used within loop body #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ ignore = [
# like this so that we can reactivate them one by one. Alternatively ignored after further #
# investigation if they are deemed to not make sense. #
##################################################################################################
"B007", # Loop control variable `result` not used within loop body
"B008", # Do not perform function call `typer.Option` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
Expand Down
18 changes: 13 additions & 5 deletions tests/unit/sdk/test_batch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest
from pytest_httpx import HTTPXMock

from infrahub_sdk.exceptions import GraphQLError

if TYPE_CHECKING:
from pytest_httpx import HTTPXMock

from tests.unit.sdk.conftest import BothClients


async def test_batch_return_exception(
httpx_mock: HTTPXMock, mock_query_mutation_location_create_failed, mock_schema_query_01, clients
httpx_mock: HTTPXMock, mock_query_mutation_location_create_failed, mock_schema_query_01, clients: BothClients
): # pylint: disable=unused-argument
batch = await clients.standard.create_batch(return_exceptions=True)
locations = ["JFK1", "JFK1"]
Expand All @@ -30,7 +38,7 @@ async def test_batch_return_exception(


async def test_batch_exception(
httpx_mock: HTTPXMock, mock_query_mutation_location_create_failed, mock_schema_query_01, clients
httpx_mock: HTTPXMock, mock_query_mutation_location_create_failed, mock_schema_query_01, clients: BothClients
): # pylint: disable=unused-argument
batch = await clients.standard.create_batch(return_exceptions=False)
locations = ["JFK1", "JFK1"]
Expand All @@ -40,11 +48,11 @@ async def test_batch_exception(
batch.add(task=obj.save, node=obj)

with pytest.raises(GraphQLError) as exc:
async for node, result in batch.execute():
async for _, _ in batch.execute():
pass
assert "An error occurred while executing the GraphQL Query" in str(exc.value)


async def test_batch_not_implemented_sync(clients):
async def test_batch_not_implemented_sync(clients: BothClients):
with pytest.raises(NotImplementedError):
clients.sync.create_batch()