Skip to content

Commit

Permalink
Bump black to fix vulnerability (#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran authored Apr 8, 2024
1 parent 0c8a4a2 commit 5bb8086
Show file tree
Hide file tree
Showing 64 changed files with 235 additions and 270 deletions.
2 changes: 1 addition & 1 deletion code-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flake8==4.0.1
black==23.3.0
black==24.3.0
isort==5.10.1
pre-commit==2.20.0
3 changes: 1 addition & 2 deletions nucliadb/migrations/0002_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0003_allfields_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
from nucliadb.migrator.migrator import logger


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0004_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0005_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
6 changes: 2 additions & 4 deletions nucliadb/migrations/0006_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
...
async def migrate_kb(context: ExecutionContext, kbid: str) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0010_fix_corrupt_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
]


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0011_materialize_labelset_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
logger = logging.getLogger(__name__)


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0012_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
]


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
6 changes: 2 additions & 4 deletions nucliadb/migrations/0013_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
from nucliadb.migrator.context import ExecutionContext


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
...
async def migrate_kb(context: ExecutionContext, kbid: str) -> None: ...
3 changes: 1 addition & 2 deletions nucliadb/migrations/0014_rollover_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
logger = logging.getLogger(__name__)


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0015_targeted_rollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
]


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
6 changes: 2 additions & 4 deletions nucliadb/migrations/0016_upgrade_to_paragraphs_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
logger = logging.getLogger(__name__)


class ShardsObjectNotFound(Exception):
...
class ShardsObjectNotFound(Exception): ...


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/migrations/0017_multiple_writable_shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
logger = logging.getLogger(__name__)


async def migrate(context: ExecutionContext) -> None:
...
async def migrate(context: ExecutionContext) -> None: ...


async def migrate_kb(context: ExecutionContext, kbid: str) -> None:
Expand Down
10 changes: 5 additions & 5 deletions nucliadb/nucliadb/common/cluster/discovery/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ async def update_node_data_cache(self) -> None:
continue
existing = self.node_id_cache[pod_name]
try:
self.node_id_cache[
pod_name
] = await self._query_node_metadata(
existing.address,
read_replica=existing.primary_id is not None,
self.node_id_cache[pod_name] = (
await self._query_node_metadata(
existing.address,
read_replica=existing.primary_id is not None,
)
)
except NodeConnectionError: # pragma: no cover
self._maybe_remove_stale_node(pod_name)
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/nucliadb/common/cluster/discovery/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ async def initialize(self) -> None:
]
)

async def finalize(self) -> None:
...
async def finalize(self) -> None: ...
6 changes: 3 additions & 3 deletions nucliadb/nucliadb/common/http_clients/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def __init__(self):
)
self.headers = {}
if nuclia_settings.nuclia_service_account is not None:
self.headers[
"X-NUCLIA-NUAKEY"
] = f"Bearer {nuclia_settings.nuclia_service_account}"
self.headers["X-NUCLIA-NUAKEY"] = (
f"Bearer {nuclia_settings.nuclia_service_account}"
)

async def __aenter__(self):
return self
Expand Down
6 changes: 3 additions & 3 deletions nucliadb/nucliadb/common/http_clients/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def __init__(self):
self.base_url = get_processing_api_url()
self.headers = {}
if nuclia_settings.nuclia_service_account is not None:
self.headers[
"X-STF-NUAKEY"
] = f"Bearer {nuclia_settings.nuclia_service_account}"
self.headers["X-STF-NUAKEY"] = (
f"Bearer {nuclia_settings.nuclia_service_account}"
)

async def __aenter__(self):
return self
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/nucliadb/common/locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
KB_SHARDS_LOCK = "shards-kb-{kbid}"


class ResourceLocked(Exception):
...
class ResourceLocked(Exception): ...


@dataclass
Expand Down
9 changes: 3 additions & 6 deletions nucliadb/nucliadb/common/maindb/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
class ConflictError(Exception):
...
class ConflictError(Exception): ...


class NotFoundError(Exception):
...
class NotFoundError(Exception): ...


class UnsetUtility(Exception):
...
class UnsetUtility(Exception): ...
3 changes: 1 addition & 2 deletions nucliadb/nucliadb/export_import/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class ExportMetadata(Metadata):
exported_resources: list[str] = list()


class ImportMetadata(Metadata):
...
class ImportMetadata(Metadata): ...


class NatsTaskMessage(BaseModel):
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/nucliadb/export_import/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ async def get_labels(context: ApplicationContext, kbid: str) -> kb_pb2.Labels:
return await datamanagers.labels.get_labels(txn, kbid=kbid)


class EndOfStream(Exception):
...
class EndOfStream(Exception): ...


class ExportStream:
Expand Down
6 changes: 3 additions & 3 deletions nucliadb/nucliadb/ingest/consumer/auditing.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ async def handle_message(self, raw_data: bytes) -> None:
@metrics.handler_histo.wrap({"type": "audit_counter"})
async def process_kb(self, kbid: str) -> None:
try:
shard_groups: list[
writer_pb2.ShardObject
] = await self.shard_manager.get_shards_by_kbid(kbid)
shard_groups: list[writer_pb2.ShardObject] = (
await self.shard_manager.get_shards_by_kbid(kbid)
)
except ShardsNotFound:
logger.warning(f"No shards found for kbid {kbid}, skipping")
return
Expand Down
8 changes: 5 additions & 3 deletions nucliadb/nucliadb/ingest/consumer/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ async def subscription_worker(self, msg: Msg):
try:
with consumer_observer(
{
"source": "writer"
if pb.source == pb.MessageSource.WRITER
else "processor"
"source": (
"writer"
if pb.source == pb.MessageSource.WRITER
else "processor"
)
}
):
await self._process(pb, seqid)
Expand Down
12 changes: 6 additions & 6 deletions nucliadb/nucliadb/ingest/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ async def set_field_metadata(
) -> tuple[FieldComputedMetadata, list[str], dict[str, list[str]]]:
if self.type in SUBFIELDFIELDS:
try:
actual_payload: Optional[
FieldComputedMetadata
] = await self.get_field_metadata(force=True)
actual_payload: Optional[FieldComputedMetadata] = (
await self.get_field_metadata(force=True)
)
except KeyError:
actual_payload = None
else:
Expand Down Expand Up @@ -471,9 +471,9 @@ async def get_field_metadata_cf(self) -> Optional[CloudFile]:
async def set_large_field_metadata(self, payload: LargeComputedMetadataWrapper):
if self.type in SUBFIELDFIELDS:
try:
actual_payload: Optional[
LargeComputedMetadata
] = await self.get_large_field_metadata(force=True)
actual_payload: Optional[LargeComputedMetadata] = (
await self.get_large_field_metadata(force=True)
)
except KeyError:
actual_payload = None
else:
Expand Down
12 changes: 6 additions & 6 deletions nucliadb/nucliadb/ingest/orm/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,9 @@ async def iterate_sentences(
for fieldmetadata in self.basic.fieldmetadata:
field_id = self.generate_field_id(fieldmetadata.field)
for annotationparagraph in fieldmetadata.paragraphs:
userdefinedparagraphclass[
annotationparagraph.key
] = annotationparagraph
userdefinedparagraphclass[annotationparagraph.key] = (
annotationparagraph
)

for (type_id, field_id), field in fields.items():
fieldid = FieldID(field_type=type_id, field=field_id) # type: ignore
Expand Down Expand Up @@ -1273,9 +1273,9 @@ async def iterate_paragraphs(
for fieldmetadata in self.basic.fieldmetadata:
field_id = self.generate_field_id(fieldmetadata.field)
for annotationparagraph in fieldmetadata.paragraphs:
userdefinedparagraphclass[
annotationparagraph.key
] = annotationparagraph
userdefinedparagraphclass[annotationparagraph.key] = (
annotationparagraph
)

for (type_id, field_id), field in fields.items():
fieldid = FieldID(field_type=type_id, field=field_id) # type: ignore
Expand Down
Loading

3 comments on commit 5bb8086

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5bb8086 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13279.404781317977 iter/sec (stddev: 1.946583953489085e-7) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5bb8086 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13441.09913747815 iter/sec (stddev: 1.0646853606824117e-7) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5bb8086 Previous: d4afd82 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13358.866052142961 iter/sec (stddev: 3.549894873079436e-7) 13028.533525895236 iter/sec (stddev: 4.192637045977425e-7) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.