Skip to content

Commit

Permalink
Fix formatting (new ruff version)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed Feb 29, 2024
1 parent a22c195 commit 5e26306
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 54 deletions.
6 changes: 2 additions & 4 deletions sqlglot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ def parse(


@t.overload
def parse_one(sql: str, *, into: t.Type[E], **opts) -> E:
...
def parse_one(sql: str, *, into: t.Type[E], **opts) -> E: ...


@t.overload
def parse_one(sql: str, **opts) -> Expression:
...
def parse_one(sql: str, **opts) -> Expression: ...


def parse_one(
Expand Down
6 changes: 2 additions & 4 deletions sqlglot/dataframe/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ def _create_cte_from_expression(
return cte, name

@t.overload
def _ensure_list_of_columns(self, cols: t.Collection[ColumnOrLiteral]) -> t.List[Column]:
...
def _ensure_list_of_columns(self, cols: t.Collection[ColumnOrLiteral]) -> t.List[Column]: ...

@t.overload
def _ensure_list_of_columns(self, cols: ColumnOrLiteral) -> t.List[Column]:
...
def _ensure_list_of_columns(self, cols: ColumnOrLiteral) -> t.List[Column]: ...

def _ensure_list_of_columns(self, cols):
return Column.ensure_cols(ensure_list(cols))
Expand Down
6 changes: 2 additions & 4 deletions sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,10 @@ def _parse_table_parts(
return table

@t.overload
def _parse_json_object(self, agg: Lit[False]) -> exp.JSONObject:
...
def _parse_json_object(self, agg: Lit[False]) -> exp.JSONObject: ...

@t.overload
def _parse_json_object(self, agg: Lit[True]) -> exp.JSONObjectAgg:
...
def _parse_json_object(self, agg: Lit[True]) -> exp.JSONObjectAgg: ...

def _parse_json_object(self, agg=False):
json_object = super()._parse_json_object()
Expand Down
30 changes: 10 additions & 20 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,10 @@ def transform(self, fun, *args, copy=True, **kwargs):
return new_node

@t.overload
def replace(self, expression: E) -> E:
...
def replace(self, expression: E) -> E: ...

@t.overload
def replace(self, expression: None) -> None:
...
def replace(self, expression: None) -> None: ...

def replace(self, expression):
"""
Expand Down Expand Up @@ -5623,8 +5621,7 @@ def maybe_parse(
prefix: t.Optional[str] = None,
copy: bool = False,
**opts,
) -> E:
...
) -> E: ...


@t.overload
Expand All @@ -5636,8 +5633,7 @@ def maybe_parse(
prefix: t.Optional[str] = None,
copy: bool = False,
**opts,
) -> E:
...
) -> E: ...


def maybe_parse(
Expand Down Expand Up @@ -5689,13 +5685,11 @@ def maybe_parse(


@t.overload
def maybe_copy(instance: None, copy: bool = True) -> None:
...
def maybe_copy(instance: None, copy: bool = True) -> None: ...


@t.overload
def maybe_copy(instance: E, copy: bool = True) -> E:
...
def maybe_copy(instance: E, copy: bool = True) -> E: ...


def maybe_copy(instance, copy=True):
Expand Down Expand Up @@ -6318,15 +6312,13 @@ def paren(expression: ExpOrStr, copy: bool = True) -> Paren:


@t.overload
def to_identifier(name: None, quoted: t.Optional[bool] = None, copy: bool = True) -> None:
...
def to_identifier(name: None, quoted: t.Optional[bool] = None, copy: bool = True) -> None: ...


@t.overload
def to_identifier(
name: str | Identifier, quoted: t.Optional[bool] = None, copy: bool = True
) -> Identifier:
...
) -> Identifier: ...


def to_identifier(name, quoted=None, copy=True):
Expand Down Expand Up @@ -6398,13 +6390,11 @@ def to_interval(interval: str | Literal) -> Interval:


@t.overload
def to_table(sql_path: str | Table, **kwargs) -> Table:
...
def to_table(sql_path: str | Table, **kwargs) -> Table: ...


@t.overload
def to_table(sql_path: None, **kwargs) -> None:
...
def to_table(sql_path: None, **kwargs) -> None: ...


def to_table(
Expand Down
12 changes: 4 additions & 8 deletions sqlglot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ def seq_get(seq: t.Sequence[T], index: int) -> t.Optional[T]:


@t.overload
def ensure_list(value: t.Collection[T]) -> t.List[T]:
...
def ensure_list(value: t.Collection[T]) -> t.List[T]: ...


@t.overload
def ensure_list(value: T) -> t.List[T]:
...
def ensure_list(value: T) -> t.List[T]: ...


def ensure_list(value):
Expand All @@ -81,13 +79,11 @@ def ensure_list(value):


@t.overload
def ensure_collection(value: t.Collection[T]) -> t.Collection[T]:
...
def ensure_collection(value: t.Collection[T]) -> t.Collection[T]: ...


@t.overload
def ensure_collection(value: T) -> t.Collection[T]:
...
def ensure_collection(value: T) -> t.Collection[T]: ...


def ensure_collection(value):
Expand Down
6 changes: 2 additions & 4 deletions sqlglot/optimizer/normalize_identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@


@t.overload
def normalize_identifiers(expression: E, dialect: DialectType = None) -> E:
...
def normalize_identifiers(expression: E, dialect: DialectType = None) -> E: ...


@t.overload
def normalize_identifiers(expression: str, dialect: DialectType = None) -> exp.Identifier:
...
def normalize_identifiers(expression: str, dialect: DialectType = None) -> exp.Identifier: ...


def normalize_identifiers(expression, dialect=None):
Expand Down
12 changes: 4 additions & 8 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4849,12 +4849,10 @@ def _parse_on_handling(self, on: str, *values: str) -> t.Optional[str]:
return None

@t.overload
def _parse_json_object(self, agg: Lit[False]) -> exp.JSONObject:
...
def _parse_json_object(self, agg: Lit[False]) -> exp.JSONObject: ...

@t.overload
def _parse_json_object(self, agg: Lit[True]) -> exp.JSONObjectAgg:
...
def _parse_json_object(self, agg: Lit[True]) -> exp.JSONObjectAgg: ...

def _parse_json_object(self, agg=False):
star = self._parse_star()
Expand Down Expand Up @@ -5912,14 +5910,12 @@ def _match_text_seq(self, *texts, advance=True):
return True

@t.overload
def _replace_columns_with_dots(self, this: exp.Expression) -> exp.Expression:
...
def _replace_columns_with_dots(self, this: exp.Expression) -> exp.Expression: ...

@t.overload
def _replace_columns_with_dots(
self, this: t.Optional[exp.Expression]
) -> t.Optional[exp.Expression]:
...
) -> t.Optional[exp.Expression]: ...

def _replace_columns_with_dots(self, this):
if isinstance(this, exp.Dot):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from tests.helpers import load_sql_fixtures


class CustomExpression(exp.Expression):
...
class CustomExpression(exp.Expression): ...


class TestSerDe(unittest.TestCase):
Expand Down

0 comments on commit 5e26306

Please sign in to comment.