Skip to content

Commit 5b7f6d7

Browse files
style: Apply pre-commit formatting fixes
- Collapse multi-line statements for readability (ruff-format) - Consistent quote style (' vs ") - Remove unused import (os from test_cascade_delete.py) - Add blank line after import for PEP 8 compliance All formatting changes from pre-commit hooks (ruff, ruff-format).
1 parent 57f376d commit 5b7f6d7

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

src/datajoint/declare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def compile_foreign_key(
291291
# Extract database and table name and rebuild with current adapter
292292
parent_full_name = ref.support[0]
293293
# Try to parse as database.table (with or without quotes)
294-
parts = parent_full_name.replace('"', '').replace('`', '').split('.')
294+
parts = parent_full_name.replace('"', "").replace("`", "").split(".")
295295
if len(parts) == 2:
296296
ref_table_name = f"{adapter.quote_identifier(parts[0])}.{adapter.quote_identifier(parts[1])}"
297297
else:

src/datajoint/heading.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ def _init_from_database(self) -> None:
369369
as_dict=True,
370370
).fetchone()
371371
if info is None:
372-
raise DataJointError(
373-
f"The table {database}.{table_name} is not defined."
374-
)
372+
raise DataJointError(f"The table {database}.{table_name} is not defined.")
375373
# Normalize table_comment to comment for backward compatibility
376374
self._table_status = {k.lower(): v for k, v in info.items()}
377375
if "table_comment" in self._table_status:
@@ -592,9 +590,7 @@ def select(self, select_list, rename_map=None, compute_map=None):
592590
dict(
593591
self.attributes[old_name].todict(),
594592
name=new_name,
595-
attribute_expression=(
596-
adapter.quote_identifier(old_name) if adapter else f"`{old_name}`"
597-
),
593+
attribute_expression=(adapter.quote_identifier(old_name) if adapter else f"`{old_name}`"),
598594
)
599595
for new_name, old_name in rename_map.items()
600596
if old_name == name

src/datajoint/table.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ def is_declared(self):
372372
"""
373373
:return: True is the table is declared in the schema.
374374
"""
375-
query = self.connection.adapter.get_table_info_sql(
376-
self.database, self.table_name
377-
)
375+
query = self.connection.adapter.get_table_info_sql(self.database, self.table_name)
378376
return self.connection.query(query).rowcount > 0
379377

380378
@property
@@ -896,7 +894,7 @@ def cascade(table):
896894
) from None
897895

898896
# Strip quotes from parsed values for backend-agnostic processing
899-
quote_chars = ('`', '"')
897+
quote_chars = ("`", '"')
900898

901899
def strip_quotes(s):
902900
if s and any(s.startswith(q) for q in quote_chars):
@@ -928,9 +926,7 @@ def strip_quotes(s):
928926
args=(strip_quotes(match["name"]), child_schema, child_table_name),
929927
).fetchall()
930928
if results:
931-
match["fk_attrs"], match["parent"], match["pk_attrs"] = list(
932-
map(list, zip(*results))
933-
)
929+
match["fk_attrs"], match["parent"], match["pk_attrs"] = list(map(list, zip(*results)))
934930
match["parent"] = match["parent"][0] # All rows have same parent
935931

936932
# Build properly quoted full table name for FreeTable

tests/integration/test_cascade_delete.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Integration tests for cascade delete on multiple backends.
33
"""
44

5-
import os
6-
75
import pytest
86

97
import datajoint as dj
@@ -15,6 +13,7 @@ def schema_by_backend(connection_by_backend, db_creds_by_backend, request):
1513
backend = db_creds_by_backend["backend"]
1614
# Use unique schema name for each test
1715
import time
16+
1817
test_id = str(int(time.time() * 1000))[-8:] # Last 8 digits of timestamp
1918
schema_name = f"djtest_cascade_{backend}_{test_id}"[:64] # Limit length
2019

0 commit comments

Comments
 (0)