Skip to content

Commit 1dba055

Browse files
committed
remove noqa: E731
1 parent 8234954 commit 1dba055

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

pyiceberg/io/pyarrow.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
from pyiceberg.utils.deprecated import deprecation_message
187187
from pyiceberg.utils.properties import (
188188
filter_properties,
189+
get_first_property_value_with_tracking,
189190
properties_with_prefix,
190191
property_as_bool,
191192
property_as_int,
@@ -427,14 +428,6 @@ def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSyste
427428
else:
428429
raise ValueError(f"Unrecognized filesystem type in URI: {scheme}")
429430

430-
def _get_first_property_value_with_tracking(self, props: Properties, used_keys: set[str], *keys: str) -> Optional[Any]:
431-
"""Tracks all candidate keys and returns the first value found."""
432-
used_keys.update(keys)
433-
for key in keys:
434-
if key in props:
435-
return props[key]
436-
return None
437-
438431
def _convert_str_to_bool(self, value: Any) -> bool:
439432
"""Convert string or other value to boolean, handling string representations properly."""
440433
if isinstance(value, str):
@@ -480,7 +473,10 @@ def _initialize_oss_fs(self) -> FileSystem:
480473

481474
properties = filter_properties(self.properties, key_predicate=lambda k: k.startswith(("s3.", "client.")))
482475
used_keys: set[str] = set()
483-
get = lambda *keys: self._get_first_property_value_with_tracking(properties, used_keys, *keys) # noqa: E731
476+
477+
def get(*keys: str) -> str | None:
478+
return get_first_property_value_with_tracking(properties, used_keys, *keys)
479+
484480
client_kwargs: Properties = {}
485481

486482
if endpoint := get(S3_ENDPOINT, "s3.endpoint_override"):
@@ -522,7 +518,10 @@ def _initialize_s3_fs(self, netloc: Optional[str]) -> FileSystem:
522518

523519
properties = filter_properties(self.properties, key_predicate=lambda k: k.startswith(("s3.", "client.")))
524520
used_keys: set[str] = set()
525-
get = lambda *keys: self._get_first_property_value_with_tracking(properties, used_keys, *keys) # noqa: E731
521+
522+
def get(*keys: str) -> str | None:
523+
return get_first_property_value_with_tracking(properties, used_keys, *keys)
524+
526525
client_kwargs: Properties = {}
527526

528527
# Handle S3 region configuration with optional auto-resolution
@@ -575,7 +574,10 @@ def _initialize_azure_fs(self) -> FileSystem:
575574

576575
properties = filter_properties(self.properties, key_predicate=lambda k: k.startswith("adls."))
577576
used_keys: set[str] = set()
578-
get = lambda *keys: self._get_first_property_value_with_tracking(properties, used_keys, *keys) # noqa: E731
577+
578+
def get(*keys: str) -> str | None:
579+
return get_first_property_value_with_tracking(properties, used_keys, *keys)
580+
579581
client_kwargs: Properties = {}
580582

581583
if account_name := get(ADLS_ACCOUNT_NAME, "adls.account_name"):
@@ -612,7 +614,10 @@ def _initialize_hdfs_fs(self, scheme: str, netloc: Optional[str]) -> FileSystem:
612614

613615
properties = filter_properties(self.properties, key_predicate=lambda k: k.startswith("hdfs."))
614616
used_keys: set[str] = set()
615-
get = lambda *keys: self._get_first_property_value_with_tracking(properties, used_keys, *keys) # noqa: E731
617+
618+
def get(*keys: str) -> str | None:
619+
return get_first_property_value_with_tracking(properties, used_keys, *keys)
620+
616621
client_kwargs: Properties = {}
617622

618623
if host := get(HDFS_HOST):
@@ -635,7 +640,10 @@ def _initialize_gcs_fs(self) -> FileSystem:
635640

636641
properties = filter_properties(self.properties, key_predicate=lambda k: k.startswith("gcs."))
637642
used_keys: set[str] = set()
638-
get = lambda *keys: self._get_first_property_value_with_tracking(properties, used_keys, *keys) # noqa: E731
643+
644+
def get(*keys: str) -> str | None:
645+
return get_first_property_value_with_tracking(properties, used_keys, *keys)
646+
639647
client_kwargs: Properties = {}
640648

641649
if access_token := get(GCS_TOKEN, "gcs.access_token"):

pyiceberg/utils/properties.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ def get_first_property_value(
7979
return None
8080

8181

82+
def get_first_property_value_with_tracking(props: Properties, used_keys: set[str], *keys: str) -> Optional[Any]:
83+
"""Tracks all candidate keys and returns the first value found."""
84+
used_keys.update(keys)
85+
for key in keys:
86+
if key in props:
87+
return props[key]
88+
return None
89+
90+
8291
def get_header_properties(
8392
properties: Properties,
8493
) -> Properties:

0 commit comments

Comments
 (0)