Skip to content

Commit 33b4b73

Browse files
Replace Black by Ruff formatter (#127)
* Replace black by Ruff Formatter * update ruff version * fix format * Update ruff format and add preserve as a quote style
1 parent dba1ef8 commit 33b4b73

40 files changed

Lines changed: 257 additions & 314 deletions

.pre-commit-config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ repos:
2929
- id: check-ast
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
3131
# Ruff version (Used for linting)
32-
rev: v0.1.0
32+
rev: v0.1.8
3333
hooks:
3434
- id: ruff
35-
args: [ --fix, --exit-non-zero-on-fix ]
36-
- repo: https://github.com/ambv/black
37-
rev: 23.10.0
38-
hooks:
39-
- id: black
40-
args: [--skip-string-normalization]
35+
args: [ --fix, --exit-non-zero-on-fix, --preview ]
36+
- id: ruff-format
37+
args: [ --preview ]
4138
- repo: https://github.com/pre-commit/mirrors-mypy
4239
rev: v1.6.1
4340
hooks:

pyiceberg/avro/codecs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
so don't confuse it with the Python's "codecs", which is a package mainly for
2424
converting character sets (https://docs.python.org/3/library/codecs.html).
2525
"""
26+
2627
from __future__ import annotations
2728

2829
from typing import Dict, Optional, Type

pyiceberg/avro/codecs/codec.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class Codec(ABC):
2424

2525
@staticmethod
2626
@abstractmethod
27-
def compress(data: bytes) -> tuple[bytes, int]:
28-
...
27+
def compress(data: bytes) -> tuple[bytes, int]: ...
2928

3029
@staticmethod
3130
@abstractmethod
32-
def decompress(data: bytes) -> bytes:
33-
...
31+
def decompress(data: bytes) -> bytes: ...

pyiceberg/avro/file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717
# pylint: disable=W0621
1818
"""Avro reader for reading Avro files."""
19+
1920
from __future__ import annotations
2021

2122
import io

pyiceberg/avro/reader.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
The reader tree can be changed in such a way that the
2424
read schema is different, while respecting the read schema.
2525
"""
26+
2627
from __future__ import annotations
2728

2829
from abc import abstractmethod
@@ -85,12 +86,10 @@ def _skip_map_array(decoder: BinaryDecoder, skip_entry: Callable[[], None]) -> N
8586

8687
class Reader(Singleton):
8788
@abstractmethod
88-
def read(self, decoder: BinaryDecoder) -> Any:
89-
...
89+
def read(self, decoder: BinaryDecoder) -> Any: ...
9090

9191
@abstractmethod
92-
def skip(self, decoder: BinaryDecoder) -> None:
93-
...
92+
def skip(self, decoder: BinaryDecoder) -> None: ...
9493

9594
def __repr__(self) -> str:
9695
"""Return the string representation of the Reader class."""

pyiceberg/avro/resolver.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ def resolve_reader(
232232
Raises:
233233
NotImplementedError: If attempting to resolve an unrecognized object type.
234234
"""
235-
return visit_with_partner(
236-
file_schema, read_schema, ReadSchemaResolver(read_types, read_enums), SchemaPartnerAccessor()
237-
) # type: ignore
235+
return visit_with_partner(file_schema, read_schema, ReadSchemaResolver(read_types, read_enums), SchemaPartnerAccessor()) # type: ignore
238236

239237

240238
class EnumReader(Reader):

pyiceberg/avro/writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Constructing a writer tree from the schema makes it easy
2121
to decouple the writing implementation from the schema.
2222
"""
23+
2324
from __future__ import annotations
2425

2526
from abc import abstractmethod
@@ -43,8 +44,7 @@
4344
@dataclass(frozen=True)
4445
class Writer(Singleton):
4546
@abstractmethod
46-
def write(self, encoder: BinaryEncoder, val: Any) -> Any:
47-
...
47+
def write(self, encoder: BinaryEncoder, val: Any) -> Any: ...
4848

4949
def __repr__(self) -> str:
5050
"""Return string representation of this object."""

pyiceberg/cli/output.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,48 +40,37 @@ class Output(ABC):
4040
"""Output interface for exporting."""
4141

4242
@abstractmethod
43-
def exception(self, ex: Exception) -> None:
44-
...
43+
def exception(self, ex: Exception) -> None: ...
4544

4645
@abstractmethod
47-
def identifiers(self, identifiers: List[Identifier]) -> None:
48-
...
46+
def identifiers(self, identifiers: List[Identifier]) -> None: ...
4947

5048
@abstractmethod
51-
def describe_table(self, table: Table) -> None:
52-
...
49+
def describe_table(self, table: Table) -> None: ...
5350

5451
@abstractmethod
55-
def files(self, table: Table, history: bool) -> None:
56-
...
52+
def files(self, table: Table, history: bool) -> None: ...
5753

5854
@abstractmethod
59-
def describe_properties(self, properties: Properties) -> None:
60-
...
55+
def describe_properties(self, properties: Properties) -> None: ...
6156

6257
@abstractmethod
63-
def text(self, response: str) -> None:
64-
...
58+
def text(self, response: str) -> None: ...
6559

6660
@abstractmethod
67-
def schema(self, schema: Schema) -> None:
68-
...
61+
def schema(self, schema: Schema) -> None: ...
6962

7063
@abstractmethod
71-
def spec(self, spec: PartitionSpec) -> None:
72-
...
64+
def spec(self, spec: PartitionSpec) -> None: ...
7365

7466
@abstractmethod
75-
def uuid(self, uuid: Optional[UUID]) -> None:
76-
...
67+
def uuid(self, uuid: Optional[UUID]) -> None: ...
7768

7869
@abstractmethod
79-
def version(self, version: str) -> None:
80-
...
70+
def version(self, version: str) -> None: ...
8171

8272
@abstractmethod
83-
def describe_refs(self, refs: List[Tuple[str, SnapshotRefType, Dict[str, str]]]) -> None:
84-
...
73+
def describe_refs(self, refs: List[Tuple[str, SnapshotRefType, Dict[str, str]]]) -> None: ...
8574

8675

8776
class ConsoleOutput(Output):
@@ -252,10 +241,8 @@ def version(self, version: str) -> None:
252241
self._out({"version": version})
253242

254243
def describe_refs(self, refs: List[Tuple[str, SnapshotRefType, Dict[str, str]]]) -> None:
255-
self._out(
256-
[
257-
{"name": name, "type": type, detail_key: detail_val}
258-
for name, type, detail in refs
259-
for detail_key, detail_val in detail.items()
260-
]
261-
)
244+
self._out([
245+
{"name": name, "type": type, detail_key: detail_val}
246+
for name, type, detail in refs
247+
for detail_key, detail_val in detail.items()
248+
])

pyiceberg/conversions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
implementation, a concrete function is registered for each generic conversion function. For PrimitiveType
2828
implementations that share the same conversion logic, registrations can be stacked.
2929
"""
30+
3031
import uuid
3132
from datetime import date, datetime, time
3233
from decimal import Decimal

pyiceberg/expressions/__init__.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,11 @@ class Unbound(Generic[B], ABC):
8080
"""Represents an unbound value expression."""
8181

8282
@abstractmethod
83-
def bind(self, schema: Schema, case_sensitive: bool = True) -> B:
84-
...
83+
def bind(self, schema: Schema, case_sensitive: bool = True) -> B: ...
8584

8685
@property
8786
@abstractmethod
88-
def as_bound(self) -> Type[Bound]:
89-
...
87+
def as_bound(self) -> Type[Bound]: ...
9088

9189

9290
class BoundTerm(Term[L], Bound, ABC):
@@ -142,8 +140,7 @@ class UnboundTerm(Term[Any], Unbound[BoundTerm[L]], ABC):
142140
"""Represents an unbound term."""
143141

144142
@abstractmethod
145-
def bind(self, schema: Schema, case_sensitive: bool = True) -> BoundTerm[L]:
146-
...
143+
def bind(self, schema: Schema, case_sensitive: bool = True) -> BoundTerm[L]: ...
147144

148145

149146
class Reference(UnboundTerm[Any]):
@@ -352,8 +349,7 @@ def __eq__(self, other: Any) -> bool:
352349

353350
@property
354351
@abstractmethod
355-
def as_unbound(self) -> Type[UnboundPredicate[Any]]:
356-
...
352+
def as_unbound(self) -> Type[UnboundPredicate[Any]]: ...
357353

358354

359355
class UnboundPredicate(Generic[L], Unbound[BooleanExpression], BooleanExpression, ABC):
@@ -367,13 +363,11 @@ def __eq__(self, other: Any) -> bool:
367363
return self.term == other.term if isinstance(other, self.__class__) else False
368364

369365
@abstractmethod
370-
def bind(self, schema: Schema, case_sensitive: bool = True) -> BooleanExpression:
371-
...
366+
def bind(self, schema: Schema, case_sensitive: bool = True) -> BooleanExpression: ...
372367

373368
@property
374369
@abstractmethod
375-
def as_bound(self) -> Type[BoundPredicate[L]]:
376-
...
370+
def as_bound(self) -> Type[BoundPredicate[L]]: ...
377371

378372

379373
class UnaryPredicate(UnboundPredicate[Any], ABC):
@@ -387,8 +381,7 @@ def __repr__(self) -> str:
387381

388382
@property
389383
@abstractmethod
390-
def as_bound(self) -> Type[BoundUnaryPredicate[Any]]:
391-
...
384+
def as_bound(self) -> Type[BoundUnaryPredicate[Any]]: ...
392385

393386

394387
class BoundUnaryPredicate(BoundPredicate[L], ABC):
@@ -398,8 +391,7 @@ def __repr__(self) -> str:
398391

399392
@property
400393
@abstractmethod
401-
def as_unbound(self) -> Type[UnaryPredicate]:
402-
...
394+
def as_unbound(self) -> Type[UnaryPredicate]: ...
403395

404396
def __getnewargs__(self) -> Tuple[BoundTerm[L]]:
405397
"""Pickle the BoundUnaryPredicate class."""
@@ -575,8 +567,7 @@ def __getnewargs__(self) -> Tuple[BoundTerm[L], Set[Literal[L]]]:
575567

576568
@property
577569
@abstractmethod
578-
def as_unbound(self) -> Type[SetPredicate[L]]:
579-
...
570+
def as_unbound(self) -> Type[SetPredicate[L]]: ...
580571

581572

582573
class BoundIn(BoundSetPredicate[L]):
@@ -705,8 +696,7 @@ def __repr__(self) -> str:
705696

706697
@property
707698
@abstractmethod
708-
def as_bound(self) -> Type[BoundLiteralPredicate[L]]:
709-
...
699+
def as_bound(self) -> Type[BoundLiteralPredicate[L]]: ...
710700

711701

712702
class BoundLiteralPredicate(BoundPredicate[L], ABC):
@@ -729,8 +719,7 @@ def __repr__(self) -> str:
729719

730720
@property
731721
@abstractmethod
732-
def as_unbound(self) -> Type[LiteralPredicate[L]]:
733-
...
722+
def as_unbound(self) -> Type[LiteralPredicate[L]]: ...
734723

735724

736725
class BoundEqualTo(BoundLiteralPredicate[L]):

0 commit comments

Comments
 (0)