Skip to content

Commit 37a9719

Browse files
committed
style: format to the black default line length
1 parent 5054275 commit 37a9719

File tree

257 files changed

+1483
-4398
lines changed

Some content is hidden

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

257 files changed

+1483
-4398
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",

dev/poetry2setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def main(args: argparse.Namespace) -> None:
3535

3636

3737
if __name__ == "__main__":
38-
p = argparse.ArgumentParser(
39-
description="Generate a setup.py file from pyproject.toml"
40-
)
38+
p = argparse.ArgumentParser(description="Generate a setup.py file from pyproject.toml")
4139
p.add_argument(
4240
"-i",
4341
"--input-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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
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
)
21-
.select_from(
22-
c.join(
23-
i, onclause=c.c.permalink == i.c.company_permalink, isouter=True
24-
)
25-
)
19+
.select_from(c.join(i, onclause=c.c.permalink == i.c.company_permalink, isouter=True))
2620
.group_by(1)
2721
.order_by(sa.desc(2))
2822
)

gen_matrix.py

Lines changed: 2 additions & 7 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):
@@ -45,9 +42,7 @@ def get_leaf_classes(op):
4542

4643

4744
def main():
48-
possible_ops = (
49-
frozenset(get_leaf_classes(ops.Value)) | INCLUDED_OPS
50-
) - EXCLUDED_OPS
45+
possible_ops = (frozenset(get_leaf_classes(ops.Value)) | INCLUDED_OPS) - EXCLUDED_OPS
5146

5247
support = {"operation": [f"`{op.__name__}`" for op in possible_ops]}
5348
support.update(

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: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,7 @@ def database(self, name: str | None = None) -> Database:
310310
Database
311311
A database object for the specified database.
312312
"""
313-
return self.database_class(
314-
name=name or self.current_database, client=self
315-
)
313+
return self.database_class(name=name or self.current_database, client=self)
316314

317315
@property
318316
@abc.abstractmethod
@@ -441,9 +439,7 @@ def register_options(cls) -> None:
441439
try:
442440
setattr(options, backend_name, backend_options)
443441
except ValueError as e:
444-
raise exc.BackendConfigurationNotRegistered(
445-
backend_name
446-
) from e
442+
raise exc.BackendConfigurationNotRegistered(backend_name) from e
447443

448444
def compile(
449445
self,
@@ -472,14 +468,10 @@ def add_operation(self, operation: ops.Node) -> Callable:
472468
... return 'NULL'
473469
"""
474470
if not hasattr(self, 'compiler'):
475-
raise RuntimeError(
476-
'Only SQL-based backends support `add_operation`'
477-
)
471+
raise RuntimeError('Only SQL-based backends support `add_operation`')
478472

479473
def decorator(translation_function: Callable) -> None:
480-
self.compiler.translator_class.add_operation(
481-
operation, translation_function
482-
)
474+
self.compiler.translator_class.add_operation(operation, translation_function)
483475

484476
return decorator
485477

@@ -546,9 +538,7 @@ def drop_table(
546538
force
547539
If `False`, an exception is raised if the table does not exist.
548540
"""
549-
raise NotImplementedError(
550-
f'Backend "{self.name}" does not implement "drop_table"'
551-
)
541+
raise NotImplementedError(f'Backend "{self.name}" does not implement "drop_table"')
552542

553543
def create_view(
554544
self,
@@ -569,9 +559,7 @@ def create_view(
569559
Name of the database where the view will be created, if not the
570560
default.
571561
"""
572-
raise NotImplementedError(
573-
f'Backend "{self.name}" does not implement "create_view"'
574-
)
562+
raise NotImplementedError(f'Backend "{self.name}" does not implement "create_view"')
575563

576564
def drop_view(
577565
self, name: str, database: str | None = None, force: bool = False
@@ -587,9 +575,7 @@ def drop_view(
587575
force
588576
If `False`, an exception is raised if the view does not exist.
589577
"""
590-
raise NotImplementedError(
591-
f'Backend "{self.name}" does not implement "drop_view"'
592-
)
578+
raise NotImplementedError(f'Backend "{self.name}" does not implement "drop_view"')
593579

594580
@classmethod
595581
def has_operation(cls, operation: type[ops.Value]) -> bool:

ibis/backends/base/sql/__init__.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ def sql(self, query: str) -> ir.Table:
103103
return ops.SQLQueryResult(query, schema, self).to_expr()
104104

105105
def _get_schema_using_query(self, query):
106-
raise NotImplementedError(
107-
f"Backend {self.name} does not support .sql()"
108-
)
106+
raise NotImplementedError(f"Backend {self.name} does not support .sql()")
109107

110108
def raw_sql(self, query: str) -> Any:
111109
"""Execute a query string.
@@ -175,9 +173,7 @@ def execute(
175173
# feature than all this magic.
176174
# we don't want to pass `timecontext` to `raw_sql`
177175
kwargs.pop('timecontext', None)
178-
query_ast = self.compiler.to_ast_ensure_limit(
179-
expr, limit, params=params
180-
)
176+
query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params)
181177
sql = query_ast.compile()
182178
self._log(sql)
183179

@@ -236,8 +232,7 @@ def ast_schema(self, query_ast, **kwargs) -> sch.Schema:
236232
return sch.schema({op.name: op.output_dtype})
237233
else:
238234
raise ValueError(
239-
'Expression with type {} does not have a '
240-
'schema'.format(type(self.expr))
235+
'Expression with type {} does not have a ' 'schema'.format(type(self.expr))
241236
)
242237

243238
def _log(self, sql: str) -> None:
@@ -275,9 +270,7 @@ def compile(
275270
The output of compilation. The type of this value depends on the
276271
backend.
277272
"""
278-
return self.compiler.to_ast_ensure_limit(
279-
expr, limit, params=params
280-
).compile()
273+
return self.compiler.to_ast_ensure_limit(expr, limit, params=params).compile()
281274

282275
def explain(
283276
self,
@@ -323,6 +316,5 @@ def has_operation(cls, operation: type[ops.Value]) -> bool:
323316

324317
def _create_temp_view(self, view, definition):
325318
raise NotImplementedError(
326-
f"The {self.name} backend does not implement temporary view "
327-
"creation"
319+
f"The {self.name} backend does not implement temporary view " "creation"
328320
)

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

Lines changed: 7 additions & 20 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,
@@ -36,10 +33,7 @@
3633
varargs,
3734
variance_reduction,
3835
)
39-
from ibis.backends.base.sql.alchemy.translator import (
40-
AlchemyContext,
41-
AlchemyExprTranslator,
42-
)
36+
from ibis.backends.base.sql.alchemy.translator import AlchemyContext, AlchemyExprTranslator
4337

4438
__all__ = (
4539
'BaseAlchemyBackend',
@@ -71,9 +65,7 @@ class BaseAlchemyBackend(BaseSQLBackend):
7165
table_class = AlchemyTable
7266
compiler = AlchemyCompiler
7367

74-
def _build_alchemy_url(
75-
self, url, host, port, user, password, database, driver
76-
):
68+
def _build_alchemy_url(self, url, host, port, user, password, database, driver):
7769
if url is not None:
7870
return sa.engine.url.make_url(url)
7971

@@ -189,8 +181,7 @@ def create_table(
189181

190182
if database is not None:
191183
raise NotImplementedError(
192-
'Creating tables from a different database is not yet '
193-
'implemented'
184+
'Creating tables from a different database is not yet ' 'implemented'
194185
)
195186

196187
if expr is None and schema is None:
@@ -236,9 +227,7 @@ def _get_insert_method(self, expr):
236227

237228
return methodcaller("from_select", list(expr.columns), compiled)
238229

239-
def _columns_from_schema(
240-
self, name: str, schema: sch.Schema
241-
) -> list[sa.Column]:
230+
def _columns_from_schema(self, name: str, schema: sch.Schema) -> list[sa.Column]:
242231
return [
243232
sa.Column(colname, to_sqla_type(dtype), nullable=dtype.nullable)
244233
for colname, dtype in zip(schema.names, schema.types)
@@ -273,8 +262,7 @@ def drop_table(
273262

274263
if database is not None:
275264
raise NotImplementedError(
276-
'Dropping tables from a different database is not yet '
277-
'implemented'
265+
'Dropping tables from a different database is not yet ' 'implemented'
278266
)
279267

280268
t = self._get_sqla_table(table_name, schema=database, autoload=False)
@@ -515,8 +503,7 @@ def _get_temp_view_definition(
515503
definition: sa.sql.compiler.Compiled,
516504
) -> str:
517505
raise NotImplementedError(
518-
f"The {self.name} backend does not implement temporary view "
519-
"creation"
506+
f"The {self.name} backend does not implement temporary view " "creation"
520507
)
521508

522509
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:

0 commit comments

Comments
 (0)