This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 806580e36e Python: Fix D105 docstring violations (#7852)
806580e36e is described below
commit 806580e36e2ec692ec1fa2cddd162b598479b10a
Author: Michael DeRoy <[email protected]>
AuthorDate: Thu Jun 22 03:04:54 2023 -0400
Python: Fix D105 docstring violations (#7852)
Co-authored-by: Michael DeRoy <[email protected]>
---
python/.pre-commit-config.yaml | 2 +-
python/pyiceberg/avro/file.py | 5 +++
python/pyiceberg/avro/reader.py | 7 ++++
python/pyiceberg/expressions/__init__.py | 70 ++++++++++++++++++++++++++++++++
python/pyiceberg/expressions/literals.py | 20 +++++++++
python/pyiceberg/io/__init__.py | 8 ++--
python/pyiceberg/io/memory.py | 2 +
python/pyiceberg/manifest.py | 5 +++
python/pyiceberg/partitioning.py | 2 +
python/pyiceberg/schema.py | 6 +++
python/pyiceberg/table/__init__.py | 1 +
python/pyiceberg/table/refs.py | 1 +
python/pyiceberg/table/snapshots.py | 3 ++
python/pyiceberg/table/sorting.py | 7 ++++
python/pyiceberg/transforms.py | 13 ++++++
python/pyiceberg/typedef.py | 10 ++++-
python/pyiceberg/types.py | 18 ++++++++
python/pyiceberg/utils/bin_packing.py | 2 +
python/tests/conftest.py | 1 +
19 files changed, 176 insertions(+), 7 deletions(-)
diff --git a/python/.pre-commit-config.yaml b/python/.pre-commit-config.yaml
index 1b067f33cd..3a58520011 100644
--- a/python/.pre-commit-config.yaml
+++ b/python/.pre-commit-config.yaml
@@ -91,7 +91,7 @@ repos:
- id: pydocstyle
args:
[
-
"--ignore=D100,D102,D101,D103,D104,D105,D106,D107,D203,D209,D212,D213,D401,D404,D405,D406,D407,D411,D413,D415,D417",
+
"--ignore=D100,D102,D101,D103,D104,D106,D107,D203,D212,D213,D401,D404,D405,D406,D407,D411,D413,D415,D417",
]
additional_dependencies:
- tomli==2.0.1
diff --git a/python/pyiceberg/avro/file.py b/python/pyiceberg/avro/file.py
index 31d6a45c4c..5c408edd56 100644
--- a/python/pyiceberg/avro/file.py
+++ b/python/pyiceberg/avro/file.py
@@ -104,12 +104,14 @@ class Block(Generic[D]):
position: int = 0
def __iter__(self) -> Block[D]:
+ """Returns an iterator for the Block class."""
return self
def has_next(self) -> bool:
return self.position < self.block_records
def __next__(self) -> D:
+ """Returns the next item when iterating over the Block class."""
if self.has_next():
self.position += 1
return self.reader.read(self.block_decoder)
@@ -161,9 +163,11 @@ class AvroFile(Generic[D]):
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
) -> None:
+ """Performs cleanup when exiting the scope of a 'with' statement."""
self.input_stream.close()
def __iter__(self) -> AvroFile[D]:
+ """Returns an iterator for the AvroFile class."""
return self
def _read_block(self) -> int:
@@ -185,6 +189,7 @@ class AvroFile(Generic[D]):
return block_records
def __next__(self) -> D:
+ """Returns the next item when iterating over the AvroFile class."""
if self.block and self.block.has_next():
return next(self.block)
diff --git a/python/pyiceberg/avro/reader.py b/python/pyiceberg/avro/reader.py
index 12ffd8abfa..a1978c6ca3 100644
--- a/python/pyiceberg/avro/reader.py
+++ b/python/pyiceberg/avro/reader.py
@@ -92,6 +92,7 @@ class Reader(Singleton):
...
def __repr__(self) -> str:
+ """Returns the string representation of the Reader class."""
return f"{self.__class__.__name__}()"
@@ -209,9 +210,11 @@ class FixedReader(Reader):
decoder.skip(len(self))
def __len__(self) -> int:
+ """Returns the length of an instance of the FixedReader class."""
return self._len
def __repr__(self) -> str:
+ """Returns the string representation of the FixedReader class."""
return f"FixedReader({self._len})"
@@ -235,6 +238,7 @@ class DecimalReader(Reader):
decoder.skip_bytes()
def __repr__(self) -> str:
+ """Returns the string representation of the DecimalReader class."""
return f"DecimalReader({self.precision}, {self.scale})"
@@ -302,6 +306,7 @@ class StructReader(Reader):
field.skip(decoder)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the StructReader class."""
return (
self.field_readers == other.field_readers and self.create_struct
== other.create_struct
if isinstance(other, StructReader)
@@ -309,9 +314,11 @@ class StructReader(Reader):
)
def __repr__(self) -> str:
+ """Returns the string representation of the StructReader class."""
return f"StructReader(({','.join(repr(field) for field in
self.field_readers)}), {repr(self.create_struct)})"
def __hash__(self) -> int:
+ """Returns a hashed representation of the StructReader class."""
return hash(self.field_readers)
diff --git a/python/pyiceberg/expressions/__init__.py
b/python/pyiceberg/expressions/__init__.py
index 8737b22b2e..0d9434ea90 100644
--- a/python/pyiceberg/expressions/__init__.py
+++ b/python/pyiceberg/expressions/__init__.py
@@ -127,9 +127,11 @@ class BoundReference(BoundTerm[L]):
return self.accessor.get(struct)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the BoundReference
class."""
return self.field == other.field if isinstance(other, BoundReference)
else False
def __repr__(self) -> str:
+ """Returns the string representation of the BoundReference class."""
return f"BoundReference(field={repr(self.field)},
accessor={repr(self.accessor)})"
def ref(self) -> BoundReference[L]:
@@ -160,9 +162,11 @@ class Reference(UnboundTerm[Any]):
self.name = name
def __repr__(self) -> str:
+ """Returns the string representation of the Reference class."""
return f"Reference(name={repr(self.name)})"
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Reference class."""
return self.name == other.name if isinstance(other, Reference) else
False
def bind(self, schema: Schema, case_sensitive: bool = True) ->
BoundReference[L]:
@@ -209,19 +213,24 @@ class And(BooleanExpression):
return obj
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the And class."""
return self.left == other.left and self.right == other.right if
isinstance(other, And) else False
def __str__(self) -> str:
+ """Returns the string representation of the And class."""
return f"And(left={str(self.left)}, right={str(self.right)})"
def __repr__(self) -> str:
+ """Returns the string representation of the And class."""
return f"And(left={repr(self.left)}, right={repr(self.right)})"
def __invert__(self) -> BooleanExpression:
+ """Transform the Expression into its negated version."""
# De Morgan's law: not (A and B) = (not A) or (not B)
return Or(~self.left, ~self.right)
def __getnewargs__(self) -> Tuple[BooleanExpression, BooleanExpression]:
+ """A magic function for pickling the And class."""
return (self.left, self.right)
@@ -247,16 +256,20 @@ class Or(BooleanExpression):
return obj
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Or class."""
return self.left == other.left and self.right == other.right if
isinstance(other, Or) else False
def __repr__(self) -> str:
+ """Returns the string representation of the Or class."""
return f"Or(left={repr(self.left)}, right={repr(self.right)})"
def __invert__(self) -> BooleanExpression:
+ """Transform the Expression into its negated version."""
# De Morgan's law: not (A or B) = (not A) and (not B)
return And(~self.left, ~self.right)
def __getnewargs__(self) -> Tuple[BooleanExpression, BooleanExpression]:
+ """A magic function for pickling the Or class."""
return (self.left, self.right)
@@ -277,15 +290,19 @@ class Not(BooleanExpression):
return obj
def __repr__(self) -> str:
+ """Returns the string representation of the Not class."""
return f"Not(child={repr(self.child)})"
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Not class."""
return self.child == other.child if isinstance(other, Not) else False
def __invert__(self) -> BooleanExpression:
+ """Transform the Expression into its negated version."""
return self.child
def __getnewargs__(self) -> Tuple[BooleanExpression]:
+ """A magic function for pickling the Not class."""
return (self.child,)
@@ -293,12 +310,15 @@ class AlwaysTrue(BooleanExpression, Singleton):
"""TRUE expression."""
def __invert__(self) -> AlwaysFalse:
+ """Transform the Expression into its negated version."""
return AlwaysFalse()
def __str__(self) -> str:
+ """Returns the string representation of the AlwaysTrue class."""
return "AlwaysTrue()"
def __repr__(self) -> str:
+ """Returns the string representation of the AlwaysTrue class."""
return "AlwaysTrue()"
@@ -306,12 +326,15 @@ class AlwaysFalse(BooleanExpression, Singleton):
"""FALSE expression."""
def __invert__(self) -> AlwaysTrue:
+ """Transform the Expression into its negated version."""
return AlwaysTrue()
def __str__(self) -> str:
+ """Returns the string representation of the AlwaysFalse class."""
return "AlwaysFalse()"
def __repr__(self) -> str:
+ """Returns the string representation of the AlwaysFalse class."""
return "AlwaysFalse()"
@@ -322,6 +345,7 @@ class BoundPredicate(Generic[L], Bound, BooleanExpression,
ABC):
self.term = term
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the BoundPredicate
class."""
if isinstance(other, BoundPredicate):
return self.term == other.term
return False
@@ -339,6 +363,7 @@ class UnboundPredicate(Generic[L],
Unbound[BooleanExpression], BooleanExpression
self.term = _to_unbound_term(term)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the UnboundPredicate
class."""
return self.term == other.term if isinstance(other, UnboundPredicate)
else False
@abstractmethod
@@ -357,6 +382,7 @@ class UnaryPredicate(UnboundPredicate[Any], ABC):
return self.as_bound(bound_term)
def __repr__(self) -> str:
+ """Returns the string representation of the UnaryPredicate class."""
return f"{str(self.__class__.__name__)}(term={repr(self.term)})"
@property
@@ -367,6 +393,7 @@ class UnaryPredicate(UnboundPredicate[Any], ABC):
class BoundUnaryPredicate(BoundPredicate[L], ABC):
def __repr__(self) -> str:
+ """Returns the string representation of the BoundUnaryPredicate
class."""
return f"{str(self.__class__.__name__)}(term={repr(self.term)})"
@property
@@ -375,6 +402,7 @@ class BoundUnaryPredicate(BoundPredicate[L], ABC):
...
def __getnewargs__(self) -> Tuple[BoundTerm[L]]:
+ """A magic function for pickling the BoundUnaryPredicate class."""
return (self.term,)
@@ -385,6 +413,7 @@ class BoundIsNull(BoundUnaryPredicate[L]):
return super().__new__(cls)
def __invert__(self) -> BoundNotNull[L]:
+ """Transform the Expression into its negated version."""
return BoundNotNull(self.term)
@property
@@ -399,6 +428,7 @@ class BoundNotNull(BoundUnaryPredicate[L]):
return super().__new__(cls)
def __invert__(self) -> BoundIsNull[L]:
+ """Transform the Expression into its negated version."""
return BoundIsNull(self.term)
@property
@@ -408,6 +438,7 @@ class BoundNotNull(BoundUnaryPredicate[L]):
class IsNull(UnaryPredicate):
def __invert__(self) -> NotNull:
+ """Transform the Expression into its negated version."""
return NotNull(self.term)
@property
@@ -417,6 +448,7 @@ class IsNull(UnaryPredicate):
class NotNull(UnaryPredicate):
def __invert__(self) -> IsNull:
+ """Transform the Expression into its negated version."""
return IsNull(self.term)
@property
@@ -432,6 +464,7 @@ class BoundIsNaN(BoundUnaryPredicate[L]):
return AlwaysFalse()
def __invert__(self) -> BoundNotNaN[L]:
+ """Transform the Expression into its negated version."""
return BoundNotNaN(self.term)
@property
@@ -447,6 +480,7 @@ class BoundNotNaN(BoundUnaryPredicate[L]):
return AlwaysTrue()
def __invert__(self) -> BoundIsNaN[L]:
+ """Transform the Expression into its negated version."""
return BoundIsNaN(self.term)
@property
@@ -456,6 +490,7 @@ class BoundNotNaN(BoundUnaryPredicate[L]):
class IsNaN(UnaryPredicate):
def __invert__(self) -> NotNaN:
+ """Transform the Expression into its negated version."""
return NotNaN(self.term)
@property
@@ -465,6 +500,7 @@ class IsNaN(UnaryPredicate):
class NotNaN(UnaryPredicate):
def __invert__(self) -> IsNaN:
+ """Transform the Expression into its negated version."""
return IsNaN(self.term)
@property
@@ -484,17 +520,21 @@ class SetPredicate(UnboundPredicate[L], ABC):
return self.as_bound(bound_term,
{lit.to(bound_term.ref().field.field_type) for lit in self.literals})
def __str__(self) -> str:
+ """Returns the string representation of the SetPredicate class."""
# Sort to make it deterministic
return f"{str(self.__class__.__name__)}({str(self.term)}, {{{',
'.join(sorted([str(literal) for literal in self.literals]))}}})"
def __repr__(self) -> str:
+ """Returns the string representation of the SetPredicate class."""
# Sort to make it deterministic
return f"{str(self.__class__.__name__)}({repr(self.term)}, {{{',
'.join(sorted([repr(literal) for literal in self.literals]))}}})"
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the SetPredicate class."""
return self.term == other.term and self.literals == other.literals if
isinstance(other, SetPredicate) else False
def __getnewargs__(self) -> Tuple[UnboundTerm[L], Set[Literal[L]]]:
+ """A magic function for pickling the SetPredicate class."""
return (self.term, self.literals)
@property
@@ -516,17 +556,21 @@ class BoundSetPredicate(BoundPredicate[L], ABC):
return {lit.value for lit in self.literals}
def __str__(self) -> str:
+ """Returns the string representation of the BoundSetPredicate class."""
# Sort to make it deterministic
return f"{str(self.__class__.__name__)}({str(self.term)}, {{{',
'.join(sorted([str(literal) for literal in self.literals]))}}})"
def __repr__(self) -> str:
+ """Returns the string representation of the BoundSetPredicate class."""
# Sort to make it deterministic
return f"{str(self.__class__.__name__)}({repr(self.term)}, {{{',
'.join(sorted([repr(literal) for literal in self.literals]))}}})"
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the BoundSetPredicate
class."""
return self.term == other.term and self.literals == other.literals if
isinstance(other, BoundSetPredicate) else False
def __getnewargs__(self) -> Tuple[BoundTerm[L], Set[Literal[L]]]:
+ """A magic function for pickling the BoundSetPredicate class."""
return (self.term, self.literals)
@property
@@ -546,9 +590,11 @@ class BoundIn(BoundSetPredicate[L]):
return super().__new__(cls)
def __invert__(self) -> BoundNotIn[L]:
+ """Transform the Expression into its negated version."""
return BoundNotIn(self.term, self.literals)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the BoundIn class."""
return self.term == other.term and self.literals == other.literals if
isinstance(other, BoundIn) else False
@property
@@ -571,6 +617,7 @@ class BoundNotIn(BoundSetPredicate[L]):
return super().__new__(cls)
def __invert__(self) -> BoundIn[L]:
+ """Transform the Expression into its negated version."""
return BoundIn(self.term, self.literals)
@property
@@ -592,6 +639,7 @@ class In(SetPredicate[L]):
return super().__new__(cls)
def __invert__(self) -> NotIn[L]:
+ """Transform the Expression into its negated version."""
return NotIn[L](self.term, self.literals)
@property
@@ -613,9 +661,11 @@ class NotIn(SetPredicate[L], ABC):
return super().__new__(cls)
def __invert__(self) -> In[L]:
+ """Transform the Expression into its negated version."""
return In[L](self.term, self.literals)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the NotIn class."""
if isinstance(other, NotIn):
return self.term == other.term and self.literals == other.literals
return False
@@ -650,11 +700,13 @@ class LiteralPredicate(UnboundPredicate[L], ABC):
return self.as_bound(bound_term, lit)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the LiteralPredicate
class."""
if isinstance(other, LiteralPredicate):
return self.term == other.term and self.literal == other.literal
return False
def __repr__(self) -> str:
+ """Returns the string representation of the LiteralPredicate class."""
return f"{str(self.__class__.__name__)}(term={repr(self.term)},
literal={repr(self.literal)})"
@property
@@ -672,11 +724,13 @@ class BoundLiteralPredicate(BoundPredicate[L], ABC):
self.literal = literal # pylint: disable=W0621
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the BoundLiteralPredicate
class."""
if isinstance(other, BoundLiteralPredicate):
return self.term == other.term and self.literal == other.literal
return False
def __repr__(self) -> str:
+ """Returns the string representation of the BoundLiteralPredicate
class."""
return f"{str(self.__class__.__name__)}(term={repr(self.term)},
literal={repr(self.literal)})"
@property
@@ -687,6 +741,7 @@ class BoundLiteralPredicate(BoundPredicate[L], ABC):
class BoundEqualTo(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundNotEqualTo[L]:
+ """Transform the Expression into its negated version."""
return BoundNotEqualTo[L](self.term, self.literal)
@property
@@ -696,6 +751,7 @@ class BoundEqualTo(BoundLiteralPredicate[L]):
class BoundNotEqualTo(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundEqualTo[L]:
+ """Transform the Expression into its negated version."""
return BoundEqualTo[L](self.term, self.literal)
@property
@@ -705,6 +761,7 @@ class BoundNotEqualTo(BoundLiteralPredicate[L]):
class BoundGreaterThanOrEqual(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundLessThan[L]:
+ """Transform the Expression into its negated version."""
return BoundLessThan[L](self.term, self.literal)
@property
@@ -714,6 +771,7 @@ class BoundGreaterThanOrEqual(BoundLiteralPredicate[L]):
class BoundGreaterThan(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundLessThanOrEqual[L]:
+ """Transform the Expression into its negated version."""
return BoundLessThanOrEqual(self.term, self.literal)
@property
@@ -723,6 +781,7 @@ class BoundGreaterThan(BoundLiteralPredicate[L]):
class BoundLessThan(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundGreaterThanOrEqual[L]:
+ """Transform the Expression into its negated version."""
return BoundGreaterThanOrEqual[L](self.term, self.literal)
@property
@@ -732,6 +791,7 @@ class BoundLessThan(BoundLiteralPredicate[L]):
class BoundLessThanOrEqual(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundGreaterThan[L]:
+ """Transform the Expression into its negated version."""
return BoundGreaterThan[L](self.term, self.literal)
@property
@@ -741,6 +801,7 @@ class BoundLessThanOrEqual(BoundLiteralPredicate[L]):
class BoundStartsWith(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundNotStartsWith[L]:
+ """Transform the Expression into its negated version."""
return BoundNotStartsWith[L](self.term, self.literal)
@property
@@ -750,6 +811,7 @@ class BoundStartsWith(BoundLiteralPredicate[L]):
class BoundNotStartsWith(BoundLiteralPredicate[L]):
def __invert__(self) -> BoundStartsWith[L]:
+ """Transform the Expression into its negated version."""
return BoundStartsWith[L](self.term, self.literal)
@property
@@ -759,6 +821,7 @@ class BoundNotStartsWith(BoundLiteralPredicate[L]):
class EqualTo(LiteralPredicate[L]):
def __invert__(self) -> NotEqualTo[L]:
+ """Transform the Expression into its negated version."""
return NotEqualTo[L](self.term, self.literal)
@property
@@ -768,6 +831,7 @@ class EqualTo(LiteralPredicate[L]):
class NotEqualTo(LiteralPredicate[L]):
def __invert__(self) -> EqualTo[L]:
+ """Transform the Expression into its negated version."""
return EqualTo[L](self.term, self.literal)
@property
@@ -777,6 +841,7 @@ class NotEqualTo(LiteralPredicate[L]):
class LessThan(LiteralPredicate[L]):
def __invert__(self) -> GreaterThanOrEqual[L]:
+ """Transform the Expression into its negated version."""
return GreaterThanOrEqual[L](self.term, self.literal)
@property
@@ -786,6 +851,7 @@ class LessThan(LiteralPredicate[L]):
class GreaterThanOrEqual(LiteralPredicate[L]):
def __invert__(self) -> LessThan[L]:
+ """Transform the Expression into its negated version."""
return LessThan[L](self.term, self.literal)
@property
@@ -795,6 +861,7 @@ class GreaterThanOrEqual(LiteralPredicate[L]):
class GreaterThan(LiteralPredicate[L]):
def __invert__(self) -> LessThanOrEqual[L]:
+ """Transform the Expression into its negated version."""
return LessThanOrEqual[L](self.term, self.literal)
@property
@@ -804,6 +871,7 @@ class GreaterThan(LiteralPredicate[L]):
class LessThanOrEqual(LiteralPredicate[L]):
def __invert__(self) -> GreaterThan[L]:
+ """Transform the Expression into its negated version."""
return GreaterThan[L](self.term, self.literal)
@property
@@ -813,6 +881,7 @@ class LessThanOrEqual(LiteralPredicate[L]):
class StartsWith(LiteralPredicate[L]):
def __invert__(self) -> NotStartsWith[L]:
+ """Transform the Expression into its negated version."""
return NotStartsWith[L](self.term, self.literal)
@property
@@ -822,6 +891,7 @@ class StartsWith(LiteralPredicate[L]):
class NotStartsWith(LiteralPredicate[L]):
def __invert__(self) -> NotStartsWith[L]:
+ """Transform the Expression into its negated version."""
return NotStartsWith[L](self.term, self.literal)
@property
diff --git a/python/pyiceberg/expressions/literals.py
b/python/pyiceberg/expressions/literals.py
index 420fa0df48..1e47e87608 100644
--- a/python/pyiceberg/expressions/literals.py
+++ b/python/pyiceberg/expressions/literals.py
@@ -80,32 +80,41 @@ class Literal(Generic[L], ABC):
... # pragma: no cover
def __repr__(self) -> str:
+ """Returns the string representation of the Literal class."""
return f"{type(self).__name__}({self.value!r})"
def __str__(self) -> str:
+ """Returns the string representation of the Literal class."""
return str(self.value)
def __hash__(self) -> int:
+ """Returns a hashed representation of the Literal class."""
return hash(self.value)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Literal class."""
if not isinstance(other, Literal):
return False
return self.value == other.value
def __ne__(self, other: Any) -> bool:
+ """Returns the inequality of two instances of the Literal class."""
return not self.__eq__(other)
def __lt__(self, other: Any) -> bool:
+ """Returns if one instance of the Literal class is less than another
instance."""
return self.value < other.value
def __gt__(self, other: Any) -> bool:
+ """Returns if one instance of the Literal class is greater than
another instance."""
return self.value > other.value
def __le__(self, other: Any) -> bool:
+ """Returns if one instance of the Literal class is less than or equal
to another instance."""
return self.value <= other.value
def __ge__(self, other: Any) -> bool:
+ """Returns if one instance of the Literal class is greater than or
equal to another instance."""
return self.value >= other.value
@@ -141,17 +150,21 @@ def literal(value: L) -> Literal[L]:
class AboveMax(Literal[L]):
def __repr__(self) -> str:
+ """Returns the string representation of the AboveMax class."""
return f"{self.__class__.__name__}()"
def __str__(self) -> str:
+ """Returns the string representation of the AboveMax class."""
return self.__class__.__name__
class BelowMin(Literal[L]):
def __repr__(self) -> str:
+ """Returns the string representation of the BelowMin class."""
return f"{self.__class__.__name__}()"
def __str__(self) -> str:
+ """Returns the string representation of the BelowMin class."""
return self.__class__.__name__
@@ -314,21 +327,27 @@ class FloatLiteral(Literal[float]):
self._value32 = struct.unpack("<f", struct.pack("<f", value))[0]
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the FloatLiteral class."""
return self._value32 == other
def __lt__(self, other: Any) -> bool:
+ """Returns if one instance of the FloatLiteral class is less than
another instance."""
return self._value32 < other
def __gt__(self, other: Any) -> bool:
+ """Returns if one instance of the FloatLiteral class is greater than
another instance."""
return self._value32 > other
def __le__(self, other: Any) -> bool:
+ """Returns if one instance of the FloatLiteral class is less than or
equal to another instance."""
return self._value32 <= other
def __ge__(self, other: Any) -> bool:
+ """Returns if one instance of the FloatLiteral class is greater than
or equal to another instance."""
return self._value32 >= other
def __hash__(self) -> int:
+ """Returns a hashed representation of the FloatLiteral class."""
return hash(self._value32)
@singledispatchmethod
@@ -573,6 +592,7 @@ class StringLiteral(Literal[str]):
raise ValueError(f"Could not convert {self.value} into a
{type_var}")
def __repr__(self) -> str:
+ """Returns the string representation of the StringLiteral class."""
return f"literal({repr(self.value)})"
diff --git a/python/pyiceberg/io/__init__.py b/python/pyiceberg/io/__init__.py
index 96fcea605d..27a3996101 100644
--- a/python/pyiceberg/io/__init__.py
+++ b/python/pyiceberg/io/__init__.py
@@ -77,13 +77,13 @@ class InputStream(Protocol):
...
def __enter__(self) -> InputStream:
- ...
+ """Provides setup when opening an InputStream using a 'with'
statement."""
@abstractmethod
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
) -> None:
- ...
+ """Performs cleanup when exiting the scope of a 'with' statement."""
@runtime_checkable
@@ -104,13 +104,13 @@ class OutputStream(Protocol): # pragma: no cover
@abstractmethod
def __enter__(self) -> OutputStream:
- ...
+ """Provides setup when opening an OutputStream using a 'with'
statement."""
@abstractmethod
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
) -> None:
- ...
+ """Performs cleanup when exiting the scope of a 'with' statement."""
class InputFile(ABC):
diff --git a/python/pyiceberg/io/memory.py b/python/pyiceberg/io/memory.py
index f100952469..c76efa570f 100644
--- a/python/pyiceberg/io/memory.py
+++ b/python/pyiceberg/io/memory.py
@@ -75,9 +75,11 @@ class MemoryInputStream(InputStream):
self.pos = 0
def __enter__(self) -> MemoryInputStream:
+ """Provides setup when opening a MemoryInputStream using a 'with'
statement."""
return self
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
) -> None:
+ """Performs cleanup when exiting the scope of a 'with' statement."""
self.close()
diff --git a/python/pyiceberg/manifest.py b/python/pyiceberg/manifest.py
index 50d16c0820..1220d8d411 100644
--- a/python/pyiceberg/manifest.py
+++ b/python/pyiceberg/manifest.py
@@ -46,6 +46,7 @@ class DataFileContent(int, Enum):
EQUALITY_DELETES = 2
def __repr__(self) -> str:
+ """Returns the string representation of the DataFileContent class."""
return f"DataFileContent.{self.name}"
@@ -54,6 +55,7 @@ class ManifestContent(int, Enum):
DELETES = 1
def __repr__(self) -> str:
+ """Returns the string representation of the ManifestContent class."""
return f"ManifestContent.{self.name}"
@@ -63,6 +65,7 @@ class ManifestEntryStatus(int, Enum):
DELETED = 2
def __repr__(self) -> str:
+ """Returns the string representation of the ManifestEntryStatus
class."""
return f"ManifestEntryStatus.{self.name}"
@@ -72,6 +75,7 @@ class FileFormat(str, Enum):
ORC = "ORC"
def __repr__(self) -> str:
+ """Returns the string representation of the FileFormat class."""
return f"FileFormat.{self.name}"
@@ -179,6 +183,7 @@ class DataFile(Record):
spec_id: Optional[int]
def __setattr__(self, name: str, value: Any) -> None:
+ """Used for assigning a key/value to a DataFile."""
# The file_format is written as a string, so we need to cast it to the
Enum
if name == "file_format":
value = FileFormat[value]
diff --git a/python/pyiceberg/partitioning.py b/python/pyiceberg/partitioning.py
index 554c04627d..935dbea68f 100644
--- a/python/pyiceberg/partitioning.py
+++ b/python/pyiceberg/partitioning.py
@@ -68,6 +68,7 @@ class PartitionField(IcebergBaseModel):
super().__init__(**data)
def __str__(self) -> str:
+ """Returns the string representation of the PartitionField class."""
return f"{self.field_id}: {self.name}:
{self.transform}({self.source_id})"
@@ -117,6 +118,7 @@ class PartitionSpec(IcebergBaseModel):
return result_str
def __repr__(self) -> str:
+ """Returns the string representation of the PartitionSpec class."""
fields = f"{', '.join(repr(column) for column in self.fields)}, " if
self.fields else ""
return f"PartitionSpec({fields}spec_id={self.spec_id})"
diff --git a/python/pyiceberg/schema.py b/python/pyiceberg/schema.py
index 1fdd7d0493..ea512078df 100644
--- a/python/pyiceberg/schema.py
+++ b/python/pyiceberg/schema.py
@@ -88,15 +88,19 @@ class Schema(IcebergBaseModel):
self._name_to_id = index_by_name(self)
def __str__(self) -> str:
+ """Returns the string representation of the Schema class."""
return "table {\n" + "\n".join([" " + str(field) for field in
self.columns]) + "\n}"
def __repr__(self) -> str:
+ """Returns the string representation of the Schema class."""
return f"Schema({', '.join(repr(column) for column in self.columns)},
schema_id={self.schema_id}, identifier_field_ids={self.identifier_field_ids})"
def __len__(self) -> int:
+ """Returns the length of an instance of the Literal class."""
return len(self.fields)
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Schema class."""
if not other:
return False
@@ -681,9 +685,11 @@ class Accessor:
inner: Optional["Accessor"] = None
def __str__(self) -> str:
+ """Returns the string representation of the Accessor class."""
return f"Accessor(position={self.position},inner={self.inner})"
def __repr__(self) -> str:
+ """Returns the string representation of the Accessor class."""
return self.__str__()
def get(self, container: StructProtocol) -> Any:
diff --git a/python/pyiceberg/table/__init__.py
b/python/pyiceberg/table/__init__.py
index 0d433a65c6..c79544be09 100644
--- a/python/pyiceberg/table/__init__.py
+++ b/python/pyiceberg/table/__init__.py
@@ -481,6 +481,7 @@ class Table:
return self.metadata.snapshot_log
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Table class."""
return (
self.identifier == other.identifier
and self.metadata == other.metadata
diff --git a/python/pyiceberg/table/refs.py b/python/pyiceberg/table/refs.py
index 09cbad27f1..a9089f84af 100644
--- a/python/pyiceberg/table/refs.py
+++ b/python/pyiceberg/table/refs.py
@@ -29,6 +29,7 @@ class SnapshotRefType(str, Enum):
TAG = "tag"
def __repr__(self) -> str:
+ """Returns the string representation of the SnapshotRefType class."""
return f"SnapshotRefType.{self.name}"
diff --git a/python/pyiceberg/table/snapshots.py
b/python/pyiceberg/table/snapshots.py
index 186c7756ad..e21a7ece64 100644
--- a/python/pyiceberg/table/snapshots.py
+++ b/python/pyiceberg/table/snapshots.py
@@ -48,6 +48,7 @@ class Operation(Enum):
DELETE = "delete"
def __repr__(self) -> str:
+ """Returns the string representation of the Operation class."""
return f"Operation.{self.name}"
@@ -92,6 +93,7 @@ class Summary(IcebergBaseModel):
return self._additional_properties
def __repr__(self) -> str:
+ """Returns the string representation of the Summary class."""
repr_properties = f", **{repr(self._additional_properties)}" if
self._additional_properties else ""
return f"Summary({repr(self.operation)}{repr_properties})"
@@ -106,6 +108,7 @@ class Snapshot(IcebergBaseModel):
schema_id: Optional[int] = Field(alias="schema-id", default=None)
def __str__(self) -> str:
+ """Returns the string representation of the Snapshot class."""
operation = f"{self.summary.operation}: " if self.summary else ""
parent_id = f", parent_id={self.parent_snapshot_id}" if
self.parent_snapshot_id else ""
schema_id = f", schema_id={self.schema_id}" if self.schema_id is not
None else ""
diff --git a/python/pyiceberg/table/sorting.py
b/python/pyiceberg/table/sorting.py
index 75a2efda08..3fbc82465f 100644
--- a/python/pyiceberg/table/sorting.py
+++ b/python/pyiceberg/table/sorting.py
@@ -38,9 +38,11 @@ class SortDirection(Enum):
DESC = "desc"
def __str__(self) -> str:
+ """Returns the string representation of the SortDirection class."""
return self.name
def __repr__(self) -> str:
+ """Returns the string representation of the SortDirection class."""
return f"SortDirection.{self.name}"
@@ -49,9 +51,11 @@ class NullOrder(Enum):
NULLS_LAST = "nulls-last"
def __str__(self) -> str:
+ """Returns the string representation of the NullOrder class."""
return self.name.replace("_", " ")
def __repr__(self) -> str:
+ """Returns the string representation of the NullOrder class."""
return f"NullOrder.{self.name}"
@@ -97,6 +101,7 @@ class SortField(IcebergBaseModel):
null_order: NullOrder = Field(alias="null-order")
def __str__(self) -> str:
+ """Returns the string representation of the SortField class."""
if type(self.transform) == IdentityTransform:
# In the case of an identity transform, we can omit the transform
return f"{self.source_id} {self.direction} {self.null_order}"
@@ -134,6 +139,7 @@ class SortOrder(IcebergBaseModel):
return len(self.fields) == 0
def __str__(self) -> str:
+ """Returns the string representation of the SortOrder class."""
result_str = "["
if self.fields:
result_str += "\n " + "\n ".join([str(field) for field in
self.fields]) + "\n"
@@ -141,6 +147,7 @@ class SortOrder(IcebergBaseModel):
return result_str
def __repr__(self) -> str:
+ """Returns the string representation of the SortOrder class."""
fields = f"{', '.join(repr(column) for column in self.fields)}, " if
self.fields else ""
return f"SortOrder({fields}order_id={self.order_id})"
diff --git a/python/pyiceberg/transforms.py b/python/pyiceberg/transforms.py
index ee7ae69acf..4b67f66873 100644
--- a/python/pyiceberg/transforms.py
+++ b/python/pyiceberg/transforms.py
@@ -116,6 +116,7 @@ class Transform(IcebergBaseModel, ABC, Generic[S, T]):
@classmethod
def __get_validators__(cls) -> Generator[AnyCallable, None, None]:
+ """Called to validate the input of the Transform class."""
# one or more validators may be yielded which will be called in the
# order to validate the input, each validator will receive as an input
# the value returned from the previous validator
@@ -177,9 +178,11 @@ class Transform(IcebergBaseModel, ABC, Generic[S, T]):
return self.__str__()
def __str__(self) -> str:
+ """Returns the string representation of the Transform class."""
return self.__root__
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Transform class."""
if isinstance(other, Transform):
return self.__root__ == other.__root__
return False
@@ -282,6 +285,7 @@ class BucketTransform(Transform[S, int]):
return hash_func
def __repr__(self) -> str:
+ """Returns the string representation of the BucketTransform class."""
return f"BucketTransform(num_buckets={self._num_buckets})"
@@ -376,6 +380,7 @@ class YearTransform(TimeTransform[S]):
return datetime.to_human_year(value) if isinstance(value, int) else
"null"
def __repr__(self) -> str:
+ """Returns the string representation of the YearTransform class."""
return "YearTransform()"
@@ -422,6 +427,7 @@ class MonthTransform(TimeTransform[S]):
return datetime.to_human_month(value) if isinstance(value, int) else
"null"
def __repr__(self) -> str:
+ """Returns the string representation of the MonthTransform class."""
return "MonthTransform()"
@@ -471,6 +477,7 @@ class DayTransform(TimeTransform[S]):
return datetime.to_human_day(value) if isinstance(value, int) else
"null"
def __repr__(self) -> str:
+ """Returns the string representation of the DayTransform class."""
return "DayTransform()"
@@ -510,6 +517,7 @@ class HourTransform(TimeTransform[S]):
return datetime.to_human_hour(value) if isinstance(value, int) else
"null"
def __repr__(self) -> str:
+ """Returns the string representation of the HourTransform class."""
return "HourTransform()"
@@ -562,9 +570,11 @@ class IdentityTransform(Transform[S, S]):
return _human_string(value, source_type) if value is not None else
"null"
def __str__(self) -> str:
+ """Returns the string representation of the IdentityTransform class."""
return "identity"
def __repr__(self) -> str:
+ """Returns the string representation of the IdentityTransform class."""
return "IdentityTransform()"
@@ -664,6 +674,7 @@ class TruncateTransform(Transform[S, S]):
return str(value)
def __repr__(self) -> str:
+ """Returns the string representation of the TruncateTransform class."""
return f"TruncateTransform(width={self._width})"
@@ -737,6 +748,7 @@ class UnknownTransform(Transform[S, T]):
return None
def __repr__(self) -> str:
+ """Returns the string representation of the UnknownTransform class."""
return f"UnknownTransform(transform={repr(self._transform)})"
@@ -761,6 +773,7 @@ class VoidTransform(Transform[S, None], Singleton):
return "null"
def __repr__(self) -> str:
+ """Returns the string representation of the VoidTransform class."""
return "VoidTransform()"
diff --git a/python/pyiceberg/typedef.py b/python/pyiceberg/typedef.py
index df133416e8..184b788c88 100644
--- a/python/pyiceberg/typedef.py
+++ b/python/pyiceberg/typedef.py
@@ -42,6 +42,7 @@ if TYPE_CHECKING:
class FrozenDict(Dict[Any, Any]):
def __setitem__(self, instance: Any, value: Any) -> None:
+ """Used for assigning a value to a FrozenDict."""
raise AttributeError("FrozenDict does not support assignment")
def update(self, *args: Any, **kwargs: Any) -> None:
@@ -61,6 +62,7 @@ class KeyDefaultDict(Dict[K, V]):
self.default_factory = default_factory
def __missing__(self, key: K) -> V:
+ """Defines behavior if you access a non-existent key in a
KeyDefaultDict."""
val = self.default_factory(key)
self[key] = val
return val
@@ -80,11 +82,11 @@ class StructProtocol(Protocol): # pragma: no cover
@abstractmethod
def __getitem__(self, pos: int) -> Any:
- ...
+ """Used for fetching a value from a StructProtocol."""
@abstractmethod
def __setitem__(self, pos: int, value: Any) -> None:
- ...
+ """Used for assigning a value to a StructProtocol."""
class IcebergBaseModel(BaseModel):
@@ -143,15 +145,19 @@ class Record(StructProtocol):
self.__setattr__(field_name, d)
def __setitem__(self, pos: int, value: Any) -> None:
+ """Used for assigning a value to a Record."""
self.__setattr__(self._position_to_field_name[pos], value)
def __getitem__(self, pos: int) -> Any:
+ """Used for fetching a value from a Record."""
return self.__getattribute__(self._position_to_field_name[pos])
def __eq__(self, other: Any) -> bool:
+ """Returns the equality of two instances of the Record class."""
if not isinstance(other, Record):
return False
return self.__dict__ == other.__dict__
def __repr__(self) -> str:
+ """Returns the string representation of the Record class."""
return f"{self.__class__.__name__}[{', '.join(f'{key}={repr(value)}'
for key, value in self.__dict__.items() if not key.startswith('_'))}]"
diff --git a/python/pyiceberg/types.py b/python/pyiceberg/types.py
index 76a1d98a31..e4f19fade8 100644
--- a/python/pyiceberg/types.py
+++ b/python/pyiceberg/types.py
@@ -66,6 +66,7 @@ class IcebergType(IcebergBaseModel, Singleton):
@classmethod
def __get_validators__(cls) -> Generator[AnyCallable, None, None]:
+ """Called to validate the input of the IcebergType class."""
# one or more validators may be yielded which will be called in the
# order to validate the input, each validator will receive as an input
# the value returned from the previous validator
@@ -112,9 +113,11 @@ class PrimitiveType(IcebergType):
__root__: str = Field()
def __repr__(self) -> str:
+ """Returns the string representation of the PrimitiveType class."""
return f"{type(self).__name__}()"
def __str__(self) -> str:
+ """Returns the string representation of the PrimitiveType class."""
return self.__root__
@@ -142,12 +145,15 @@ class FixedType(PrimitiveType):
self._len = length
def __len__(self) -> int:
+ """Returns the length of an instance of the FixedType class."""
return self._len
def __repr__(self) -> str:
+ """Returns the string representation of the FixedType class."""
return f"FixedType(length={self._len})"
def __getnewargs__(self) -> Tuple[int]:
+ """A magic function for pickling the FixedType class."""
return (self._len,)
@@ -193,9 +199,11 @@ class DecimalType(PrimitiveType):
return self._scale
def __repr__(self) -> str:
+ """Returns the string representation of the DecimalType class."""
return f"DecimalType(precision={self._precision}, scale={self._scale})"
def __getnewargs__(self) -> Tuple[int, int]:
+ """A magic function for pickling the DecimalType class."""
return (self._precision, self._scale)
@@ -250,11 +258,13 @@ class NestedField(IcebergType):
super().__init__(**data)
def __str__(self) -> str:
+ """Returns the string representation of the NestedField class."""
doc = "" if not self.doc else f" ({self.doc})"
req = "required" if self.required else "optional"
return f"{self.field_id}: {self.name}: {req} {self.field_type}{doc}"
def __getnewargs__(self) -> Tuple[int, str, IcebergType, bool,
Optional[str]]:
+ """A magic function for pickling the NestedField class."""
return (self.field_id, self.name, self.field_type, self.required,
self.doc)
@property
@@ -289,15 +299,19 @@ class StructType(IcebergType):
return None
def __str__(self) -> str:
+ """Returns the string representation of the StructType class."""
return f"struct<{', '.join(map(str, self.fields))}>"
def __repr__(self) -> str:
+ """Returns the string representation of the StructType class."""
return f"StructType(fields=({', '.join(map(repr, self.fields))},))"
def __len__(self) -> int:
+ """Returns the length of an instance of the StructType class."""
return len(self.fields)
def __getnewargs__(self) -> Tuple[NestedField, ...]:
+ """A magic function for pickling the StructType class."""
return self.fields
@@ -333,9 +347,11 @@ class ListType(IcebergType):
super().__init__(**data)
def __str__(self) -> str:
+ """Returns the string representation of the ListType class."""
return f"list<{self.element_type}>"
def __getnewargs__(self) -> Tuple[int, IcebergType, bool]:
+ """A magic function for pickling the ListType class."""
return (self.element_id, self.element_type, self.element_required)
@@ -381,9 +397,11 @@ class MapType(IcebergType):
super().__init__(**data)
def __str__(self) -> str:
+ """Returns the string representation of the MapType class."""
return f"map<{self.key_type}, {self.value_type}>"
def __getnewargs__(self) -> Tuple[int, IcebergType, int, IcebergType,
bool]:
+ """A magic function for pickling the MapType class."""
return (self.key_id, self.key_type, self.value_id, self.value_type,
self.value_required)
diff --git a/python/pyiceberg/utils/bin_packing.py
b/python/pyiceberg/utils/bin_packing.py
index 10e21693ae..7f9d44117a 100644
--- a/python/pyiceberg/utils/bin_packing.py
+++ b/python/pyiceberg/utils/bin_packing.py
@@ -64,9 +64,11 @@ class PackingIterator(Generic[T]):
self.bins = []
def __iter__(self) -> PackingIterator[T]:
+ """Returns an iterator for the PackingIterator class."""
return self
def __next__(self) -> List[T]:
+ """Returns the next item when iterating over the PackingIterator
class."""
while True:
try:
item = next(self.items)
diff --git a/python/tests/conftest.py b/python/tests/conftest.py
index 2bd6270620..55588f60f9 100644
--- a/python/tests/conftest.py
+++ b/python/tests/conftest.py
@@ -1041,6 +1041,7 @@ class LocalOutputFile(OutputFile):
self._path = parsed_location.path
def __len__(self) -> int:
+ """Returns the length of an instance of the LocalOutputFile class."""
return os.path.getsize(self._path)
def exists(self) -> bool: