Skip to content

Commit 4ed5a14

Browse files
TjuAachenFokko
andcommitted
Python: Fix D401 pydocstyle issues (#8401)
* Fix D401 pydocstyle issues * Update python/tests/conftest.py --------- Co-authored-by: Fokko Driesprong <[email protected]>
1 parent 98c2257 commit 4ed5a14

Some content is hidden

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

45 files changed

+359
-359
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ repos:
9191
- id: pydocstyle
9292
args:
9393
[
94-
"--ignore=D100,D102,D101,D103,D104,D106,D107,D203,D212,D213,D401,D404,D405,D406,D407,D411,D413,D415,D417",
94+
"--ignore=D100,D102,D101,D103,D104,D106,D107,D203,D212,D213,D404,D405,D406,D407,D411,D413,D415,D417",
9595
]
9696
additional_dependencies:
9797
- tomli==2.0.1

pyiceberg/avro/decoder.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def skip(self, n: int) -> None:
4747
"""Skip n bytes."""
4848

4949
def read_boolean(self) -> bool:
50-
"""Reads a value from the stream as a boolean.
50+
"""Read a value from the stream as a boolean.
5151
5252
A boolean is written as a single byte
5353
whose value is either 0 (false) or 1 (true).
5454
"""
5555
return ord(self.read(1)) == 1
5656

5757
def read_int(self) -> int:
58-
"""Reads an int/long value.
58+
"""Read an int/long value.
5959
6060
int/long values are written using variable-length, zigzag coding.
6161
"""
@@ -70,18 +70,18 @@ def read_int(self) -> int:
7070
return datum
7171

7272
def read_ints(self, n: int) -> Tuple[int, ...]:
73-
"""Reads a list of integers."""
73+
"""Read a list of integers."""
7474
return tuple(self.read_int() for _ in range(n))
7575

7676
def read_int_bytes_dict(self, n: int, dest: Dict[int, bytes]) -> None:
77-
"""Reads a dictionary of integers for keys and bytes for values into a destination dictionary."""
77+
"""Read a dictionary of integers for keys and bytes for values into a destination dictionary."""
7878
for _ in range(n):
7979
k = self.read_int()
8080
v = self.read_bytes()
8181
dest[k] = v
8282

8383
def read_float(self) -> float:
84-
"""Reads a value from the stream as a float.
84+
"""Read a value from the stream as a float.
8585
8686
A float is written as 4 bytes.
8787
The float is converted into a 32-bit integer using a method equivalent to
@@ -90,7 +90,7 @@ def read_float(self) -> float:
9090
return float(cast(Tuple[float, ...], STRUCT_FLOAT.unpack(self.read(4)))[0])
9191

9292
def read_double(self) -> float:
93-
"""Reads a value from the stream as a double.
93+
"""Read a value from the stream as a double.
9494
9595
A double is written as 8 bytes.
9696
The double is converted into a 64-bit integer using a method equivalent to
@@ -104,7 +104,7 @@ def read_bytes(self) -> bytes:
104104
return self.read(num_bytes) if num_bytes > 0 else b""
105105

106106
def read_utf8(self) -> str:
107-
"""Reads an utf-8 encoded string from the stream.
107+
"""Read an utf-8 encoded string from the stream.
108108
109109
A string is encoded as a long followed by
110110
that many bytes of UTF-8 encoded character data.

pyiceberg/avro/encoder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def write(self, b: bytes) -> None:
3232
self._output_stream.write(b)
3333

3434
def write_boolean(self, boolean: bool) -> None:
35-
"""A boolean is written as a single byte whose value is either 0 (false) or 1 (true).
35+
"""Write a boolean as a single byte whose value is either 0 (false) or 1 (true).
3636
3737
Args:
3838
boolean: The boolean to write.
@@ -48,11 +48,11 @@ def write_int(self, integer: int) -> None:
4848
self.write(bytearray([datum]))
4949

5050
def write_float(self, f: float) -> None:
51-
"""A float is written as 4 bytes."""
51+
"""Write a float as 4 bytes."""
5252
self.write(STRUCT_FLOAT.pack(f))
5353

5454
def write_double(self, f: float) -> None:
55-
"""A double is written as 8 bytes."""
55+
"""Write a double as 8 bytes."""
5656
self.write(STRUCT_DOUBLE.pack(f))
5757

5858
def write_bytes(self, b: bytes) -> None:
@@ -61,7 +61,7 @@ def write_bytes(self, b: bytes) -> None:
6161
self.write(b)
6262

6363
def write_utf8(self, s: str) -> None:
64-
"""A string is encoded as a long followed by that many bytes of UTF-8 encoded character data."""
64+
"""Encode a string as a long followed by that many bytes of UTF-8 encoded character data."""
6565
self.write_bytes(s.encode("utf-8"))
6666

6767
def write_uuid(self, uuid: UUID) -> None:

pyiceberg/avro/file.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ class Block(Generic[D]):
109109
position: int = 0
110110

111111
def __iter__(self) -> Block[D]:
112-
"""Returns an iterator for the Block class."""
112+
"""Return an iterator for the Block class."""
113113
return self
114114

115115
def has_next(self) -> bool:
116116
return self.position < self.block_records
117117

118118
def __next__(self) -> D:
119-
"""Returns the next item when iterating over the Block class."""
119+
"""Return the next item when iterating over the Block class."""
120120
if self.has_next():
121121
self.position += 1
122122
return self.reader.read(self.block_decoder)
@@ -160,9 +160,9 @@ def __init__(
160160
self.block = None
161161

162162
def __enter__(self) -> AvroFile[D]:
163-
"""Generates a reader tree for the payload within an avro file.
163+
"""Generate a reader tree for the payload within an avro file.
164164
165-
Returns:
165+
Return:
166166
A generator returning the AvroStructs.
167167
"""
168168
with self.input_file.open() as f:
@@ -179,10 +179,10 @@ def __enter__(self) -> AvroFile[D]:
179179
def __exit__(
180180
self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType]
181181
) -> None:
182-
"""Performs cleanup when exiting the scope of a 'with' statement."""
182+
"""Perform cleanup when exiting the scope of a 'with' statement."""
183183

184184
def __iter__(self) -> AvroFile[D]:
185-
"""Returns an iterator for the AvroFile class."""
185+
"""Return an iterator for the AvroFile class."""
186186
return self
187187

188188
def _read_block(self) -> int:
@@ -202,7 +202,7 @@ def _read_block(self) -> int:
202202
return block_records
203203

204204
def __next__(self) -> D:
205-
"""Returns the next item when iterating over the AvroFile class."""
205+
"""Return the next item when iterating over the AvroFile class."""
206206
if self.block and self.block.has_next():
207207
return next(self.block)
208208

@@ -238,7 +238,7 @@ def __init__(self, output_file: OutputFile, schema: Schema, schema_name: str, me
238238

239239
def __enter__(self) -> AvroOutputFile[D]:
240240
"""
241-
Opens the file and writes the header.
241+
Open the file and writes the header.
242242
243243
Returns:
244244
The file object to write records to
@@ -254,7 +254,7 @@ def __enter__(self) -> AvroOutputFile[D]:
254254
def __exit__(
255255
self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType]
256256
) -> None:
257-
"""Performs cleanup when exiting the scope of a 'with' statement."""
257+
"""Perform cleanup when exiting the scope of a 'with' statement."""
258258
self.output_stream.close()
259259

260260
def _write_header(self) -> None:

pyiceberg/avro/reader.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def skip(self, decoder: ReadableDecoder) -> None:
9797
...
9898

9999
def __repr__(self) -> str:
100-
"""Returns the string representation of the Reader class."""
100+
"""Return the string representation of the Reader class."""
101101
return f"{self.__class__.__name__}()"
102102

103103

@@ -217,11 +217,11 @@ def skip(self, decoder: ReadableDecoder) -> None:
217217
decoder.skip(len(self))
218218

219219
def __len__(self) -> int:
220-
"""Returns the length of an instance of the FixedReader class."""
220+
"""Return the length of an instance of the FixedReader class."""
221221
return self._len
222222

223223
def __repr__(self) -> str:
224-
"""Returns the string representation of the FixedReader class."""
224+
"""Return the string representation of the FixedReader class."""
225225
return f"FixedReader({self._len})"
226226

227227

@@ -263,7 +263,7 @@ def skip(self, decoder: ReadableDecoder) -> None:
263263
decoder.skip_bytes()
264264

265265
def __repr__(self) -> str:
266-
"""Returns the string representation of the DecimalReader class."""
266+
"""Return the string representation of the DecimalReader class."""
267267
return f"DecimalReader({self.precision}, {self.scale})"
268268

269269

@@ -346,19 +346,19 @@ def skip(self, decoder: ReadableDecoder) -> None:
346346
field.skip(decoder)
347347

348348
def __eq__(self, other: Any) -> bool:
349-
"""Returns the equality of two instances of the StructReader class."""
349+
"""Return the equality of two instances of the StructReader class."""
350350
return (
351351
self.field_readers == other.field_readers and self.create_struct == other.create_struct
352352
if isinstance(other, StructReader)
353353
else False
354354
)
355355

356356
def __repr__(self) -> str:
357-
"""Returns the string representation of the StructReader class."""
357+
"""Return the string representation of the StructReader class."""
358358
return f"StructReader(({','.join(repr(field) for field in self.field_readers)}), {repr(self.create_struct)})"
359359

360360
def __hash__(self) -> int:
361-
"""Returns a hashed representation of the StructReader class."""
361+
"""Return a hashed representation of the StructReader class."""
362362
return self._hash
363363

364364

@@ -392,7 +392,7 @@ def skip(self, decoder: ReadableDecoder) -> None:
392392
_skip_map_array(decoder, lambda: self.element.skip(decoder))
393393

394394
def __hash__(self) -> int:
395-
"""Returns a hashed representation of the ListReader class."""
395+
"""Return a hashed representation of the ListReader class."""
396396
return self._hash
397397

398398

@@ -492,5 +492,5 @@ def skip() -> None:
492492
_skip_map_array(decoder, skip)
493493

494494
def __hash__(self) -> int:
495-
"""Returns a hashed representation of the MapReader class."""
495+
"""Return a hashed representation of the MapReader class."""
496496
return self._hash

pyiceberg/avro/resolver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
def construct_reader(
109109
file_schema: Union[Schema, IcebergType], read_types: Dict[int, Callable[..., StructProtocol]] = EMPTY_DICT
110110
) -> Reader:
111-
"""Constructs a reader from a file schema.
111+
"""Construct a reader from a file schema.
112112
113113
Args:
114114
file_schema (Schema | IcebergType): The schema of the Avro file.
@@ -120,7 +120,7 @@ def construct_reader(
120120

121121

122122
def construct_writer(file_schema: Union[Schema, IcebergType]) -> Writer:
123-
"""Constructs a writer from a file schema.
123+
"""Construct a writer from a file schema.
124124
125125
Args:
126126
file_schema (Schema | IcebergType): The schema of the Avro file.
@@ -132,7 +132,7 @@ def construct_writer(file_schema: Union[Schema, IcebergType]) -> Writer:
132132

133133

134134
class ConstructWriter(SchemaVisitorPerPrimitiveType[Writer]):
135-
"""Constructs a writer tree from an Iceberg schema."""
135+
"""Construct a writer tree from an Iceberg schema."""
136136

137137
def schema(self, schema: Schema, struct_result: Writer) -> Writer:
138138
return struct_result
@@ -198,7 +198,7 @@ def resolve(
198198
read_types: Dict[int, Callable[..., StructProtocol]] = EMPTY_DICT,
199199
read_enums: Dict[int, Callable[..., Enum]] = EMPTY_DICT,
200200
) -> Reader:
201-
"""Resolves the file and read schema to produce a reader.
201+
"""Resolve the file and read schema to produce a reader.
202202
203203
Args:
204204
file_schema (Schema | IcebergType): The schema of the Avro file.

pyiceberg/avro/writer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def write(self, encoder: BinaryEncoder, val: Any) -> Any:
4545
...
4646

4747
def __repr__(self) -> str:
48-
"""Returns string representation of this object."""
48+
"""Return string representation of this object."""
4949
return f"{self.__class__.__name__}()"
5050

5151

@@ -116,11 +116,11 @@ def write(self, encoder: BinaryEncoder, val: bytes) -> None:
116116
encoder.write(val)
117117

118118
def __len__(self) -> int:
119-
"""Returns the length of this object."""
119+
"""Return the length of this object."""
120120
return self._len
121121

122122
def __repr__(self) -> str:
123-
"""Returns string representation of this object."""
123+
"""Return string representation of this object."""
124124
return f"FixedWriter({self._len})"
125125

126126

@@ -140,7 +140,7 @@ def write(self, encoder: BinaryEncoder, val: Any) -> None:
140140
return encoder.write(decimal_to_bytes(val, byte_length=decimal_required_bytes(self.precision)))
141141

142142
def __repr__(self) -> str:
143-
"""Returns string representation of this object."""
143+
"""Return string representation of this object."""
144144
return f"DecimalWriter({self.precision}, {self.scale})"
145145

146146

@@ -165,15 +165,15 @@ def write(self, encoder: BinaryEncoder, val: StructType) -> None:
165165
writer.write(encoder, value)
166166

167167
def __eq__(self, other: Any) -> bool:
168-
"""Implements the equality operator for this object."""
168+
"""Implement the equality operator for this object."""
169169
return self.field_writers == other.field_writers if isinstance(other, StructWriter) else False
170170

171171
def __repr__(self) -> str:
172-
"""Returns string representation of this object."""
172+
"""Return string representation of this object."""
173173
return f"StructWriter({','.join(repr(field) for field in self.field_writers)})"
174174

175175
def __hash__(self) -> int:
176-
"""Returns the hash of the writer as hash of this object."""
176+
"""Return the hash of the writer as hash of this object."""
177177
return hash(self.field_writers)
178178

179179

0 commit comments

Comments
 (0)