diff --git a/python/ee/batch.py b/python/ee/batch.py index ef4c86c0f..c196682b8 100644 --- a/python/ee/batch.py +++ b/python/ee/batch.py @@ -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 ''.format( - self.id, self.task_type, self.config['description'], self.state + return ( + f"' ) elif self.config: - return ''.format( - self.task_type, self.config['description'], self.state + return ( + f'" ) else: - return '' % self.id + return f'' class Export: @@ -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 @@ -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 @@ -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') @@ -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