Skip to content

Commit

Permalink
remove unnecessary and rewrite it using list in providers (#33763)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala committed Aug 26, 2023
1 parent e4ae83d commit 353b148
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/sensors/s3.py
Expand Up @@ -120,7 +120,7 @@ def _check_key(self, key):
return False

# Reduce the set of metadata to size only
files = list(map(lambda f: {"Size": f["Size"]}, key_matches))
files = [{"Size": f["Size"]} for f in key_matches]
else:
obj = self.hook.head_object(key, bucket_name)
if obj is None:
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/elasticsearch/log/es_response.py
Expand Up @@ -38,7 +38,7 @@ def __getitem__(self, k):
return _wrap(val)

def __iter__(self):
return map(lambda i: _wrap(i), self._l_)
return (_wrap(i) for i in self._l_)

def __bool__(self):
return bool(self._l_)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/sql_to_gcs.py
Expand Up @@ -235,7 +235,7 @@ def _write_local_data_files(self, cursor):
names in GCS, and values are file handles to local files that
contain the data for the GCS objects.
"""
org_schema = list(map(lambda schema_tuple: schema_tuple[0], cursor.description))
org_schema = [schema_tuple[0] for schema_tuple in cursor.description]
schema = [column for column in org_schema if column not in self.exclude_columns]

col_type_dict = self._get_col_type_dict()
Expand Down
Expand Up @@ -87,7 +87,7 @@ def _write_temp_file(self, cursor: Any, path_to_save: str | bytes | int) -> None
quotechar=self.quotechar,
quoting=self.quoting,
)
csv_writer.writerow(map(lambda field: field[0], cursor.description))
csv_writer.writerow(field[0] for field in cursor.description)
csv_writer.writerows(cursor)
csvfile.flush()

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/oracle/transfers/oracle_to_oracle.py
Expand Up @@ -69,7 +69,7 @@ def _execute(self, src_hook, dest_hook, context) -> None:
cursor = src_conn.cursor()
self.log.info("Querying data from source: %s", self.oracle_source_conn_id)
cursor.execute(self.source_sql, self.source_sql_params)
target_fields = list(map(lambda field: field[0], cursor.description))
target_fields = [field[0] for field in cursor.description]

rows_total = 0
for rows in iter(lambda: cursor.fetchmany(self.rows_chunk), []):
Expand Down

0 comments on commit 353b148

Please sign in to comment.