Skip to content

Commit d36af08

Browse files
cpcloudkszucs
authored andcommitted
style: format to the black default line length
1 parent 39cea3b commit d36af08

File tree

245 files changed

+1219
-3559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+1219
-3559
lines changed

ci/make_geography_db.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ def make_geography_db(
7070
table = sa.Table(
7171
table_name,
7272
metadata,
73-
*(
74-
sa.Column(col_name, col_type)
75-
for col_name, col_type in schema
76-
),
73+
*(sa.Column(col_name, col_type) for col_name, col_type in schema),
7774
)
7875
table_columns = table.c.keys()
7976
post_parse = POST_PARSE_FUNCTIONS.get(table_name, toolz.identity)
@@ -82,16 +79,11 @@ def make_geography_db(
8279
table.create(bind=bind)
8380
bind.execute(
8481
table.insert().values(),
85-
[
86-
post_parse(dict(zip(table_columns, row)))
87-
for row in data[table_name]
88-
],
82+
[post_parse(dict(zip(table_columns, row))) for row in data[table_name]],
8983
)
9084

9185

92-
@click.command(
93-
help="Create the geography SQLite database for the Ibis tutorial"
94-
)
86+
@click.command(help="Create the geography SQLite database for the Ibis tutorial")
9587
@click.option(
9688
"-d",
9789
"--output-directory",

docs/example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
.aggregate(
1212
num_investments=c.permalink.nunique(),
1313
acq_ipos=(
14-
c.status.isin(("ipo", "acquired"))
15-
.ifelse(c.permalink, ibis.NA)
16-
.nunique()
14+
c.status.isin(("ipo", "acquired")).ifelse(c.permalink, ibis.NA).nunique()
1715
),
1816
)
1917
.mutate(acq_rate=lambda t: t.acq_ipos / t.num_investments)

docs/sqlalchemy_example.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@
1212
).label("investor_name"),
1313
sa.func.count(c.c.permalink.distinct()).label("num_investments"),
1414
sa.func.count(
15-
sa.case(
16-
[(c.status.in_(("ipo", "acquired")), c.c.permalink)]
17-
).distinct()
15+
sa.case([(c.status.in_(("ipo", "acquired")), c.c.permalink)]).distinct()
1816
).label("acq_ipos"),
1917
]
2018
)
2119
.select_from(
22-
c.join(
23-
i, onclause=c.c.permalink == i.c.company_permalink, isouter=True
24-
)
20+
c.join(i, onclause=c.c.permalink == i.c.company_permalink, isouter=True)
2521
)
2622
.group_by(1)
2723
.order_by(sa.desc(2))

gen_matrix.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ def get_backends():
1111
pyproject = tomli.loads(Path("pyproject.toml").read_text())
1212
backends = pyproject["tool"]["poetry"]["plugins"]["ibis.backends"]
1313
del backends["spark"]
14-
return [
15-
(backend, getattr(ibis, backend))
16-
for backend in sorted(backends.keys())
17-
]
14+
return [(backend, getattr(ibis, backend)) for backend in sorted(backends.keys())]
1815

1916

2017
def get_leaf_classes(op):

ibis/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def __getattr__(name: str) -> BaseBackend:
4343
the `ibis.backends` entrypoints. If successful, the `ibis.sqlite`
4444
attribute is "cached", so this function is only called the first time.
4545
"""
46-
entry_points = {
47-
ep for ep in util.backend_entry_points() if ep.name == name
48-
}
46+
entry_points = {ep for ep in util.backend_entry_points() if ep.name == name}
4947

5048
if not entry_points:
5149
msg = f"module 'ibis' has no attribute '{name}'. "

ibis/backends/base/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ def to_pyarrow(
266266
# so construct at one column table (if applicable)
267267
# then return the column _from_ the table
268268
table = pa.Table.from_batches(
269-
self.to_pyarrow_batches(
270-
expr, params=params, limit=limit, **kwargs
271-
)
269+
self.to_pyarrow_batches(expr, params=params, limit=limit, **kwargs)
272270
)
273271
except ValueError:
274272
# The pyarrow batches iterator is empty so pass in an empty
@@ -430,9 +428,7 @@ def database(self, name: str | None = None) -> Database:
430428
Database
431429
A database object for the specified database.
432430
"""
433-
return self.database_class(
434-
name=name or self.current_database, client=self
435-
)
431+
return self.database_class(name=name or self.current_database, client=self)
436432

437433
@property
438434
@abc.abstractmethod
@@ -561,9 +557,7 @@ def register_options(cls) -> None:
561557
try:
562558
setattr(options, backend_name, backend_options)
563559
except ValueError as e:
564-
raise exc.BackendConfigurationNotRegistered(
565-
backend_name
566-
) from e
560+
raise exc.BackendConfigurationNotRegistered(backend_name) from e
567561

568562
def compile(
569563
self,
@@ -592,9 +586,7 @@ def add_operation(self, operation: ops.Node) -> Callable:
592586
... return 'NULL'
593587
"""
594588
if not hasattr(self, 'compiler'):
595-
raise RuntimeError(
596-
'Only SQL-based backends support `add_operation`'
597-
)
589+
raise RuntimeError('Only SQL-based backends support `add_operation`')
598590

599591
def decorator(translation_function: Callable) -> None:
600592
self.compiler.translator_class.add_operation(

ibis/backends/base/sql/__init__.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def sql(self, query: str) -> ir.Table:
110110
return ops.SQLQueryResult(query, schema, self).to_expr()
111111

112112
def _get_schema_using_query(self, query):
113-
raise NotImplementedError(
114-
f"Backend {self.name} does not support .sql()"
115-
)
113+
raise NotImplementedError(f"Backend {self.name} does not support .sql()")
116114

117115
def raw_sql(self, query: str) -> Any:
118116
"""Execute a query string.
@@ -149,9 +147,7 @@ def _cursor_batches(
149147
limit: int | str | None = None,
150148
chunk_size: int = 1_000_000,
151149
) -> Iterable[list]:
152-
query_ast = self.compiler.to_ast_ensure_limit(
153-
expr, limit, params=params
154-
)
150+
query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params)
155151
sql = query_ast.compile()
156152

157153
with self._safe_raw_sql(sql) as cursor:
@@ -207,9 +203,7 @@ def _batches():
207203
)
208204
yield pa.RecordBatch.from_struct_array(struct_array)
209205

210-
return pa.RecordBatchReader.from_batches(
211-
schema.to_pyarrow(), _batches()
212-
)
206+
return pa.RecordBatchReader.from_batches(schema.to_pyarrow(), _batches())
213207

214208
def execute(
215209
self,
@@ -249,9 +243,7 @@ def execute(
249243
# feature than all this magic.
250244
# we don't want to pass `timecontext` to `raw_sql`
251245
kwargs.pop('timecontext', None)
252-
query_ast = self.compiler.to_ast_ensure_limit(
253-
expr, limit, params=params
254-
)
246+
query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params)
255247
sql = query_ast.compile()
256248
self._log(sql)
257249

@@ -349,9 +341,7 @@ def compile(
349341
The output of compilation. The type of this value depends on the
350342
backend.
351343
"""
352-
return self.compiler.to_ast_ensure_limit(
353-
expr, limit, params=params
354-
).compile()
344+
return self.compiler.to_ast_ensure_limit(expr, limit, params=params).compile()
355345

356346
def explain(
357347
self,
@@ -397,6 +387,5 @@ def has_operation(cls, operation: type[ops.Value]) -> bool:
397387

398388
def _create_temp_view(self, view, definition):
399389
raise NotImplementedError(
400-
f"The {self.name} backend does not implement temporary view "
401-
"creation"
390+
f"The {self.name} backend does not implement temporary view " "creation"
402391
)

ibis/backends/base/sql/alchemy/__init__.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import ibis.expr.types as ir
1616
import ibis.util as util
1717
from ibis.backends.base.sql import BaseSQLBackend
18-
from ibis.backends.base.sql.alchemy.database import (
19-
AlchemyDatabase,
20-
AlchemyTable,
21-
)
18+
from ibis.backends.base.sql.alchemy.database import AlchemyDatabase, AlchemyTable
2219
from ibis.backends.base.sql.alchemy.datatypes import (
2320
schema_from_table,
2421
table_from_schema,
@@ -71,9 +68,7 @@ class BaseAlchemyBackend(BaseSQLBackend):
7168
table_class = AlchemyTable
7269
compiler = AlchemyCompiler
7370

74-
def _build_alchemy_url(
75-
self, url, host, port, user, password, database, driver
76-
):
71+
def _build_alchemy_url(self, url, host, port, user, password, database, driver):
7772
if url is not None:
7873
return sa.engine.url.make_url(url)
7974

@@ -189,8 +184,7 @@ def create_table(
189184

190185
if database is not None:
191186
raise NotImplementedError(
192-
'Creating tables from a different database is not yet '
193-
'implemented'
187+
'Creating tables from a different database is not yet ' 'implemented'
194188
)
195189

196190
if expr is None and schema is None:
@@ -236,9 +230,7 @@ def _get_insert_method(self, expr):
236230

237231
return methodcaller("from_select", list(expr.columns), compiled)
238232

239-
def _columns_from_schema(
240-
self, name: str, schema: sch.Schema
241-
) -> list[sa.Column]:
233+
def _columns_from_schema(self, name: str, schema: sch.Schema) -> list[sa.Column]:
242234
return [
243235
sa.Column(colname, to_sqla_type(dtype), nullable=dtype.nullable)
244236
for colname, dtype in zip(schema.names, schema.types)
@@ -273,8 +265,7 @@ def drop_table(
273265

274266
if database is not None:
275267
raise NotImplementedError(
276-
'Dropping tables from a different database is not yet '
277-
'implemented'
268+
'Dropping tables from a different database is not yet ' 'implemented'
278269
)
279270

280271
t = self._get_sqla_table(table_name, schema=database, autoload=False)
@@ -515,8 +506,7 @@ def _get_temp_view_definition(
515506
definition: sa.sql.compiler.Compiled,
516507
) -> str:
517508
raise NotImplementedError(
518-
f"The {self.name} backend does not implement temporary view "
519-
"creation"
509+
f"The {self.name} backend does not implement temporary view " "creation"
520510
)
521511

522512
def _register_temp_view_cleanup(self, name: str, raw_name: str) -> None:

ibis/backends/base/sql/alchemy/database.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def __init__(self, source, sqla_table, name, schema):
2323
name = sqla_table.name
2424
if schema is None:
2525
schema = sch.infer(sqla_table, schema=schema)
26-
super().__init__(
27-
name=name, schema=schema, sqla_table=sqla_table, source=source
28-
)
26+
super().__init__(name=name, schema=schema, sqla_table=sqla_table, source=source)
2927

3028
# TODO(kszucs): remove this
3129
def __equals__(self, other: AlchemyTable) -> bool:

ibis/backends/base/sql/alchemy/datatypes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def __init__(
2525
self,
2626
pairs: Iterable[tuple[str, sa.types.TypeEngine]],
2727
):
28-
self.pairs = [
29-
(name, sa.types.to_instance(type)) for name, type in pairs
30-
]
28+
self.pairs = [(name, sa.types.to_instance(type)) for name, type in pairs]
3129

3230
def get_col_spec(self, **_):
3331
pairs = ", ".join(f"{k} {v}" for k, v in self.pairs)
@@ -176,9 +174,7 @@ def sa_boolean(_, satype, nullable=True):
176174
@dt.dtype.register(MySQLDialect, sa.NUMERIC)
177175
def sa_mysql_numeric(_, satype, nullable=True):
178176
# https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html
179-
return dt.Decimal(
180-
satype.precision or 10, satype.scale or 0, nullable=nullable
181-
)
177+
return dt.Decimal(satype.precision or 10, satype.scale or 0, nullable=nullable)
182178

183179

184180
@dt.dtype.register(MySQLDialect, mysql.TINYBLOB)

0 commit comments

Comments
 (0)