Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions python/ee/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,17 @@ def list() -> list[Task]:
def __repr__(self) -> str:
"""Returns a string representation of the task."""
if self.config and self.id:
return '<Task {} {}: {} ({})>'.format(
self.id, self.task_type, self.config['description'], self.state
return (
f"<Task {self.id} {self.task_type}: {self.config['description']}"
f' ({self.state})>'
)
elif self.config:
return '<Task {}: {} ({})>'.format(
self.task_type, self.config['description'], self.state
return (
f'<Task {self.task_type}:'
f" {self.config['description']} ({self.state})>"
)
else:
return '<Task "%s">' % self.id
return f'<Task "{self.id}">'


class Export:
Expand Down Expand Up @@ -1233,7 +1235,9 @@ def _prepare_image_export_config(
if config:
if 'skipEmptyTiles' in config:
raise ValueError('skipEmptyTiles is only supported for GeoTIFF exports.')
raise ee_exception.EEException(f'Unknown configuration options: {config}.')
raise ee_exception.EEException(
f'Unknown configuration options: {config!r}.'
)

return request

Expand Down Expand Up @@ -1897,8 +1901,9 @@ def build_ingestion_time_parameters(

if input_params:
raise ee_exception.EEException(
'The following keys are unrecognized in the ingestion parameters: %s' %
list(input_params.keys()))
'The following keys are unrecognized in the ingestion parameters:'
f' {list(input_params.keys())}'
)
return output_params


Expand Down Expand Up @@ -1980,7 +1985,7 @@ def canonicalize_name(a, b):
"""Renames config[a] to config[b]."""
if a in config:
if b in config:
raise ee_exception.EEException(collision_error.format(a, b))
raise ee_exception.EEException(f'Both {a} and {b} are specified.')
config[b] = config.pop(a)

canonicalize_name('crsTransform', 'crs_transform')
Expand Down Expand Up @@ -2046,16 +2051,16 @@ def _canonicalize_region(
if isinstance(region, str):
try:
region = json.loads(region)
except json.JSONDecodeError:
raise region_error # pylint: disable=raise-missing-from
except json.JSONDecodeError as e:
raise region_error from e

# It's probably a list of coordinates - attempt to parse as a LineString or
# Polygon.
try:
region = geometry.Geometry.LineString(region)
except:
except Exception:
try:
region = geometry.Geometry.Polygon(region)
except:
raise region_error # pylint: disable=raise-missing-from
except Exception as e:
raise region_error from e
return region
Loading