Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-formatting all files using pre-commit hook #1963

Merged
merged 1 commit into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[settings]
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
ensure_newline_before_comments=true
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ repos:
rev: v1.9.2
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.17
- repo: https://github.com/timothycrosley/isort
rev: 18ad293fc9d1852776afe35015a932b68d26fb14
hooks:
- id: isort
- repo: https://github.com/psf/black
Expand Down
2 changes: 1 addition & 1 deletion ci/datamgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def parquet(tables, data_directory, ignore_missing_dependency, **params):
@click.option(
'--plpython/--no-plpython',
help='Create PL/Python extension in database',
default=True
default=True,
)
def postgres(schema, tables, data_directory, psql_path, plpython, **params):
psql = local[psql_path]
Expand Down
1 change: 1 addition & 0 deletions ibis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ibis.config_init # noqa: F401
import ibis.expr.api as api # noqa: F401
import ibis.expr.types as ir # noqa: F401

# pandas backend is mandatory
import ibis.pandas.api as pandas # noqa: F401
import ibis.util as util # noqa: F401
Expand Down
12 changes: 4 additions & 8 deletions ibis/bigquery/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _string_join(translator, expr):


def _string_ascii(translator, expr):
arg, = expr.op().args
(arg,) = expr.op().args
return 'TO_CODE_POINTS({})[SAFE_OFFSET(0)]'.format(
translator.translate(arg)
)
Expand Down Expand Up @@ -494,7 +494,7 @@ def identical_to(expr):

@rewrites(ops.Log2)
def log2(expr):
arg, = expr.op().args
(arg,) = expr.op().args
return arg.log(2)


Expand Down Expand Up @@ -558,9 +558,7 @@ def bigquery_any_all_no_op(expr):

@compiles(ops.Any)
def bigquery_compile_any(translator, expr):
return "LOGICAL_OR({})".format(
*map(translator.translate, expr.op().args)
)
return "LOGICAL_OR({})".format(*map(translator.translate, expr.op().args))


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

@compiles(ops.All)
def bigquery_compile_all(translator, expr):
return "LOGICAL_AND({})".format(
*map(translator.translate, expr.op().args)
)
return "LOGICAL_AND({})".format(*map(translator.translate, expr.op().args))


@compiles(ops.NotAll)
Expand Down
4 changes: 2 additions & 2 deletions ibis/bigquery/udf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def visit_YieldFrom(self, node):
@semicolon
def visit_Assign(self, node):
try:
target, = node.targets
(target,) = node.targets
except ValueError:
raise NotImplementedError(
'Only single assignment supported for now'
Expand Down Expand Up @@ -495,7 +495,7 @@ def visit_ListComp(self, node):
[[1, 4], [2, 5], [3, 6]]].map(([x, y]) => x + y)
"""
try:
generator, = node.generators
(generator,) = node.generators
except ValueError:
raise NotImplementedError(
'Only single loop comprehensions are allowed'
Expand Down
2 changes: 1 addition & 1 deletion ibis/bigquery/udf/tests/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse_expr(expr):


def parse_stmt(stmt):
body, = ast.parse(stmt).body
(body,) = ast.parse(stmt).body
return body


Expand Down
2 changes: 1 addition & 1 deletion ibis/clickhouse/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _index_of(translator, expr):
def _sign(translator, expr):
"""Workaround for missing sign function"""
op = expr.op()
arg, = op.args
(arg,) = op.args
arg_ = translator.translate(arg)
return 'intDivOrZero({0}, abs({0}))'.format(arg_)

Expand Down
4 changes: 2 additions & 2 deletions ibis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ def validate_backends(backends):


def execute(expr, limit='default', params=None, **kwargs):
backend, = validate_backends(list(find_backends(expr)))
(backend,) = validate_backends(list(find_backends(expr)))
return backend.execute(expr, limit=limit, params=params, **kwargs)


def compile(expr, limit=None, params=None, **kwargs):
backend, = validate_backends(list(find_backends(expr)))
(backend,) = validate_backends(list(find_backends(expr)))
return backend.compile(expr, limit=limit, params=params, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def reduction_to_aggregation(expr, default_name='tmp'):
named_expr = expr.name(default_name)

if len(tables) == 1:
table, = tables
(table,) = tables
return table.aggregate([named_expr]), name
else:
return ScalarAggregate(expr, None, default_name).get_result()
Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4089,6 +4089,6 @@ def prevent_rewrite(expr, client=None):
sql_query_result : ir.TableExpr
"""
if client is None:
client, = ibis.client.find_backends(expr)
(client,) = ibis.client.find_backends(expr)
query = client.compile(expr)
return ops.SQLQueryResult(query, expr.schema(), client).to_expr()
24 changes: 15 additions & 9 deletions ibis/expr/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
try:
if sys.version_info >= (3, 6):
import shapely.geometry

IS_SHAPELY_AVAILABLE = True
except ImportError:
...
Expand Down Expand Up @@ -536,11 +537,10 @@ def _literal_value_hash_key(self, value):

def _tuplize(values):
"""Recursively convert `values` to a tuple of tuples."""

def tuplize_iter(values):
yield from (
tuple(tuplize_iter(value))
if util.is_iterable(value)
else value
tuple(tuplize_iter(value)) if util.is_iterable(value) else value
for value in values
)

Expand Down Expand Up @@ -665,7 +665,7 @@ def _literal_value_hash_key(self, value):
shapely.geometry.Polygon,
shapely.geometry.MultiLineString,
shapely.geometry.MultiPoint,
shapely.geometry.MultiPolygon
shapely.geometry.MultiPolygon,
)
if isinstance(value, geo_shapes):
return self, value.wkt
Expand Down Expand Up @@ -1572,13 +1572,14 @@ def infer_null(value: Optional[Null]) -> Null:


if IS_SHAPELY_AVAILABLE:

@infer.register(shapely.geometry.Point)
def infer_shapely_point(value: shapely.geometry.Point) -> Point:
return point

@infer.register(shapely.geometry.LineString)
def infer_shapely_linestring(
value: shapely.geometry.LineString
value: shapely.geometry.LineString,
) -> LineString:
return linestring

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

@infer.register(shapely.geometry.MultiLineString)
def infer_shapely_multilinestring(
value: shapely.geometry.MultiLineString
value: shapely.geometry.MultiLineString,
) -> MultiLineString:
return multilinestring

@infer.register(shapely.geometry.MultiPoint)
def infer_shapely_multipoint(
value: shapely.geometry.MultiPoint
value: shapely.geometry.MultiPoint,
) -> MultiPoint:
return multipoint

@infer.register(shapely.geometry.MultiPolygon)
def infer_shapely_multipolygon(
value: shapely.geometry.MultiPolygon
value: shapely.geometry.MultiPolygon,
) -> MultiPolygon:
return multipolygon

Expand Down Expand Up @@ -1721,7 +1722,12 @@ def can_cast_variadic(
# geo spatial data type
# cast between same type, used to cast from/to geometry and geography
GEO_TYPES = (
Point, LineString, Polygon, MultiLineString, MultiPoint, MultiPolygon
Point,
LineString,
Polygon,
MultiLineString,
MultiPoint,
MultiPolygon,
)


Expand Down
9 changes: 7 additions & 2 deletions ibis/expr/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,10 @@ def __init__(self, expr, window):
window = window.bind(table)

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

class GeoSetSRID(GeoSpatialUnOp):
"""Set the spatial reference identifier for the ST_Geometry."""

srid = Arg(rlz.integer)
output_type = rlz.shape_like('args', dt.geometry)

Expand All @@ -3221,6 +3224,7 @@ class GeoDFullyWithin(GeoSpatialBinOp):
"""Returns True if the geometries are fully within the specified distance
of one another.
"""

distance = Arg(rlz.floating)

output_type = rlz.shape_like('args', dt.boolean)
Expand All @@ -3230,6 +3234,7 @@ class GeoDWithin(GeoSpatialBinOp):
"""Returns True if the geometries are within the specified distance
of one another.
"""

distance = Arg(rlz.floating)

output_type = rlz.shape_like('args', dt.boolean)
Expand Down
3 changes: 2 additions & 1 deletion ibis/expr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, names, types):
for v in self._name_locs.keys():
duplicate_names.remove(v)
raise com.IntegrityError(
'Duplicate column name(s): {}'.format(duplicate_names))
'Duplicate column name(s): {}'.format(duplicate_names)
)

def __repr__(self):
space = 2 + max(map(len, self.names), default=0)
Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def validate(self, *args, **kwargs):
inspect.Parameter(
name,
inspect.Parameter.POSITIONAL_OR_KEYWORD,
default=_undefined
default=_undefined,
)
for (name, argument) in self.items()
]
Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ def test_cannot_use_existence_expression_in_join(table):


def test_not_exists_predicate(t1, t2):
cond = -(t1.key1 == t2.key1).any()
cond = -((t1.key1 == t2.key1).any())
assert isinstance(cond.op(), ops.NotAny)


Expand Down
4 changes: 2 additions & 2 deletions ibis/expr/tests/test_value_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def test_negate(table, col):


def test_negate_boolean_scalar():
result = -ibis.literal(False)
result = -(ibis.literal(False))
assert isinstance(result, ir.BooleanScalar)
assert isinstance(result.op(), ops.Negate)

Expand Down Expand Up @@ -793,7 +793,7 @@ def test_binop_string_type_error(table, operation):
(operator.mul, 'a', 0, 'int8'),
(operator.mul, 'a', 5, 'int16'),
(operator.mul, 'a', 2 ** 24, 'int32'),
(operator.mul, 'a', -2 ** 24 + 1, 'int32'),
(operator.mul, 'a', -(2 ** 24) + 1, 'int32'),
(operator.mul, 'a', 1.5, 'double'),
(operator.mul, 'b', 0, 'int16'),
(operator.mul, 'b', 5, 'int32'),
Expand Down
Loading