Skip to content

Commit ae71b3a

Browse files
xmnlabtoryhaavik
authored andcommitted
Re-formatting all files using pre-commit hook
waiting for PyCQA/isort#1000 Author: Ivan Ogasawara <ivan.ogasawara@gmail.com> Closes #1963 from xmnlab/black-files-formatting and squashes the following commits: 9d1defb [Ivan Ogasawara] Re-formatting all files using pre-commit hook
1 parent 4c990ba commit ae71b3a

Some content is hidden

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

68 files changed

+410
-535
lines changed

.isort.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[settings]
22
known_third_party = asv,click,clickhouse_driver,dateutil,google,graphviz,impala,jinja2,kudu,multipledispatch,numpy,pandas,pkg_resources,plumbum,psycopg2,pyarrow,pydata_google_auth,pygit2,pymapd,pymysql,pyspark,pytest,pytz,regex,requests,ruamel,setuptools,sphinx_rtd_theme,sqlalchemy,toolz
3+
ensure_newline_before_comments=true

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ repos:
33
rev: v1.9.2
44
hooks:
55
- id: seed-isort-config
6-
- repo: https://github.com/pre-commit/mirrors-isort
7-
rev: v4.3.17
6+
- repo: https://github.com/timothycrosley/isort
7+
rev: 18ad293fc9d1852776afe35015a932b68d26fb14
88
hooks:
99
- id: isort
1010
- repo: https://github.com/psf/black

ci/datamgr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def parquet(tables, data_directory, ignore_missing_dependency, **params):
231231
@click.option(
232232
'--plpython/--no-plpython',
233233
help='Create PL/Python extension in database',
234-
default=True
234+
default=True,
235235
)
236236
def postgres(schema, tables, data_directory, psql_path, plpython, **params):
237237
psql = local[psql_path]

ibis/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ibis.config_init # noqa: F401
44
import ibis.expr.api as api # noqa: F401
55
import ibis.expr.types as ir # noqa: F401
6+
67
# pandas backend is mandatory
78
import ibis.pandas.api as pandas # noqa: F401
89
import ibis.util as util # noqa: F401

ibis/bigquery/compiler.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _string_join(translator, expr):
199199

200200

201201
def _string_ascii(translator, expr):
202-
arg, = expr.op().args
202+
(arg,) = expr.op().args
203203
return 'TO_CODE_POINTS({})[SAFE_OFFSET(0)]'.format(
204204
translator.translate(arg)
205205
)
@@ -494,7 +494,7 @@ def identical_to(expr):
494494

495495
@rewrites(ops.Log2)
496496
def log2(expr):
497-
arg, = expr.op().args
497+
(arg,) = expr.op().args
498498
return arg.log(2)
499499

500500

@@ -558,9 +558,7 @@ def bigquery_any_all_no_op(expr):
558558

559559
@compiles(ops.Any)
560560
def bigquery_compile_any(translator, expr):
561-
return "LOGICAL_OR({})".format(
562-
*map(translator.translate, expr.op().args)
563-
)
561+
return "LOGICAL_OR({})".format(*map(translator.translate, expr.op().args))
564562

565563

566564
@compiles(ops.NotAny)
@@ -572,9 +570,7 @@ def bigquery_compile_notany(translator, expr):
572570

573571
@compiles(ops.All)
574572
def bigquery_compile_all(translator, expr):
575-
return "LOGICAL_AND({})".format(
576-
*map(translator.translate, expr.op().args)
577-
)
573+
return "LOGICAL_AND({})".format(*map(translator.translate, expr.op().args))
578574

579575

580576
@compiles(ops.NotAll)

ibis/bigquery/udf/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def visit_YieldFrom(self, node):
162162
@semicolon
163163
def visit_Assign(self, node):
164164
try:
165-
target, = node.targets
165+
(target,) = node.targets
166166
except ValueError:
167167
raise NotImplementedError(
168168
'Only single assignment supported for now'
@@ -495,7 +495,7 @@ def visit_ListComp(self, node):
495495
[[1, 4], [2, 5], [3, 6]]].map(([x, y]) => x + y)
496496
"""
497497
try:
498-
generator, = node.generators
498+
(generator,) = node.generators
499499
except ValueError:
500500
raise NotImplementedError(
501501
'Only single loop comprehensions are allowed'

ibis/bigquery/udf/tests/test_find.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def parse_expr(expr):
1414

1515

1616
def parse_stmt(stmt):
17-
body, = ast.parse(stmt).body
17+
(body,) = ast.parse(stmt).body
1818
return body
1919

2020

ibis/clickhouse/operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _index_of(translator, expr):
214214
def _sign(translator, expr):
215215
"""Workaround for missing sign function"""
216216
op = expr.op()
217-
arg, = op.args
217+
(arg,) = op.args
218218
arg_ = translator.translate(arg)
219219
return 'intDivOrZero({0}, abs({0}))'.format(arg_)
220220

ibis/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ def validate_backends(backends):
281281

282282

283283
def execute(expr, limit='default', params=None, **kwargs):
284-
backend, = validate_backends(list(find_backends(expr)))
284+
(backend,) = validate_backends(list(find_backends(expr)))
285285
return backend.execute(expr, limit=limit, params=params, **kwargs)
286286

287287

288288
def compile(expr, limit=None, params=None, **kwargs):
289-
backend, = validate_backends(list(find_backends(expr)))
289+
(backend,) = validate_backends(list(find_backends(expr)))
290290
return backend.compile(expr, limit=limit, params=params, **kwargs)
291291

292292

ibis/expr/analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def reduction_to_aggregation(expr, default_name='tmp'):
169169
named_expr = expr.name(default_name)
170170

171171
if len(tables) == 1:
172-
table, = tables
172+
(table,) = tables
173173
return table.aggregate([named_expr]), name
174174
else:
175175
return ScalarAggregate(expr, None, default_name).get_result()

ibis/expr/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4089,6 +4089,6 @@ def prevent_rewrite(expr, client=None):
40894089
sql_query_result : ir.TableExpr
40904090
"""
40914091
if client is None:
4092-
client, = ibis.client.find_backends(expr)
4092+
(client,) = ibis.client.find_backends(expr)
40934093
query = client.compile(expr)
40944094
return ops.SQLQueryResult(query, expr.schema(), client).to_expr()

ibis/expr/datatypes.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
try:
3333
if sys.version_info >= (3, 6):
3434
import shapely.geometry
35+
3536
IS_SHAPELY_AVAILABLE = True
3637
except ImportError:
3738
...
@@ -536,11 +537,10 @@ def _literal_value_hash_key(self, value):
536537

537538
def _tuplize(values):
538539
"""Recursively convert `values` to a tuple of tuples."""
540+
539541
def tuplize_iter(values):
540542
yield from (
541-
tuple(tuplize_iter(value))
542-
if util.is_iterable(value)
543-
else value
543+
tuple(tuplize_iter(value)) if util.is_iterable(value) else value
544544
for value in values
545545
)
546546

@@ -665,7 +665,7 @@ def _literal_value_hash_key(self, value):
665665
shapely.geometry.Polygon,
666666
shapely.geometry.MultiLineString,
667667
shapely.geometry.MultiPoint,
668-
shapely.geometry.MultiPolygon
668+
shapely.geometry.MultiPolygon,
669669
)
670670
if isinstance(value, geo_shapes):
671671
return self, value.wkt
@@ -1572,13 +1572,14 @@ def infer_null(value: Optional[Null]) -> Null:
15721572

15731573

15741574
if IS_SHAPELY_AVAILABLE:
1575+
15751576
@infer.register(shapely.geometry.Point)
15761577
def infer_shapely_point(value: shapely.geometry.Point) -> Point:
15771578
return point
15781579

15791580
@infer.register(shapely.geometry.LineString)
15801581
def infer_shapely_linestring(
1581-
value: shapely.geometry.LineString
1582+
value: shapely.geometry.LineString,
15821583
) -> LineString:
15831584
return linestring
15841585

@@ -1588,19 +1589,19 @@ def infer_shapely_polygon(value: shapely.geometry.Polygon) -> Polygon:
15881589

15891590
@infer.register(shapely.geometry.MultiLineString)
15901591
def infer_shapely_multilinestring(
1591-
value: shapely.geometry.MultiLineString
1592+
value: shapely.geometry.MultiLineString,
15921593
) -> MultiLineString:
15931594
return multilinestring
15941595

15951596
@infer.register(shapely.geometry.MultiPoint)
15961597
def infer_shapely_multipoint(
1597-
value: shapely.geometry.MultiPoint
1598+
value: shapely.geometry.MultiPoint,
15981599
) -> MultiPoint:
15991600
return multipoint
16001601

16011602
@infer.register(shapely.geometry.MultiPolygon)
16021603
def infer_shapely_multipolygon(
1603-
value: shapely.geometry.MultiPolygon
1604+
value: shapely.geometry.MultiPolygon,
16041605
) -> MultiPolygon:
16051606
return multipolygon
16061607

@@ -1721,7 +1722,12 @@ def can_cast_variadic(
17211722
# geo spatial data type
17221723
# cast between same type, used to cast from/to geometry and geography
17231724
GEO_TYPES = (
1724-
Point, LineString, Polygon, MultiLineString, MultiPoint, MultiPolygon
1725+
Point,
1726+
LineString,
1727+
Polygon,
1728+
MultiLineString,
1729+
MultiPoint,
1730+
MultiPolygon,
17251731
)
17261732

17271733

ibis/expr/operations.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,10 @@ def __init__(self, expr, window):
10261026
window = window.bind(table)
10271027

10281028
if window.max_lookback is not None:
1029-
error_msg = ("'max lookback' windows must be ordered "
1030-
"by a timestamp column")
1029+
error_msg = (
1030+
"'max lookback' windows must be ordered "
1031+
"by a timestamp column"
1032+
)
10311033
if len(window._order_by) != 1:
10321034
raise com.IbisInputError(error_msg)
10331035
order_var = window._order_by[0].op().args[0]
@@ -3196,6 +3198,7 @@ class GeoSRID(GeoSpatialUnOp):
31963198

31973199
class GeoSetSRID(GeoSpatialUnOp):
31983200
"""Set the spatial reference identifier for the ST_Geometry."""
3201+
31993202
srid = Arg(rlz.integer)
32003203
output_type = rlz.shape_like('args', dt.geometry)
32013204

@@ -3221,6 +3224,7 @@ class GeoDFullyWithin(GeoSpatialBinOp):
32213224
"""Returns True if the geometries are fully within the specified distance
32223225
of one another.
32233226
"""
3227+
32243228
distance = Arg(rlz.floating)
32253229

32263230
output_type = rlz.shape_like('args', dt.boolean)
@@ -3230,6 +3234,7 @@ class GeoDWithin(GeoSpatialBinOp):
32303234
"""Returns True if the geometries are within the specified distance
32313235
of one another.
32323236
"""
3237+
32333238
distance = Arg(rlz.floating)
32343239

32353240
output_type = rlz.shape_like('args', dt.boolean)

ibis/expr/schema.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __init__(self, names, types):
3737
for v in self._name_locs.keys():
3838
duplicate_names.remove(v)
3939
raise com.IntegrityError(
40-
'Duplicate column name(s): {}'.format(duplicate_names))
40+
'Duplicate column name(s): {}'.format(duplicate_names)
41+
)
4142

4243
def __repr__(self):
4344
space = 2 + max(map(len, self.names), default=0)

ibis/expr/signature.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def validate(self, *args, **kwargs):
106106
inspect.Parameter(
107107
name,
108108
inspect.Parameter.POSITIONAL_OR_KEYWORD,
109-
default=_undefined
109+
default=_undefined,
110110
)
111111
for (name, argument) in self.items()
112112
]

ibis/expr/tests/test_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ def test_cannot_use_existence_expression_in_join(table):
10641064

10651065

10661066
def test_not_exists_predicate(t1, t2):
1067-
cond = -(t1.key1 == t2.key1).any()
1067+
cond = -((t1.key1 == t2.key1).any())
10681068
assert isinstance(cond.op(), ops.NotAny)
10691069

10701070

ibis/expr/tests/test_value_exprs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def test_negate(table, col):
580580

581581

582582
def test_negate_boolean_scalar():
583-
result = -ibis.literal(False)
583+
result = -(ibis.literal(False))
584584
assert isinstance(result, ir.BooleanScalar)
585585
assert isinstance(result.op(), ops.Negate)
586586

@@ -793,7 +793,7 @@ def test_binop_string_type_error(table, operation):
793793
(operator.mul, 'a', 0, 'int8'),
794794
(operator.mul, 'a', 5, 'int16'),
795795
(operator.mul, 'a', 2 ** 24, 'int32'),
796-
(operator.mul, 'a', -2 ** 24 + 1, 'int32'),
796+
(operator.mul, 'a', -(2 ** 24) + 1, 'int32'),
797797
(operator.mul, 'a', 1.5, 'double'),
798798
(operator.mul, 'b', 0, 'int16'),
799799
(operator.mul, 'b', 5, 'int32'),

0 commit comments

Comments
 (0)