diff --git a/python/ee/__init__.py b/python/ee/__init__.py index fb3fd0173..09dccea5e 100644 --- a/python/ee/__init__.py +++ b/python/ee/__init__.py @@ -10,7 +10,7 @@ import inspect import os import re -from typing import Any, Hashable, List as ListType, Optional, Sequence, Tuple, Type, Union +from typing import Any, Hashable, Optional, Sequence, Union from ee import _utils from ee import batch @@ -64,7 +64,7 @@ _HAS_DYNAMIC_ATTRIBUTES = True # A list of autogenerated class names added by _InitializeGeneratedClasses. -_generatedClasses: ListType[str] = [] +_generatedClasses: list[str] = [] NO_PROJECT_EXCEPTION = ('ee.Initialize: no project found. Call with project=' ' or see http://goo.gle/ee-auth.') @@ -434,7 +434,7 @@ def _InitializeGeneratedClasses() -> None: types._registerClasses(globals()) # pylint: disable=protected-access -def _MakeClass(name: str) -> Type[Any]: +def _MakeClass(name: str) -> type[Any]: """Generates a dynamic API class for a given name.""" def init(self, *args, **kwargs): diff --git a/python/ee/_arg_types.py b/python/ee/_arg_types.py index 9751bda4b..71d9d9892 100644 --- a/python/ee/_arg_types.py +++ b/python/ee/_arg_types.py @@ -2,7 +2,7 @@ from __future__ import annotations import datetime -from typing import Any as AnyType, Dict, List as ListType, Sequence, Tuple, Union +from typing import Any as AnyType, Sequence, Union from ee import classifier from ee import clusterer @@ -27,7 +27,7 @@ Array = Union[ AnyType, - ListType[AnyType], + list[AnyType], ee_array.Array, ee_list.List, computedobject.ComputedObject, @@ -43,7 +43,7 @@ ] DateRange = Union[daterange.DateRange, computedobject.ComputedObject] Dictionary = Union[ - Dict[AnyType, AnyType], + dict[AnyType, AnyType], Sequence[AnyType], dictionary.Dictionary, computedobject.ComputedObject, @@ -68,9 +68,9 @@ Integer = Union[int, ee_number.Number, computedobject.ComputedObject] Kernel = Union[kernel.Kernel, computedobject.ComputedObject] List = Union[ - ListType[AnyType], - Tuple[()], - Tuple[AnyType, AnyType], + list[AnyType], + tuple[()], + tuple[AnyType, AnyType], ee_list.List, computedobject.ComputedObject, ] diff --git a/python/ee/_cloud_api_utils.py b/python/ee/_cloud_api_utils.py index a808616f4..788298c2e 100644 --- a/python/ee/_cloud_api_utils.py +++ b/python/ee/_cloud_api_utils.py @@ -11,7 +11,7 @@ import json import os import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union +from typing import Any, Callable, Optional, Sequence, Union import warnings import google_auth_httplib2 @@ -54,10 +54,10 @@ def request( # pylint: disable=invalid-name uri: str, method: str = 'GET', body: Optional[str] = None, - headers: Optional[Dict[str, str]] = None, + headers: Optional[dict[str, str]] = None, redirections: Optional[int] = None, - connection_type: Optional[Type[Any]] = None, - ) -> Tuple[httplib2.Response, Any]: + connection_type: Optional[type[Any]] = None, + ) -> tuple[httplib2.Response, Any]: """Makes an HTTP request using httplib2 semantics.""" del connection_type # Ignored del redirections # Ignored @@ -84,7 +84,7 @@ def request( # pylint: disable=invalid-name def _wrap_request( - headers_supplier: Callable[[], Dict[str, Any]], + headers_supplier: Callable[[], dict[str, Any]], response_inspector: Callable[[Any], None], ) -> Callable[..., http.HttpRequest]: """Builds a callable that wraps an API request. @@ -146,7 +146,7 @@ def build_cloud_resource( api_key: Optional[str] = None, credentials: Optional[Any] = None, timeout: Optional[float] = None, - headers_supplier: Optional[Callable[[], Dict[str, Any]]] = None, + headers_supplier: Optional[Callable[[], dict[str, Any]]] = None, response_inspector: Optional[Callable[[Any], None]] = None, http_transport: Optional[Any] = None, raw: Optional[bool] = False, @@ -252,12 +252,12 @@ def build_cloud_resource_from_document( def _convert_dict( - to_convert: Dict[str, Any], - conversions: Dict[str, Any], - defaults: Optional[Dict[str, Any]] = None, + to_convert: dict[str, Any], + conversions: dict[str, Any], + defaults: Optional[dict[str, Any]] = None, key_warnings: bool = False, retain_keys: bool = False, -) -> Dict[str, Any]: +) -> dict[str, Any]: """Applies a set of conversion rules to a dict. Args: @@ -290,7 +290,7 @@ def _convert_dict( The "to_convert" dict with keys renamed, values converted, and defaults added. """ - result: Dict[str, Any] = {} + result: dict[str, Any] = {} for key, value in to_convert.items(): if key in conversions: conversion = conversions[key] @@ -315,7 +315,7 @@ def _convert_dict( def _convert_value( - value: str, conversions: Dict[str, Any], default: Any) -> Any: + value: str, conversions: dict[str, Any], default: Any) -> Any: """Converts a value using a set of value mappings. Args: @@ -374,7 +374,7 @@ def _convert_bounding_box_to_geo_json(bbox: Sequence[float]) -> str: lng_min, lat_min, lng_max, lat_max)) -def convert_get_list_params_to_list_assets_params(params) -> Dict[str, Any]: +def convert_get_list_params_to_list_assets_params(params) -> dict[str, Any]: """Converts a getList params dict to something usable with listAssets.""" params = _convert_dict( params, { @@ -393,7 +393,7 @@ def convert_get_list_params_to_list_assets_params(params) -> Dict[str, Any]: return convert_list_images_params_to_list_assets_params(params) -def convert_list_assets_result_to_get_list_result(result) -> List[Any]: +def convert_list_assets_result_to_get_list_result(result) -> list[Any]: """Converts a listAssets result to something getList can return.""" if 'assets' not in result: return [] @@ -444,8 +444,8 @@ def _convert_list_images_filter_params_to_list_assets_params(params) -> str: def convert_list_images_params_to_list_assets_params( - params: Dict[str, Any] -) -> Dict[str, Any]: + params: dict[str, Any] +) -> dict[str, Any]: """Converts a listImages params dict to something usable with listAssets.""" params = params.copy() extra_filters = _convert_list_images_filter_params_to_list_assets_params( @@ -462,14 +462,14 @@ def is_asset_root(asset_name: str) -> bool: return bool(re.match(ASSET_ROOT_PATTERN, asset_name)) -def convert_list_images_result_to_get_list_result(result) -> List[Any]: +def convert_list_images_result_to_get_list_result(result) -> list[Any]: """Converts a listImages result to something getList can return.""" if 'images' not in result: return [] return [_convert_image_for_get_list_result(i) for i in result['images']] -def _convert_asset_for_get_list_result(asset) -> Dict[str, Any]: +def _convert_asset_for_get_list_result(asset) -> dict[str, Any]: """Converts an EarthEngineAsset to the format returned by getList.""" result = _convert_dict( asset, { @@ -480,7 +480,7 @@ def _convert_asset_for_get_list_result(asset) -> Dict[str, Any]: return result -def _convert_image_for_get_list_result(asset) -> Dict[str, Any]: +def _convert_image_for_get_list_result(asset) -> dict[str, Any]: """Converts an Image to the format returned by getList.""" result = _convert_dict( asset, { @@ -531,7 +531,7 @@ def convert_asset_id_to_asset_name(asset_id: str) -> str: return 'projects/earthengine-public/assets/{}'.format(asset_id) -def split_asset_name(asset_name: str) -> Tuple[str, str]: +def split_asset_name(asset_name: str) -> tuple[str, str]: """Splits an asset name into the parent and ID parts. Args: @@ -556,7 +556,7 @@ def convert_task_id_to_operation_name(task_id: str) -> str: return 'projects/{}/operations/{}'.format(_cloud_api_user_project, task_id) -def convert_params_to_image_manifest(params: Dict[str, Any]) -> Dict[str, Any]: +def convert_params_to_image_manifest(params: dict[str, Any]) -> dict[str, Any]: """Converts params to an ImageManifest for ingestion.""" return _convert_dict( params, { @@ -566,7 +566,7 @@ def convert_params_to_image_manifest(params: Dict[str, Any]) -> Dict[str, Any]: retain_keys=True) -def convert_params_to_table_manifest(params: Dict[str, Any]) -> Dict[str, Any]: +def convert_params_to_table_manifest(params: dict[str, Any]) -> dict[str, Any]: """Converts params to a TableManifest for ingestion.""" return _convert_dict( params, { @@ -576,7 +576,7 @@ def convert_params_to_table_manifest(params: Dict[str, Any]) -> Dict[str, Any]: retain_keys=True) -def convert_tilesets_to_one_platform_tilesets(tilesets: List[Any]) -> List[Any]: +def convert_tilesets_to_one_platform_tilesets(tilesets: list[Any]) -> list[Any]: """Converts a tileset to a one platform representation of a tileset.""" converted_tilesets = [] for tileset in tilesets: @@ -588,7 +588,7 @@ def convert_tilesets_to_one_platform_tilesets(tilesets: List[Any]) -> List[Any]: return converted_tilesets -def convert_sources_to_one_platform_sources(sources: List[Any]) -> List[Any]: +def convert_sources_to_one_platform_sources(sources: list[Any]) -> list[Any]: """Converts the sources to one platform representation of sources.""" converted_sources = [] for source in sources: @@ -607,7 +607,7 @@ def convert_sources_to_one_platform_sources(sources: List[Any]) -> List[Any]: return converted_sources -def encode_number_as_cloud_value(number: float) -> Dict[str, Union[float, str]]: +def encode_number_as_cloud_value(number: float) -> dict[str, Union[float, str]]: # Numeric values in constantValue-style nodes end up stored in doubles. If the # input is an integer that loses precision as a double, use the int64 slot # ("integerValue") in ValueNode. @@ -617,7 +617,7 @@ def encode_number_as_cloud_value(number: float) -> Dict[str, Union[float, str]]: return {'constantValue': number} -def convert_algorithms(algorithms) -> Dict[str, Any]: +def convert_algorithms(algorithms) -> dict[str, Any]: """Converts a ListAlgorithmsResult to the internal format. The internal code expects a dict mapping each algorithm's name to a dict @@ -645,7 +645,7 @@ def convert_algorithms(algorithms) -> Dict[str, Any]: return dict(_convert_algorithm(algorithm) for algorithm in algs) -def _convert_algorithm(algorithm: Dict[str, Any]) -> Tuple[str, Dict[str, Any]]: +def _convert_algorithm(algorithm: dict[str, Any]) -> tuple[str, dict[str, Any]]: """Converts an Algorithm to the internal format.""" # Strip leading 'algorithms/' from the name. algorithm_name = algorithm['name'][11:] @@ -669,11 +669,11 @@ def _convert_algorithm(algorithm: Dict[str, Any]) -> Tuple[str, Dict[str, Any]]: def _convert_algorithm_arguments( - args: List[Dict[str, Any]]) -> List[Dict[str, Any]]: + args: list[dict[str, Any]]) -> list[dict[str, Any]]: return [_convert_algorithm_argument(arg) for arg in args] -def _convert_algorithm_argument(arg: Dict[str, Any]) -> Dict[str, Any]: +def _convert_algorithm_argument(arg: dict[str, Any]) -> dict[str, Any]: return _convert_dict( arg, { 'argumentName': 'name', @@ -738,7 +738,7 @@ def convert_to_table_file_format(format_str: Optional[str]) -> str: return format_str -def convert_to_band_list(bands: Union[List[str], None, str]) -> List[str]: +def convert_to_band_list(bands: Union[list[str], None, str]) -> list[str]: """Converts a band list, possibly as CSV, to a real list of bands. Args: @@ -758,7 +758,7 @@ def convert_to_band_list(bands: Union[List[str], None, str]) -> List[str]: raise ee_exception.EEException('Invalid band list ' + bands) -def convert_to_visualization_options(params: Dict[str, Any]) -> Dict[str, Any]: +def convert_to_visualization_options(params: dict[str, Any]) -> dict[str, Any]: """Extracts a VisualizationOptions from a param dict. Args: @@ -821,14 +821,14 @@ def convert_to_visualization_options(params: Dict[str, Any]) -> Dict[str, Any]: return result -def _convert_csv_numbers_to_list(value: str) -> List[float]: +def _convert_csv_numbers_to_list(value: str) -> list[float]: """Converts a string containing CSV numbers to a list.""" if not value: return [] return [float(x) for x in value.split(',')] -def convert_operation_to_task(operation: Dict[str, Any]) -> Dict[str, Any]: +def convert_operation_to_task(operation: dict[str, Any]) -> dict[str, Any]: """Converts an Operation to a legacy Task.""" result = _convert_dict( operation['metadata'], { @@ -864,7 +864,7 @@ def _convert_operation_state_to_task_state(state: str) -> str: }, 'UNKNOWN') -def convert_iam_policy_to_acl(policy: Dict[str, Any]) -> Dict[str, Any]: +def convert_iam_policy_to_acl(policy: dict[str, Any]) -> dict[str, Any]: """Converts an IAM Policy proto to the legacy ACL format.""" bindings = { binding['role']: binding.get('members', []) @@ -884,7 +884,7 @@ def convert_iam_policy_to_acl(policy: Dict[str, Any]) -> Dict[str, Any]: return result -def convert_acl_to_iam_policy(acl: Dict[str, Any]) -> Dict[str, Any]: +def convert_acl_to_iam_policy(acl: dict[str, Any]) -> dict[str, Any]: """Converts the legacy ACL format to an IAM Policy proto.""" owners = acl.get('owners', []) readers = acl.get('readers', []) @@ -903,7 +903,7 @@ def convert_acl_to_iam_policy(acl: Dict[str, Any]) -> Dict[str, Any]: def convert_to_grid_dimensions( dimensions: Union[float, Sequence[float]] -) -> Dict[str, float]: +) -> dict[str, float]: """Converts an input value to GridDimensions. Args: diff --git a/python/ee/_helpers.py b/python/ee/_helpers.py index 335f2cf9c..2775b0452 100644 --- a/python/ee/_helpers.py +++ b/python/ee/_helpers.py @@ -10,7 +10,7 @@ import contextlib import json import sys -from typing import Any, Dict, Iterator, Optional, TextIO, Union +from typing import Any, Iterator, Optional, TextIO, Union from google.auth import crypt from google.oauth2 import service_account @@ -91,7 +91,7 @@ def call( # pylint: disable-next=redefined-builtin def apply( - func: Union[str, apifunction.ApiFunction], named_args: Dict[str, Any] + func: Union[str, apifunction.ApiFunction], named_args: dict[str, Any] ) -> computedobject.ComputedObject: """Call a function with a dictionary of named arguments. diff --git a/python/ee/apifunction.py b/python/ee/apifunction.py index c09b32d7b..6cc308d3a 100644 --- a/python/ee/apifunction.py +++ b/python/ee/apifunction.py @@ -18,7 +18,7 @@ import copy import keyword import re -from typing import Any, Dict, Optional, Set, Type +from typing import Any, Optional from ee import _utils from ee import computedobject @@ -31,17 +31,17 @@ class ApiFunction(function.Function): """An object representing an EE API Function.""" - _signature: Dict[str, Any] + _signature: dict[str, Any] # A dictionary of functions defined by the API server. - _api: Dict[str, ApiFunction] = {} + _api: dict[str, ApiFunction] = {} # A set of algorithm names containing all algorithms that have been bound to # a function so far using importApi(). - _bound_signatures: Set[str] = set() + _bound_signatures: set[str] = set() @_utils.accept_opt_prefix('opt_signature') - def __init__(self, name: str, signature: Optional[Dict[str, Any]] = None): + def __init__(self, name: str, signature: Optional[dict[str, Any]] = None): """Creates a function defined by the EE API. Args: @@ -84,7 +84,7 @@ def call_(cls, name: str, *args: Any, **kwargs: Any) -> Any: return cls.lookup(name).call(*args, **kwargs) @classmethod - def apply_(cls, name: str, named_args: Dict[str, Any]) -> Any: + def apply_(cls, name: str, named_args: dict[str, Any]) -> Any: """Call a named API function with a dictionary of named arguments. Args: @@ -101,23 +101,23 @@ def encode_invocation(self, encoder: Any) -> Any: del encoder # Unused. return self._signature['name'] - def encode_cloud_invocation(self, encoder: Any) -> Dict[str, Any]: + def encode_cloud_invocation(self, encoder: Any) -> dict[str, Any]: del encoder # Unused. return {'functionName': self._signature['name']} - def getSignature(self) -> Dict[str, Any]: + def getSignature(self) -> dict[str, Any]: """Returns a description of the interface provided by this function.""" return self._signature @classmethod - def allSignatures(cls) -> Dict[str, Dict[str, Any]]: + def allSignatures(cls) -> dict[str, dict[str, Any]]: """Returns a map from the name to signature for all API functions.""" cls.initialize() return dict([(name, func.getSignature()) for name, func in cls._api.items()]) @classmethod - def unboundFunctions(cls) -> Dict[str, Any]: + def unboundFunctions(cls) -> dict[str, Any]: """Returns the functions that have not been bound using importApi() yet.""" cls.initialize() return dict([(name, func) for name, func in cls._api.items() @@ -248,7 +248,7 @@ def MakeBoundFunction(func): setattr(target, fname, bound_function) @staticmethod - def clearApi(target: Type[Any]) -> None: + def clearApi(target: type[Any]) -> None: """Removes all methods added by importApi() from a target class. Args: diff --git a/python/ee/apitestcase.py b/python/ee/apitestcase.py index c85114728..d9ba203f5 100644 --- a/python/ee/apitestcase.py +++ b/python/ee/apitestcase.py @@ -3,7 +3,7 @@ import contextlib import json import os -from typing import Any, Dict, Iterable, Optional +from typing import Any, Iterable, Optional from googleapiclient import discovery @@ -13,10 +13,10 @@ # Cached algorithms list -_algorithms_cache: Optional[Dict[str, Any]] = None +_algorithms_cache: Optional[dict[str, Any]] = None -def GetAlgorithms() -> Dict[str, Any]: +def GetAlgorithms() -> dict[str, Any]: """Returns a static version of the ListAlgorithms call. After ApiTestCase.setUp is called, ee.data.getAlgorithms() is patched to use @@ -102,30 +102,30 @@ def InitializeApi(self): ee.Initialize(None, '') # We are mocking the url here so the unit tests are happy. - def _MockMapId(self, params: Dict[str, Any]) -> Dict[str, str]: + def _MockMapId(self, params: dict[str, Any]) -> dict[str, str]: self.last_mapid_call = {'url': '/mapid', 'data': params} return {'mapid': 'fakeMapId', 'token': 'fakeToken'} - def _MockDownloadUrl(self, params: Dict[str, Any]) -> Dict[str, str]: + def _MockDownloadUrl(self, params: dict[str, Any]) -> dict[str, str]: self.last_download_call = {'url': '/download', 'data': params} return {'docid': '1', 'token': '2'} def _MockThumbUrl( self, - params: Dict[str, Any], + params: dict[str, Any], # pylint: disable-next=invalid-name thumbType: Optional[str] = None, - ) -> Dict[str, str]: + ) -> dict[str, str]: del thumbType # Unused. # Hang on to the call arguments. self.last_thumb_call = {'url': '/thumb', 'data': params} return {'thumbid': '3', 'token': '4'} - def _MockTableDownload(self, params: Dict[str, Any]) -> Dict[str, str]: + def _MockTableDownload(self, params: dict[str, Any]) -> dict[str, str]: self.last_table_call = {'url': '/table', 'data': params} return {'docid': '5', 'token': '6'} - def _MockFetchDataCatalogStac(self) -> Dict[str, Any]: + def _MockFetchDataCatalogStac(self) -> dict[str, Any]: return {} diff --git a/python/ee/batch.py b/python/ee/batch.py index 73f83e208..626332844 100644 --- a/python/ee/batch.py +++ b/python/ee/batch.py @@ -12,7 +12,7 @@ import enum import json import re -from typing import Any, Dict, List, Optional, Sequence, Union +from typing import Any, Optional, Sequence, Union from ee import _cloud_api_utils from ee import data @@ -20,7 +20,7 @@ from ee import geometry -def _transform_operation_to_task(operation: Dict[str, Any]) -> Task: +def _transform_operation_to_task(operation: dict[str, Any]) -> Task: """Converts an operation to a task.""" status = _cloud_api_utils.convert_operation_to_task(operation) return Task( @@ -74,7 +74,7 @@ class ExportDestination(str, enum.Enum): FEATURE_VIEW = 'FEATURE_VIEW' BIGQUERY = 'BIGQUERY' - config: Optional[Dict[str, Any]] + config: Optional[dict[str, Any]] id: Optional[str] name: Optional[str] state: State @@ -88,7 +88,7 @@ def __init__( task_id: Optional[str], task_type: Type, state: State, - config: Optional[Dict[str, Any]] = None, + config: Optional[dict[str, Any]] = None, name: Optional[str] = None, ): """Creates a Task with the given ID and configuration. @@ -159,7 +159,7 @@ def start(self) -> None: result['name']) self.name = result['name'] - def status(self) -> Dict[str, Any]: + def status(self) -> dict[str, Any]: """Fetches the current status of the task. Returns: @@ -190,7 +190,7 @@ def cancel(self) -> None: data.cancelOperation(self.operation_name) @staticmethod - def list() -> List[Task]: + def list() -> list[Task]: """Returns the tasks submitted to EE by the current user. These include all currently running tasks as well as recently canceled or @@ -231,7 +231,7 @@ def __new__( cls, image: Any, description: str = 'myExportImageTask', - config: Optional[Dict[str, Any]] = None, + config: Optional[dict[str, Any]] = None, ): """Creates a task to export an EE Image to Google Drive or Cloud Storage. @@ -1127,8 +1127,8 @@ def toAsset(classifier, def _prepare_image_export_config( - image: Any, config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + image: Any, config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Performs all preparation steps for an image export. Args: @@ -1213,8 +1213,8 @@ def _prepare_image_export_config( def _prepare_map_export_config( - image: Any, config: Dict[str, Any] -) -> Dict[str, Any]: + image: Any, config: dict[str, Any] +) -> dict[str, Any]: """Performs all preparation steps for a map export. Args: @@ -1260,8 +1260,8 @@ def _prepare_map_export_config( def _prepare_table_export_config( - collection: Any, config: Dict[str, Any], export_destination -) -> Dict[str, Any]: + collection: Any, config: dict[str, Any], export_destination +) -> dict[str, Any]: """Performs all preparation steps for a table export. Args: @@ -1332,8 +1332,8 @@ def _prepare_table_export_config( def _prepare_video_export_config( - collection: Any, config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + collection: Any, config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Performs all preparation steps for a video export. Args: @@ -1375,8 +1375,8 @@ def _prepare_video_export_config( def _build_image_file_export_options( - config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Builds an ImageFileExportOptions from values in a config dict. Args: @@ -1480,8 +1480,8 @@ def _build_image_file_export_options( def _build_table_file_export_options( - config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Builds a TableFileExportOptions from values in a config dict. Args: @@ -1510,7 +1510,7 @@ def _build_table_file_export_options( return file_export_options -def _build_video_options(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_video_options(config: dict[str, Any]) -> dict[str, Any]: """Builds a VideoOptions from values in a config dict. Args: @@ -1533,8 +1533,8 @@ def _build_video_options(config: Dict[str, Any]) -> Dict[str, Any]: def _build_video_file_export_options( - config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Builds a VideoFileExportOptions from values in a config dict. Args: @@ -1564,8 +1564,8 @@ def _build_video_file_export_options( def _prepare_classifier_export_config( - classifier: Any, config: Dict[str, Any], export_destination: str -) -> Dict[str, Any]: + classifier: Any, config: dict[str, Any], export_destination: str +) -> dict[str, Any]: """Performs all preparation steps for a classifier export. Args: @@ -1595,7 +1595,7 @@ def _prepare_classifier_export_config( return request -def _build_drive_destination(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_drive_destination(config: dict[str, Any]) -> dict[str, Any]: """Builds a DriveDestination from values in a config dict. Args: @@ -1614,7 +1614,7 @@ def _build_drive_destination(config: Dict[str, Any]) -> Dict[str, Any]: return drive_destination -def _build_cloud_storage_destination(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_cloud_storage_destination(config: dict[str, Any]) -> dict[str, Any]: """Builds a CloudStorageDestination from values in a config dict. Args: @@ -1635,7 +1635,7 @@ def _build_cloud_storage_destination(config: Dict[str, Any]) -> Dict[str, Any]: return destination -def _build_bigquery_destination(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_bigquery_destination(config: dict[str, Any]) -> dict[str, Any]: """Builds a BigqueryDestination from values in a config dict. Args: @@ -1654,7 +1654,7 @@ def _build_bigquery_destination(config: Dict[str, Any]) -> Dict[str, Any]: return destination -def _build_tile_options(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_tile_options(config: dict[str, Any]) -> dict[str, Any]: """Builds a TileOptions from values in a config dict. Args: @@ -1697,7 +1697,7 @@ def _build_tile_options(config: Dict[str, Any]) -> Dict[str, Any]: return tile_options -def _build_earth_engine_destination(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_earth_engine_destination(config: dict[str, Any]) -> dict[str, Any]: """Builds an EarthEngineDestination from values in a config dict. Args: @@ -1715,7 +1715,7 @@ def _build_earth_engine_destination(config: Dict[str, Any]) -> Dict[str, Any]: } -def _build_feature_view_destination(config: Dict[str, Any]) -> Dict[str, Any]: +def _build_feature_view_destination(config: dict[str, Any]) -> dict[str, Any]: """Builds a FeatureViewDestination from values in a config dict. Args: @@ -1733,7 +1733,7 @@ def _build_feature_view_destination(config: Dict[str, Any]) -> Dict[str, Any]: return feature_view_destination -def _get_rank_by_one_thing_rule(rule_str: str) -> Dict[str, Any]: +def _get_rank_by_one_thing_rule(rule_str: str) -> dict[str, Any]: """Returns a RankByOneThingRule dict created from the rank-by-one-thing rule. Args: @@ -1771,8 +1771,8 @@ def _get_rank_by_one_thing_rule(rule_str: str) -> Dict[str, Any]: def _get_ranking_rule( - rules: Optional[Union[str, List[str]]] -) -> Optional[Dict[str, List[Dict[str, Any]]]]: + rules: Optional[Union[str, list[str]]] +) -> Optional[dict[str, list[dict[str, Any]]]]: """Returns a RankingRule dict created from the rank-by-one-thing rules. Args: @@ -1798,7 +1798,7 @@ def _get_ranking_rule( 'either be a comma-separated string or list of strings.')) -def _build_thinning_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]: +def _build_thinning_options(config: dict[str, Any]) -> Optional[dict[str, Any]]: """Returns a ThinningOptions dict created from the config. Args: @@ -1818,7 +1818,7 @@ def _build_thinning_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]: return output -def _build_ranking_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]: +def _build_ranking_options(config: dict[str, Any]) -> Optional[dict[str, Any]]: """Returns a RankingOptions dict created from the config. Args: @@ -1844,8 +1844,8 @@ def _build_ranking_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]: def build_ingestion_time_parameters( - input_params: Dict[str, Any] -) -> Dict[str, Any]: + input_params: dict[str, Any] +) -> dict[str, Any]: """Builds a FeatureViewIngestionTimeParameters from values in a params dict. Args: @@ -1873,7 +1873,7 @@ def build_ingestion_time_parameters( return output_params -def _create_export_task(config: Dict[str, Any], task_type: Task.Type) -> Task: +def _create_export_task(config: dict[str, Any], task_type: Task.Type) -> Task: """Creates an export task. Args: @@ -1888,7 +1888,7 @@ def _create_export_task(config: Dict[str, Any], task_type: Task.Type) -> Task: def _capture_parameters( all_locals, parameters_to_exclude: Sequence[str] -) -> Dict[str, Any]: +) -> dict[str, Any]: """Creates a parameter dict by copying all non-None locals. This is generally invoked as the first part of call processing, via diff --git a/python/ee/blob.py b/python/ee/blob.py index 779a273f0..8bf74fcb3 100644 --- a/python/ee/blob.py +++ b/python/ee/blob.py @@ -1,7 +1,7 @@ """A wrapper for Blobs.""" from __future__ import annotations -from typing import Any, Dict, Optional +from typing import Any, Optional from ee import _arg_types from ee import apifunction @@ -40,7 +40,7 @@ def __init__(self, url: _arg_types.String): """ self.initialize() - args: Dict[str, Any] = {'url': url} + args: dict[str, Any] = {'url': url} func = apifunction.ApiFunction(self.name()) if isinstance(url, str): diff --git a/python/ee/collection.py b/python/ee/collection.py index 3e5f0a688..a4c8c67c3 100644 --- a/python/ee/collection.py +++ b/python/ee/collection.py @@ -6,7 +6,7 @@ from __future__ import annotations import datetime -from typing import Any, Callable, Dict, Optional, Type, Union +from typing import Any, Callable, Optional, Union from ee import _arg_types from ee import _utils @@ -37,7 +37,7 @@ class Collection(element.Element): def __init__( self, func: function.Function, - args: Dict[str, Any], + args: dict[str, Any], varName: Optional[str] = None, # pylint: disable=invalid-name ): """Constructs a collection by initializing its ComputedObject.""" @@ -390,7 +390,7 @@ def draw( ) @staticmethod - def elementType() -> Type[element.Element]: + def elementType() -> type[element.Element]: """Returns the type of the collection's elements.""" return element.Element @@ -461,7 +461,7 @@ def filterMetadata( return self.filter(ee_filter.Filter.metadata_(name, operator, value)) def filterBounds( - self, geometry: Union[Dict[str, Any], ee_geometry.Geometry] + self, geometry: Union[dict[str, Any], ee_geometry.Geometry] ) -> Any: """Shortcut to add a geometry filter to a collection. diff --git a/python/ee/computedobject.py b/python/ee/computedobject.py index 4cf4ec31b..3075fb584 100644 --- a/python/ee/computedobject.py +++ b/python/ee/computedobject.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Callable, Dict, Optional +from typing import Any, Callable, Optional from ee import _utils from ee import data @@ -48,7 +48,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass): mapping calls do not use the same variable name. """ func: Optional[Any] - args: Optional[Dict[str, Any]] + args: Optional[dict[str, Any]] varName: Optional[str] # pylint: disable=g-bad-name # Tell pytype not to worry about dynamic attributes. @@ -61,7 +61,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass): def __init__( self, func: Optional[Any], - args: Optional[Dict[str, Any]], + args: Optional[dict[str, Any]], varName: Optional[str] = None, # pylint: disable=g-bad-name ): """Creates a computed object. @@ -106,7 +106,7 @@ def getInfo(self) -> Optional[Any]: """ return data.computeValue(self) - def encode(self, encoder: Optional[Callable[..., Any]]) -> Dict[str, Any]: + def encode(self, encoder: Optional[Callable[..., Any]]) -> dict[str, Any]: """Encodes the object in a format compatible with Serializer.""" if self.isVariable(): return { @@ -135,7 +135,7 @@ def encode(self, encoder: Optional[Callable[..., Any]]) -> Dict[str, Any]: key: func } - def encode_cloud_value(self, encoder: Any) -> Dict[str, Any]: + def encode_cloud_value(self, encoder: Any) -> dict[str, Any]: if self.isVariable(): ref = self.varName if ref is None and isinstance( @@ -160,7 +160,7 @@ def encode_cloud_value(self, encoder: Any) -> Dict[str, Any]: invocation = self.func.encode_cloud_invocation(encoder) # Encode all arguments recursively. - encoded_args: Dict[str, Any] = {} + encoded_args: dict[str, Any] = {} for name in sorted(self.args): value = self.args[name] if value is not None: diff --git a/python/ee/confusionmatrix.py b/python/ee/confusionmatrix.py index 281762aba..f91d22b23 100644 --- a/python/ee/confusionmatrix.py +++ b/python/ee/confusionmatrix.py @@ -1,7 +1,7 @@ """A wrapper for ConfusionMatrices.""" from __future__ import annotations -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import apifunction @@ -57,7 +57,7 @@ def __init__( super().__init__(array.func, array.args, array.varName) return - args: Dict[str, Any] = {'array': array} + args: dict[str, Any] = {'array': array} if order is not None: args['order'] = order diff --git a/python/ee/customfunction.py b/python/ee/customfunction.py index c76391ae6..ff1c5494f 100644 --- a/python/ee/customfunction.py +++ b/python/ee/customfunction.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Callable, Dict, Optional +from typing import Any, Callable, Optional from ee import computedobject from ee import ee_exception @@ -20,9 +20,9 @@ class CustomFunction(function.Function, encodable.Encodable): """An object representing a custom EE Function.""" _body: Any - _signature: Dict[str, Any] + _signature: dict[str, Any] - def __init__(self, signature: Dict[str, Any], body: Any): + def __init__(self, signature: dict[str, Any], body: Any): """Creates a function defined by a given expression with unbound variables. The expression is created by evaluating the given function @@ -47,14 +47,14 @@ def __init__(self, signature: Dict[str, Any], body: Any): # The expression to evaluate. self._body = body(*variables) - def encode(self, encoder: Callable[[Any], Any]) -> Dict[str, Any]: + def encode(self, encoder: Callable[[Any], Any]) -> dict[str, Any]: return { 'type': 'Function', 'argumentNames': [x['name'] for x in self._signature['args']], 'body': encoder(self._body) } - def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> Dict[str, Any]: + def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> dict[str, Any]: return { 'functionDefinitionValue': { 'argumentNames': [x['name'] for x in self._signature['args']], @@ -62,15 +62,15 @@ def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> Dict[str, Any]: } } - def encode_invocation(self, encoder: Callable[[Any], Any]) -> Dict[str, Any]: + def encode_invocation(self, encoder: Callable[[Any], Any]) -> dict[str, Any]: return self.encode(encoder) def encode_cloud_invocation( self, encoder: Callable[[Any], Any] - ) -> Dict[str, Any]: + ) -> dict[str, Any]: return {'functionReference': encoder(self)} - def getSignature(self) -> Dict[str, Any]: + def getSignature(self) -> dict[str, Any]: """Returns a description of the interface provided by this function.""" return self._signature diff --git a/python/ee/data.py b/python/ee/data.py index e21fbb8d5..1b582abb1 100644 --- a/python/ee/data.py +++ b/python/ee/data.py @@ -9,7 +9,7 @@ import re import sys import threading -from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Union +from typing import Any, Callable, Iterator, Optional, Sequence, Union import uuid import warnings @@ -357,10 +357,10 @@ def _get_cloud_projects_raw() -> Any: return _cloud_api_resource_raw.projects() -def _make_request_headers() -> Optional[Dict[str, Any]]: +def _make_request_headers() -> Optional[dict[str, Any]]: """Adds headers based on client context.""" - headers: Dict[str, Any] = {} - client_version_header_values: List[Any] = [] + headers: dict[str, Any] = {} + client_version_header_values: list[Any] = [] if _cloud_api_client_version is not None: client_version_header_values.append('ee-py/' + _cloud_api_client_version) if _user_agent is not None: @@ -424,7 +424,7 @@ def _translate_cloud_exception( return ee_exception.EEException(http_error._get_reason()) # pylint: disable=protected-access -def _maybe_populate_workload_tag(body: Dict[str, Any]) -> None: +def _maybe_populate_workload_tag(body: dict[str, Any]) -> None: """Populates the workload tag on the request body passed in if applicable. Defaults to the workload tag set by ee.data.setWorkloadTag() or related @@ -554,7 +554,7 @@ def getAsset(asset_id: str) -> Any: @deprecation.Deprecated('Use listAssets or listImages') -def getList(params: Dict[str, Any]) -> Any: +def getList(params: dict[str, Any]) -> Any: """Get a list of contents for a collection asset. Args: @@ -575,8 +575,8 @@ def getList(params: Dict[str, Any]) -> Any: def listImages( - params: Union[str, Dict[str, Any]], -) -> Dict[str, Optional[List[Any]]]: + params: Union[str, dict[str, Any]], +) -> dict[str, Optional[list[Any]]]: """Returns the images in an image collection or folder. Args: @@ -613,7 +613,7 @@ def listImages( return images -def listAssets(params: Union[str, Dict[str, Any]]) -> Dict[str, List[Any]]: +def listAssets(params: Union[str, dict[str, Any]]) -> dict[str, list[Any]]: """Returns the assets in a folder. Args: @@ -685,7 +685,7 @@ def listBuckets(project: Optional[str] = None) -> Any: return _execute_cloud_call(_get_cloud_projects().listAssets(parent=project)) -def getMapId(params: Dict[str, Any]) -> Dict[str, Any]: +def getMapId(params: dict[str, Any]) -> dict[str, Any]: """Get a Map ID for a given asset. Args: @@ -760,7 +760,7 @@ def getMapId(params: Dict[str, Any]) -> Dict[str, Any]: 'tile_fetcher': TileFetcher(url_format, map_name=map_name)} -def getFeatureViewTilesKey(params: Dict[str, Any]) -> Dict[str, Any]: +def getFeatureViewTilesKey(params: dict[str, Any]) -> dict[str, Any]: """Get a tiles key for a given map or asset. Args: @@ -799,7 +799,7 @@ def getFeatureViewTilesKey(params: Dict[str, Any]) -> Dict[str, Any]: } -def _extract_table_converter(params: Dict[str, Any]) -> Optional[Any]: +def _extract_table_converter(params: dict[str, Any]) -> Optional[Any]: if 'fileFormat' in params: file_format = params.get('fileFormat') converter = table_converter.from_file_format(file_format) @@ -810,7 +810,7 @@ def _extract_table_converter(params: Dict[str, Any]) -> Optional[Any]: def _extract_image_converter( - params: Dict[str, Any] + params: dict[str, Any] ) -> image_converter.ImageConverter: file_format = params.get('fileFormat') converter = image_converter.from_file_format(file_format) @@ -831,7 +831,7 @@ def _generate(func, list_key: str, **kwargs) -> Iterator[Any]: args['params'].update({'pageToken': response[_NEXT_PAGE_TOKEN_KEY]}) -def listFeatures(params: Dict[str, Any]) -> Any: +def listFeatures(params: dict[str, Any]) -> Any: """List features for a given table or FeatureView asset. Args: @@ -876,7 +876,7 @@ def call(params): return call(params) -def getPixels(params: Dict[str, Any]) -> Any: +def getPixels(params: dict[str, Any]) -> Any: """Fetches pixels from an image asset. Args: @@ -919,7 +919,7 @@ def getPixels(params: Dict[str, Any]) -> Any: return data -def computePixels(params: Dict[str, Any]) -> Any: +def computePixels(params: dict[str, Any]) -> Any: """Computes a tile by performing an arbitrary computation on image data. Args: @@ -959,7 +959,7 @@ def computePixels(params: Dict[str, Any]) -> Any: return data -def computeImages(params: Dict[str, Any]) -> Any: +def computeImages(params: dict[str, Any]) -> Any: """Computes a list of images by applying a computation to features. Args: @@ -985,7 +985,7 @@ def computeImages(params: Dict[str, Any]) -> Any: ) -def computeFeatures(params: Dict[str, Any]) -> Any: +def computeFeatures(params: dict[str, Any]) -> Any: """Computes a list of features by applying a computation to features. Args: @@ -1031,7 +1031,7 @@ def call(params): return call(params) -def getTileUrl(mapid: Dict[str, Any], x: float, y: float, z: float) -> str: +def getTileUrl(mapid: dict[str, Any], x: float, y: float, z: float) -> str: """Generate a URL for map tiles from a Map ID and coordinates. Args: @@ -1132,7 +1132,7 @@ def computeValue(obj: computedobject.ComputedObject) -> Any: @deprecation.Deprecated('Use getThumbId and makeThumbUrl') def getThumbnail( - params: Dict[str, Any], thumbType: Optional[str] = None + params: dict[str, Any], thumbType: Optional[str] = None ) -> Any: """Get a Thumbnail for a given asset. @@ -1167,8 +1167,8 @@ def getThumbnail( def getThumbId( - params: Dict[str, Any], thumbType: Optional[str] = None -) -> Dict[str, str]: + params: dict[str, Any], thumbType: Optional[str] = None +) -> dict[str, str]: """Get a Thumbnail ID for a given asset. Args: @@ -1251,7 +1251,7 @@ def getThumbId( return {'thumbid': result['name'], 'token': ''} -def makeThumbUrl(thumbId: Dict[str, str]) -> str: +def makeThumbUrl(thumbId: dict[str, str]) -> str: """Create a thumbnail URL from the given thumbid. Args: @@ -1267,7 +1267,7 @@ def makeThumbUrl(thumbId: Dict[str, str]) -> str: return url -def getDownloadId(params: Dict[str, Any]) -> Dict[str, str]: +def getDownloadId(params: dict[str, Any]) -> dict[str, str]: """Get a Download ID. Args: @@ -1383,7 +1383,7 @@ def getDownloadId(params: Dict[str, Any]) -> Dict[str, str]: return {'docid': result['name'], 'token': ''} -def makeDownloadUrl(downloadId: Dict[str, str]) -> str: +def makeDownloadUrl(downloadId: dict[str, str]) -> str: """Create a download URL from the given docid. Args: @@ -1396,7 +1396,7 @@ def makeDownloadUrl(downloadId: Dict[str, str]) -> str: downloadId['docid']) -def getTableDownloadId(params: Dict[str, Any]) -> Dict[str, str]: +def getTableDownloadId(params: dict[str, Any]) -> dict[str, str]: """Get a Download ID. Args: @@ -1445,7 +1445,7 @@ def getTableDownloadId(params: Dict[str, Any]) -> Dict[str, str]: return {'docid': result['name'], 'token': ''} -def makeTableDownloadUrl(downloadId: Dict[str, str]) -> str: +def makeTableDownloadUrl(downloadId: dict[str, str]) -> str: """Create a table download URL from a docid. Args: @@ -1499,10 +1499,10 @@ def inspect(response): @_utils.accept_opt_prefix('opt_path', 'opt_force', 'opt_properties') def createAsset( - value: Dict[str, Any], + value: dict[str, Any], path: Optional[str] = None, - properties: Optional[Dict[str, Any]] = None, -) -> Dict[str, Any]: + properties: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: """Creates an asset from a JSON value. To create an empty image collection or folder, pass in a "value" object @@ -1558,7 +1558,7 @@ def createAsset( ) -def createFolder(path: str) -> Dict[str, Any]: +def createFolder(path: str) -> dict[str, Any]: """Creates an asset folder. Returns a description of the newly created folder. @@ -1622,7 +1622,7 @@ def deleteAsset(assetId: str) -> None: _execute_cloud_call(_get_cloud_projects().assets().delete(name=name)) -def newTaskId(count: int = 1) -> List[str]: +def newTaskId(count: int = 1) -> list[str]: """Generate an ID for a long-running task. Args: @@ -1635,7 +1635,7 @@ def newTaskId(count: int = 1) -> List[str]: @deprecation.Deprecated('Use listOperations') -def getTaskList() -> List[Any]: +def getTaskList() -> list[Any]: """Retrieves a list of the user's tasks. Returns: @@ -1647,7 +1647,7 @@ def getTaskList() -> List[Any]: for o in listOperations()] -def listOperations(project: Optional[str] = None) -> List[Any]: +def listOperations(project: Optional[str] = None) -> list[Any]: """Retrieves a list of the user's tasks. Args: @@ -1674,7 +1674,7 @@ def listOperations(project: Optional[str] = None) -> List[Any]: @deprecation.Deprecated('Use getOperation') -def getTaskStatus(taskId: Union[List[str], str]) -> List[Any]: +def getTaskStatus(taskId: Union[list[str], str]) -> list[Any]: """Retrieve status of one or more long-running tasks. Args: @@ -1738,7 +1738,7 @@ def cancelOperation(operation_name: str) -> None: ) -def exportImage(request_id: str, params: Dict[str, Any]) -> Any: +def exportImage(request_id: str, params: dict[str, Any]) -> Any: """Starts an image export task running. This is a low-level method. The higher-level ee.batch.Export.image object @@ -1765,7 +1765,7 @@ def exportImage(request_id: str, params: Dict[str, Any]) -> Any: ) -def exportTable(request_id: str, params: Dict[str, Any]) -> Any: +def exportTable(request_id: str, params: dict[str, Any]) -> Any: """Starts a table export task running. This is a low-level method. The higher-level ee.batch.Export.table object @@ -1792,7 +1792,7 @@ def exportTable(request_id: str, params: Dict[str, Any]) -> Any: ) -def exportVideo(request_id: str, params: Dict[str, Any]) -> Any: +def exportVideo(request_id: str, params: dict[str, Any]) -> Any: """Starts a video export task running. This is a low-level method. The higher-level ee.batch.Export.video object @@ -1819,7 +1819,7 @@ def exportVideo(request_id: str, params: Dict[str, Any]) -> Any: ) -def exportMap(request_id: str, params: Dict[str, Any]) -> Any: +def exportMap(request_id: str, params: dict[str, Any]) -> Any: """Starts a map export task running. This is a low-level method. The higher-level ee.batch.Export.map object @@ -1846,7 +1846,7 @@ def exportMap(request_id: str, params: Dict[str, Any]) -> Any: ) -def exportClassifier(request_id: str, params: Dict[str, Any]) -> Any: +def exportClassifier(request_id: str, params: dict[str, Any]) -> Any: """Starts a classifier export task. This is a low-level method. The higher-level ee.batch.Export.classifier @@ -1874,7 +1874,7 @@ def exportClassifier(request_id: str, params: Dict[str, Any]) -> Any: def _prepare_and_run_export( - request_id: str, params: Dict[str, Any], export_endpoint: Any + request_id: str, params: dict[str, Any], export_endpoint: Any ) -> Any: """Starts an export task running. @@ -1910,8 +1910,8 @@ def _prepare_and_run_export( def startIngestion( - request_id: Any, params: Dict[str, Any], allow_overwrite: bool = False -) -> Dict[str, Any]: + request_id: Any, params: dict[str, Any], allow_overwrite: bool = False +) -> dict[str, Any]: """Creates an image asset import task. Args: @@ -1970,8 +1970,8 @@ def startIngestion( def startTableIngestion( - request_id: str, params: Dict[str, Any], allow_overwrite: bool = False -) -> Dict[str, Any]: + request_id: str, params: dict[str, Any], allow_overwrite: bool = False +) -> dict[str, Any]: """Creates a table asset import task. Args: @@ -2040,7 +2040,7 @@ def getAssetRoots() -> Any: listBuckets()) -def getAssetRootQuota(rootId: str) -> Dict[str, Any]: +def getAssetRootQuota(rootId: str) -> dict[str, Any]: """Returns quota usage details for the asset root with the given ID. Usage notes: @@ -2116,7 +2116,7 @@ def getIamPolicy(asset_id: str) -> Any: @deprecation.Deprecated('Use setIamPolicy') -def setAssetAcl(assetId: str, aclUpdate: Union[str, Dict[str, Any]]) -> None: +def setAssetAcl(assetId: str, aclUpdate: Union[str, dict[str, Any]]) -> None: """Sets the access control list of the asset with the given ID. The owner ACL cannot be changed, and the final ACL of the asset @@ -2152,7 +2152,7 @@ def setIamPolicy(asset_id: str, policy: Any) -> None: ) @deprecation.Deprecated('Use ee.data.updateAsset().') -def setAssetProperties(assetId: str, properties: Dict[str, Any]) -> None: +def setAssetProperties(assetId: str, properties: dict[str, Any]) -> None: """Sets metadata properties of the asset with the given ID. To delete a property, set its value to None. @@ -2217,7 +2217,7 @@ def _get_config_path() -> str: return f'{_get_projects_path()}/config' -def getProjectConfig() -> Dict[str, Any]: +def getProjectConfig() -> dict[str, Any]: """Gets the project config for the current project. Returns: @@ -2229,8 +2229,8 @@ def getProjectConfig() -> Dict[str, Any]: def updateProjectConfig( - project_config: Dict[str, Any], update_mask: Optional[Sequence[str]] = None -) -> Dict[str, Any]: + project_config: dict[str, Any], update_mask: Optional[Sequence[str]] = None +) -> dict[str, Any]: """Updates the project config for the current project. Args: diff --git a/python/ee/daterange.py b/python/ee/daterange.py index 07ec605d3..d91bbccb5 100644 --- a/python/ee/daterange.py +++ b/python/ee/daterange.py @@ -1,7 +1,7 @@ """A wrapper for DateRanges.""" from __future__ import annotations -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import apifunction @@ -58,7 +58,7 @@ def __init__( super().__init__(start.func, start.args, start.varName) return - args: Dict[str, Any] = {'start': start} + args: dict[str, Any] = {'start': start} if end is not None: args['end'] = end if timeZone is not None: diff --git a/python/ee/deprecation.py b/python/ee/deprecation.py index 3bf8de002..aab003dcb 100644 --- a/python/ee/deprecation.py +++ b/python/ee/deprecation.py @@ -7,7 +7,7 @@ import functools import inspect import json -from typing import Any, Callable, Dict, Optional +from typing import Any, Callable, Optional import urllib import warnings @@ -15,7 +15,7 @@ _DEPRECATED_ASSETS_URL = f'https://storage.googleapis.com/{_DEPRECATED_OBJECT}' # Deprecation warnings are per-asset, per-initialization. -deprecated_assets: Dict[str, DeprecatedAsset] = None +deprecated_assets: dict[str, DeprecatedAsset] = None def Deprecated(message: str): @@ -83,7 +83,7 @@ def _ParseDateString(cls, date_str: str) -> Optional[datetime.datetime]: return None @classmethod - def FromStacLink(cls, stac_link: Dict[str, Any]) -> DeprecatedAsset: + def FromStacLink(cls, stac_link: dict[str, Any]) -> DeprecatedAsset: removal_date = stac_link.get('gee:removal_date') if removal_date is not None: removal_date = cls._ParseDateString(removal_date) @@ -156,7 +156,7 @@ def Reset() -> None: deprecated_assets = None -def _FetchDataCatalogStac() -> Dict[str, Any]: +def _FetchDataCatalogStac() -> dict[str, Any]: try: response = urllib.request.urlopen(_DEPRECATED_ASSETS_URL).read() except (urllib.error.HTTPError, urllib.error.URLError): diff --git a/python/ee/dictionary.py b/python/ee/dictionary.py index aed82647e..1da7a9f6b 100644 --- a/python/ee/dictionary.py +++ b/python/ee/dictionary.py @@ -1,7 +1,7 @@ """A wrapper for dictionaries.""" from __future__ import annotations -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -26,7 +26,7 @@ class Dictionary(computedobject.ComputedObject): """An object to represent dictionaries.""" - _dictionary: Optional[Dict[Any, Any]] + _dictionary: Optional[dict[Any, Any]] _initialized = False diff --git a/python/ee/ee_array.py b/python/ee/ee_array.py index 50fbb3e5d..8a2907c5b 100644 --- a/python/ee/ee_array.py +++ b/python/ee/ee_array.py @@ -1,7 +1,7 @@ """A wrapper for Arrays.""" from __future__ import annotations -from typing import Any, Dict, Optional +from typing import Any, Optional from ee import _arg_types from ee import apifunction @@ -60,7 +60,7 @@ def __init__( super().__init__(values.func, values.args, values.varName) return - args: Dict[str, Any] = {'values': values} + args: dict[str, Any] = {'values': values} if pixelType is not None: args['pixelType'] = pixelType diff --git a/python/ee/ee_date.py b/python/ee/ee_date.py index dc8798e00..cfb63aa17 100644 --- a/python/ee/ee_date.py +++ b/python/ee/ee_date.py @@ -3,7 +3,7 @@ import datetime import math -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -50,7 +50,7 @@ def __init__( self.initialize() func = apifunction.ApiFunction(self.name()) - args: Dict[str, Any] + args: dict[str, Any] var_name = None if isinstance(date, datetime.datetime): args = {'value': diff --git a/python/ee/ee_list.py b/python/ee/ee_list.py index d64d3ea6e..46710a85b 100644 --- a/python/ee/ee_list.py +++ b/python/ee/ee_list.py @@ -1,8 +1,7 @@ """A wrapper for lists.""" from __future__ import annotations -# List clashes with the class List, so call it ListType -from typing import Any, List as ListType, Optional, Tuple, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -19,7 +18,7 @@ class List(computedobject.ComputedObject): """An object to represent lists.""" _list: Optional[ - Union[ListType[Any], Tuple[Any, Any]] + Union[list[Any], tuple[Any, Any]] ] _initialized = False diff --git a/python/ee/ee_types.py b/python/ee/ee_types.py index 2e5a87f41..42cc17754 100644 --- a/python/ee/ee_types.py +++ b/python/ee/ee_types.py @@ -4,7 +4,7 @@ # pylint: disable=g-bad-name import datetime -from typing import Any, Type +from typing import Any from ee import computedobject @@ -23,7 +23,7 @@ def _registerClasses(classes) -> None: _registered_classes = classes -def classToName(a_class: Type[Any]) -> str: +def classToName(a_class: type[Any]) -> str: """Converts a class to the API-friendly type name. Args: diff --git a/python/ee/element.py b/python/ee/element.py index 67196430a..e19f5faf2 100644 --- a/python/ee/element.py +++ b/python/ee/element.py @@ -6,7 +6,7 @@ from __future__ import annotations import datetime -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -30,7 +30,7 @@ class Element(computedobject.ComputedObject): def __init__( self, func: Optional[apifunction.ApiFunction], - args: Optional[Dict[str, Any]], + args: Optional[dict[str, Any]], varName: Optional[str] = None, # pylint: disable=g-bad-name ): """Constructs a collection by initializing its ComputedObject.""" @@ -122,7 +122,7 @@ def propertyNames(self) -> ee_list.List: def set( self, *args: Union[ - Dict[str, Any], + dict[str, Any], float, str, datetime.datetime, diff --git a/python/ee/errormargin.py b/python/ee/errormargin.py index 2cb919890..5bc1d4917 100644 --- a/python/ee/errormargin.py +++ b/python/ee/errormargin.py @@ -1,7 +1,7 @@ """A wrapper for ErrorMargins.""" from __future__ import annotations -from typing import Any, Dict, Optional +from typing import Any, Optional from ee import _arg_types from ee import apifunction @@ -64,7 +64,7 @@ def __init__( ): raise TypeError('value must be provided if unit is not infinite') - args: Dict[str, Any] = {} + args: dict[str, Any] = {} if value is not None: args['value'] = value if unit is not None: diff --git a/python/ee/feature.py b/python/ee/feature.py index 600598ce7..450087421 100644 --- a/python/ee/feature.py +++ b/python/ee/feature.py @@ -1,7 +1,7 @@ """An object representing EE Features.""" from __future__ import annotations -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -32,12 +32,12 @@ def __init__( Union[ Feature, geometry.Geometry, - Dict[str, Any], + dict[str, Any], computedobject.ComputedObject, ] ], properties: Optional[ - Union[Dict[str, Any], computedobject.ComputedObject] + Union[dict[str, Any], computedobject.ComputedObject] ] = None, ): """Creates a feature a geometry or computed object. @@ -113,8 +113,8 @@ def reset(cls) -> None: cls._initialized = False def getMapId( - self, vis_params: Optional[Dict[str, Any]] = None - ) -> Dict[str, Any]: + self, vis_params: Optional[dict[str, Any]] = None + ) -> dict[str, Any]: """Fetch and return a map id and token, suitable for use in a Map overlay. Args: diff --git a/python/ee/featurecollection.py b/python/ee/featurecollection.py index c341dce22..abdf1aef6 100644 --- a/python/ee/featurecollection.py +++ b/python/ee/featurecollection.py @@ -5,7 +5,7 @@ from __future__ import annotations -from typing import Any, Dict, List, Optional, Type, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import _utils @@ -36,8 +36,8 @@ def __init__( self, args: Optional[ Union[ - Dict[str, Any], - List[Any], + dict[str, Any], + list[Any], str, feature.Feature, geometry.Geometry, @@ -116,8 +116,8 @@ def reset(cls) -> None: cls._initialized = False def getMapId( - self, vis_params: Optional[Dict[str, Any]] = None - ) -> Dict[str, Any]: + self, vis_params: Optional[dict[str, Any]] = None + ) -> dict[str, Any]: """Fetch and return a map id and token, suitable for use in a Map overlay. Args: @@ -218,7 +218,7 @@ def name() -> str: return 'FeatureCollection' @staticmethod - def elementType() -> Type[feature.Feature]: + def elementType() -> type[feature.Feature]: return feature.Feature def classify( diff --git a/python/ee/function.py b/python/ee/function.py index d71dfe198..d70d6b7c0 100644 --- a/python/ee/function.py +++ b/python/ee/function.py @@ -1,7 +1,7 @@ """A base class for EE Functions.""" import textwrap -from typing import Any, Dict, Set +from typing import Any from ee import computedobject from ee import ee_exception @@ -31,7 +31,7 @@ def _registerPromoter(promoter): """ Function._promoter = staticmethod(promoter) - def getSignature(self) -> Dict[str, Any]: + def getSignature(self) -> dict[str, Any]: """Returns a description of the interface provided by this function. Returns: @@ -75,7 +75,7 @@ def apply(self, named_args): result = computedobject.ComputedObject(self, self.promoteArgs(named_args)) return Function._promoter(result, self.getReturnType()) - def promoteArgs(self, args: Dict[str, Any]) -> Dict[str, Any]: + def promoteArgs(self, args: dict[str, Any]) -> dict[str, Any]: """Promotes arguments to their types based on the function's signature. Verifies that all required arguments are provided and no unknown arguments @@ -95,8 +95,8 @@ def promoteArgs(self, args: Dict[str, Any]) -> Dict[str, Any]: arg_specs = signature['args'] # Promote all recognized args. - promoted_args: Dict[str, Any] = {} - known: Set[str] = set() + promoted_args: dict[str, Any] = {} + known: set[str] = set() for arg_spec in arg_specs: name = arg_spec['name'] if name in args: diff --git a/python/ee/geometry.py b/python/ee/geometry.py index 41c885658..16817a5da 100644 --- a/python/ee/geometry.py +++ b/python/ee/geometry.py @@ -5,7 +5,7 @@ import collections.abc import json import math -from typing import Any, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Optional, Sequence, Union from ee import _arg_types from ee import _utils @@ -36,7 +36,7 @@ class Geometry(computedobject.ComputedObject): @_utils.accept_opt_prefix('opt_proj', 'opt_geodesic', 'opt_evenOdd') def __init__( self, - geo_json: Union[Dict[str, Any], computedobject.ComputedObject, Geometry], + geo_json: Union[dict[str, Any], computedobject.ComputedObject, Geometry], proj: Optional[Any] = None, geodesic: Optional[bool] = None, evenOdd: Optional[bool] = None, # pylint: disable=g-bad-name @@ -147,7 +147,7 @@ def __init__( self._computed_equivalent = apifunction.ApiFunction.lookup( 'GeometryConstructors.' + ctor_name).apply(ctor_args) - def _get_name_from_crs(self, crs: Dict[str, Any]) -> str: + def _get_name_from_crs(self, crs: dict[str, Any]) -> str: """Returns projection name from a CRS.""" if isinstance(crs, dict) and crs.get('type') == 'name': properties = crs.get('properties') @@ -595,7 +595,7 @@ def MultiPolygon( return Geometry(Geometry._parseArgs('MultiPolygon', 4, all_args)) @_utils.accept_opt_prefix('opt_encoder') - def encode(self, encoder: Optional[Any] = None) -> Dict[str, Any]: + def encode(self, encoder: Optional[Any] = None) -> dict[str, Any]: """Returns a GeoJSON-compatible representation of the geometry.""" if not getattr(self, '_type', None): return super().encode(encoder) @@ -624,7 +624,7 @@ def encode_cloud_value(self, encoder: Any) -> Any: return self._computed_equivalent.encode_cloud_value(encoder) - def toGeoJSON(self) -> Dict[str, Any]: + def toGeoJSON(self) -> dict[str, Any]: """Returns a GeoJSON representation of the geometry.""" if self.func: raise ee_exception.EEException( @@ -654,7 +654,7 @@ def __repr__(self) -> str: return self.__str__() @staticmethod - def _isValidGeometry(geometry: Dict[str, Any]) -> bool: + def _isValidGeometry(geometry: dict[str, Any]) -> bool: """Check if a geometry looks valid. Args: @@ -747,7 +747,7 @@ def _coordinatesToLine(coordinates: Sequence[float]) -> Any: return line @staticmethod - def _parseArgs(ctor_name: str, depth: int, args: Any) -> Dict[str, Any]: + def _parseArgs(ctor_name: str, depth: int, args: Any) -> dict[str, Any]: """Parses arguments into a GeoJSON dictionary or a ComputedObject. Args: @@ -866,8 +866,8 @@ def _fixDepth(depth: int, coords: Any) -> Any: @staticmethod def _GetSpecifiedArgs( - args, keywords: Tuple[str, ...] = (), **kwargs - ) -> List[Any]: + args, keywords: tuple[str, ...] = (), **kwargs + ) -> list[Any]: """Returns args, filtering out _UNSPECIFIED and checking for keywords.""" if keywords: args = list(args) diff --git a/python/ee/image.py b/python/ee/image.py index 1e64b0b6b..ce8bac10c 100644 --- a/python/ee/image.py +++ b/python/ee/image.py @@ -7,7 +7,7 @@ from __future__ import annotations import json -from typing import Any, Dict, Optional, Sequence, Tuple +from typing import Any, Optional, Sequence from ee import _arg_types from ee import _utils @@ -142,7 +142,7 @@ def getInfo(self) -> Optional[Any]: """ return super().getInfo() - def getMapId(self, vis_params: Optional[Any] = None) -> Dict[str, Any]: + def getMapId(self, vis_params: Optional[Any] = None) -> dict[str, Any]: """Fetch and return a map ID dictionary, suitable for use in a Map overlay. Args: @@ -158,8 +158,8 @@ def getMapId(self, vis_params: Optional[Any] = None) -> Dict[str, Any]: return response def _apply_crs_and_affine( - self, params: Dict[str, Any] - ) -> Tuple[Any, Any, Any]: + self, params: dict[str, Any] + ) -> tuple[Any, Any, Any]: """Applies any CRS and affine parameters to an image. Wraps the image in a call to Reproject() if the request includes @@ -246,8 +246,8 @@ def _apply_crs_and_affine( return image, request, dimensions_consumed def _apply_selection_and_scale( - self, params: Dict[str, Any], dimensions_consumed: bool - ) -> Tuple[Any, Dict[str, Any]]: + self, params: dict[str, Any], dimensions_consumed: bool + ) -> tuple[Any, dict[str, Any]]: """Applies region selection and scaling parameters to an image. Wraps the image in a call to clipToBoundsAndScale() if there are any @@ -266,8 +266,8 @@ def _apply_selection_and_scale( """ keys_to_extract = set(['region', 'dimensions', 'scale']) scale_keys = ['maxDimension', 'height', 'width', 'scale'] - request: Dict[str, Any] = {} - selection_params: Dict[str, Any] = {} + request: dict[str, Any] = {} + selection_params: dict[str, Any] = {} if params: for key in params: if key not in keys_to_extract: @@ -322,8 +322,8 @@ def _apply_selection_and_scale( return image, request def _apply_spatial_transformations( - self, params: Dict[str, Any] - ) -> Tuple[Any, Dict[str, Any]]: + self, params: dict[str, Any] + ) -> tuple[Any, dict[str, Any]]: """Applies spatial transformation and clipping. Args: @@ -340,8 +340,8 @@ def _apply_spatial_transformations( return image._apply_selection_and_scale(params, dimensions_consumed) def _apply_visualization( - self, params: Dict[str, Any] - ) -> Tuple[Any, Dict[str, Any]]: + self, params: dict[str, Any] + ) -> tuple[Any, dict[str, Any]]: """Applies visualization parameters to an image. Wraps the image in a call to visualize() if there are any recognized @@ -373,7 +373,7 @@ def _apply_visualization( image = apifunction.ApiFunction.apply_('Image.visualize', vis_params) return image, request - def _build_download_id_image(self, params: Dict[str, Any]) -> Any: + def _build_download_id_image(self, params: dict[str, Any]) -> Any: """Processes the getDownloadId parameters and returns the built image. Given transformation parameters (crs, crs_transform, dimensions, scale, and @@ -395,7 +395,7 @@ def _build_download_id_image(self, params: Dict[str, Any]) -> Any: """ params = params.copy() - def _extract_and_validate_transforms(obj: Dict[str, Any]) -> Dict[str, Any]: + def _extract_and_validate_transforms(obj: dict[str, Any]) -> dict[str, Any]: """Takes a parameter dictionary and extracts the transformation keys.""" extracted = {} for key in ['crs', 'crs_transform', 'dimensions', 'region']: @@ -407,7 +407,7 @@ def _extract_and_validate_transforms(obj: Dict[str, Any]) -> Dict[str, Any]: extracted['scale'] = obj['scale'] return extracted - def _build_image_per_band(band_params: Dict[str, Any]) -> Any: + def _build_image_per_band(band_params: dict[str, Any]) -> Any: """Takes a band dictionary and builds an image for it.""" if 'id' not in band_params: raise ee_exception.EEException('Each band dictionary must have an id.') @@ -435,7 +435,7 @@ def _build_image_per_band(band_params: Dict[str, Any]) -> Any: del copy_params # Unused. return image - def prepare_for_export(self, params: Dict[str, Any]) -> Any: + def prepare_for_export(self, params: dict[str, Any]) -> Any: """Applies all relevant export parameters to an image. Args: @@ -449,7 +449,7 @@ def prepare_for_export(self, params: Dict[str, Any]) -> Any: """ return self._apply_spatial_transformations(params) - def getDownloadURL(self, params: Optional[Dict[str, Any]] = None) -> str: + def getDownloadURL(self, params: Optional[dict[str, Any]] = None) -> str: """Get a download URL for an image chunk. Generates a download URL for small chunks of image data in GeoTIFF or NumPy @@ -509,7 +509,7 @@ def getDownloadURL(self, params: Optional[Dict[str, Any]] = None) -> str: request['image'] = self return data.makeDownloadUrl(data.getDownloadId(request)) - def getThumbId(self, params: Dict[str, Any]) -> Dict[str, str]: + def getThumbId(self, params: dict[str, Any]) -> dict[str, str]: """Applies transformations and returns the thumbId. Args: @@ -534,7 +534,7 @@ def getThumbId(self, params: Dict[str, Any]) -> Dict[str, str]: params['image'] = image return data.getThumbId(params) - def getThumbURL(self, params: Optional[Dict[str, Any]] = None) -> str: + def getThumbURL(self, params: Optional[dict[str, Any]] = None) -> str: """Get a thumbnail URL for this image. Args: diff --git a/python/ee/image_converter.py b/python/ee/image_converter.py index 41ea7c1ec..1a6054950 100644 --- a/python/ee/image_converter.py +++ b/python/ee/image_converter.py @@ -1,7 +1,7 @@ """Converters used in the image data fetching methods.""" import io -from typing import Any, Dict, Optional, Type, Union +from typing import Any, Optional, Union class ImageConverter: @@ -43,7 +43,7 @@ def do_conversion(self, data: bytes) -> Any: return numpy.load(io.BytesIO(data)) -_PIXEL_DATA_CONVERTERS: Dict[str, Type[ImageConverter]] = { +_PIXEL_DATA_CONVERTERS: dict[str, type[ImageConverter]] = { 'NUMPY_NDARRAY': NumPyConverter } diff --git a/python/ee/imagecollection.py b/python/ee/imagecollection.py index c9e72bf71..39656d098 100644 --- a/python/ee/imagecollection.py +++ b/python/ee/imagecollection.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Callable, Dict, Optional, Sequence, Tuple +from typing import Any, Callable, Optional, Sequence from ee import _arg_types from ee import _utils @@ -87,7 +87,7 @@ def reset(cls) -> None: apifunction.ApiFunction.clearApi(cls) cls._initialized = False - def getMapId(self, vis_params: Optional[Any] = None) -> Dict[str, Any]: + def getMapId(self, vis_params: Optional[Any] = None) -> dict[str, Any]: """Fetch and return a Map ID. This mosaics the collection to a single image and return a map ID suitable @@ -188,7 +188,7 @@ def name() -> str: def elementType(): return image.Image - def getVideoThumbURL(self, params: Optional[Dict[str, Any]] = None) -> str: + def getVideoThumbURL(self, params: Optional[dict[str, Any]] = None) -> str: """Get the URL for an animated video thumbnail of the given collection. Note: Videos can only be created when the image visualization @@ -252,7 +252,7 @@ def getFilmstripThumbURL(self, params: Optional[Any] = None) -> str: def _getThumbURL( self, valid_formats: Sequence[str], - # TODO(user): Need to drop the default None and use Dict[str, Any]] + # TODO(user): Need to drop the default None and use dict[str, Any]] params: Optional[Any] = None, thumbType: Optional[str] = None, # pylint: disable=g-bad-name ) -> str: @@ -314,7 +314,7 @@ def map_function(input_image, input_params): def _apply_preparation_function( self, preparation_function: Callable[[Any, Any], Any], - params: Dict[str, Any], + params: dict[str, Any], ) -> Any: """Applies a preparation function to an ImageCollection. @@ -350,8 +350,8 @@ def apply_params(img): return self.map(apply_params), remaining_params def prepare_for_export( - self, params: Dict[str, Any] - ) -> Tuple[ImageCollection, Dict[str, Any]]: + self, params: dict[str, Any] + ) -> tuple[ImageCollection, dict[str, Any]]: """Applies all relevant export parameters to an ImageCollection. Args: diff --git a/python/ee/oauth.py b/python/ee/oauth.py index 908cd935e..823ad0bee 100644 --- a/python/ee/oauth.py +++ b/python/ee/oauth.py @@ -17,7 +17,7 @@ import shutil import subprocess import sys -from typing import Any, Dict, Optional, Sequence, Union +from typing import Any, Optional, Sequence, Union import urllib.error import urllib.parse import urllib.request @@ -86,7 +86,7 @@ def get_credentials_path() -> str: return cred_path -def get_credentials_arguments() -> Dict[str, Any]: +def get_credentials_arguments() -> dict[str, Any]: with open(get_credentials_path()) as creds: stored = json.load(creds) args = {} @@ -184,7 +184,7 @@ def request_token( return json.loads(response)['refresh_token'] -def write_private_json(json_path: str, info_dict: Dict[str, Any]) -> None: +def write_private_json(json_path: str, info_dict: dict[str, Any]) -> None: """Attempts to write the passed token to the given user directory.""" dirname = os.path.dirname(json_path) @@ -332,7 +332,7 @@ def _base64param(byte_string: bytes) -> bytes: return base64.urlsafe_b64encode(byte_string).rstrip(b'=') -def _nonce_table(*nonce_keys: str) -> Dict[str, str]: +def _nonce_table(*nonce_keys: str) -> dict[str, str]: """Makes random nonces, and adds PKCE challenges for each _verifier nonce.""" table = {} for key in nonce_keys: diff --git a/python/ee/pixeltype.py b/python/ee/pixeltype.py index 284663051..e3a59c822 100644 --- a/python/ee/pixeltype.py +++ b/python/ee/pixeltype.py @@ -1,7 +1,7 @@ """A wrapper for PixelTypes.""" from __future__ import annotations -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from ee import _arg_types from ee import apifunction @@ -72,7 +72,7 @@ def __init__( """ self.initialize() - args: Dict[str, Any] = {'precision': precision} + args: dict[str, Any] = {'precision': precision} if minValue is not None: args['minValue'] = minValue if maxValue is not None: diff --git a/python/ee/projection.py b/python/ee/projection.py index 5cf54b79f..54a696538 100644 --- a/python/ee/projection.py +++ b/python/ee/projection.py @@ -1,7 +1,7 @@ """A wrapper for Projections.""" from __future__ import annotations -from typing import Any, Dict, Optional, Sequence, Union +from typing import Any, Optional, Sequence, Union from ee import _arg_types from ee import apifunction @@ -80,7 +80,7 @@ def __init__( super().__init__(crs.func, crs.args, crs.varName) return - args: Dict[str, Any] = {'crs': crs} + args: dict[str, Any] = {'crs': crs} if transform is not None: args['transform'] = transform if transformWkt is not None: diff --git a/python/ee/serializer.py b/python/ee/serializer.py index ec473a46c..60d4c9f09 100644 --- a/python/ee/serializer.py +++ b/python/ee/serializer.py @@ -4,7 +4,7 @@ import datetime import hashlib import json -from typing import Any, Dict, List, Optional, Set +from typing import Any, Optional from ee import _cloud_api_utils from ee import _utils @@ -38,11 +38,11 @@ class Serializer: _is_compound: bool _for_cloud_api: bool # A list of shared subtrees as [name, value] pairs. - _scope: List[str] + _scope: list[str] # A lookup table from object hash to subtree names as stored in self._scope - _encoded: Dict[Any, Any] + _encoded: dict[Any, Any] # A lookup table from object ID as retrieved by id() to md5 hash values. - _hashcache: Dict[Any, Any] + _hashcache: dict[Any, Any] def __init__( self, @@ -380,7 +380,7 @@ def __init__(self, result: Any, values: Optional[Any] = None): def _is_compound(self) -> bool: return self._values is not None - def _find_single_uses(self) -> Set[Any]: + def _find_single_uses(self) -> set[Any]: """Finds the names of all named values that are referred to only once.""" reference_counts = collections.defaultdict(int) reference_counts[self._result] += 1 diff --git a/python/ee/table_converter.py b/python/ee/table_converter.py index e3810d214..5344bd9f6 100644 --- a/python/ee/table_converter.py +++ b/python/ee/table_converter.py @@ -1,6 +1,6 @@ """Converters used in the table data fetching methods.""" -from typing import Any, Dict, Iterator, List, Optional, Type, Union +from typing import Any, Iterator, Optional, Union class TableConverter: @@ -24,7 +24,7 @@ def do_conversion(self, features: Iterator[Any]) -> Any: def _convert_to_records( self, features: Iterator[Any] - ) -> Iterator[Dict[str, Any]]: + ) -> Iterator[dict[str, Any]]: for feature in features: yield { 'geo': feature.get('geometry'), @@ -46,12 +46,12 @@ def do_conversion(self, features: Iterator[Any]) -> Any: self._materialize_features(features) ) - def _materialize_features(self, features: Iterator[Any]) -> List[Any]: + def _materialize_features(self, features: Iterator[Any]) -> list[Any]: """Materializes the features, making several requests if necessary.""" return list(features) -_TABLE_DATA_CONVERTERS: Dict[str, Type[TableConverter]] = { +_TABLE_DATA_CONVERTERS: dict[str, type[TableConverter]] = { 'PANDAS_DATAFRAME': PandasConverter, 'GEOPANDAS_GEODATAFRAME': GeoPandasConverter, } diff --git a/python/ee/tests/blob_test.py b/python/ee/tests/blob_test.py index 8584197bd..bf0ba8d2f 100644 --- a/python/ee/tests/blob_test.py +++ b/python/ee/tests/blob_test.py @@ -2,7 +2,7 @@ """Test for the blob module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -12,8 +12,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/classifier_test.py b/python/ee/tests/classifier_test.py index c2c6d328e..eed0b86e5 100644 --- a/python/ee/tests/classifier_test.py +++ b/python/ee/tests/classifier_test.py @@ -3,7 +3,7 @@ import json import sys -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -33,8 +33,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/clusterer_test.py b/python/ee/tests/clusterer_test.py index 50517fe7e..1b7c1dc7c 100644 --- a/python/ee/tests/clusterer_test.py +++ b/python/ee/tests/clusterer_test.py @@ -3,7 +3,7 @@ import json import sys -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -28,8 +28,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/confusionmatrix_test.py b/python/ee/tests/confusionmatrix_test.py index 3ef2b221b..d314278fc 100644 --- a/python/ee/tests/confusionmatrix_test.py +++ b/python/ee/tests/confusionmatrix_test.py @@ -2,7 +2,7 @@ """Tests for the ee.ConfusionMatrix module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -26,8 +26,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/daterange_test.py b/python/ee/tests/daterange_test.py index c5a798bf8..e32c63bbe 100644 --- a/python/ee/tests/daterange_test.py +++ b/python/ee/tests/daterange_test.py @@ -6,7 +6,7 @@ import datetime import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -22,15 +22,15 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any] -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, } -def daterange_function_expr(value: int) -> Dict[str, Any]: +def daterange_function_expr(value: int) -> dict[str, Any]: return { 'functionInvocationValue': { 'functionName': 'DateRange', diff --git a/python/ee/tests/deprecation_test.py b/python/ee/tests/deprecation_test.py index c20b2980e..7abc0affa 100644 --- a/python/ee/tests/deprecation_test.py +++ b/python/ee/tests/deprecation_test.py @@ -3,7 +3,7 @@ import contextlib import datetime -from typing import Any, Dict +from typing import Any from unittest import mock import warnings @@ -170,7 +170,7 @@ def assertDoesNotWarn(self): yield # Overridden from apitestcase.ApiTestCase. - def _MockFetchDataCatalogStac(self) -> Dict[str, Any]: + def _MockFetchDataCatalogStac(self) -> dict[str, Any]: return _STAC_JSON def test_no_warnings_thrown(self): diff --git a/python/ee/tests/dictionary_test.py b/python/ee/tests/dictionary_test.py index ef9044a03..dff0182f6 100644 --- a/python/ee/tests/dictionary_test.py +++ b/python/ee/tests/dictionary_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Test for the ee.dictionary module.""" import json -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -10,8 +10,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/ee_array_test.py b/python/ee/tests/ee_array_test.py index a7c9603d5..18a18b915 100644 --- a/python/ee/tests/ee_array_test.py +++ b/python/ee/tests/ee_array_test.py @@ -2,7 +2,7 @@ """Tests for the ee.Array module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -24,8 +24,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/ee_date_test.py b/python/ee/tests/ee_date_test.py index c841847ed..602de0a60 100644 --- a/python/ee/tests/ee_date_test.py +++ b/python/ee/tests/ee_date_test.py @@ -3,7 +3,7 @@ import datetime import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -16,15 +16,15 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any] -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, } -def date_function_expr(value: int) -> Dict[str, Any]: +def date_function_expr(value: int) -> dict[str, Any]: return { 'functionInvocationValue': { 'functionName': 'Date', diff --git a/python/ee/tests/ee_list_test.py b/python/ee/tests/ee_list_test.py index 9dfddfc19..5b7ceed6b 100644 --- a/python/ee/tests/ee_list_test.py +++ b/python/ee/tests/ee_list_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Test for the ee.list module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -9,8 +9,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any] -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/ee_number_test.py b/python/ee/tests/ee_number_test.py index e22302f06..482fe78ca 100644 --- a/python/ee/tests/ee_number_test.py +++ b/python/ee/tests/ee_number_test.py @@ -2,7 +2,7 @@ """Test for the ee.number module.""" import json -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -11,8 +11,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/ee_string_test.py b/python/ee/tests/ee_string_test.py index 4ff718069..b04a9f75e 100644 --- a/python/ee/tests/ee_string_test.py +++ b/python/ee/tests/ee_string_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Test for the ee.string module.""" import json -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -10,8 +10,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any] -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/feature_test.py b/python/ee/tests/feature_test.py index 5c01994a5..60049b495 100644 --- a/python/ee/tests/feature_test.py +++ b/python/ee/tests/feature_test.py @@ -2,7 +2,7 @@ """Test for the ee.feature module.""" import json -from typing import Any, Dict +from typing import Any from unittest import mock import unittest @@ -40,7 +40,7 @@ } -def right_maxerror_proj(function_name: str) -> Dict[str, Any]: +def right_maxerror_proj(function_name: str) -> dict[str, Any]: return { 'result': '0', 'values': { @@ -61,8 +61,8 @@ def right_maxerror_proj(function_name: str) -> Dict[str, Any]: def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/featurecollection_test.py b/python/ee/tests/featurecollection_test.py index e33064fa7..43c0c6e7f 100644 --- a/python/ee/tests/featurecollection_test.py +++ b/python/ee/tests/featurecollection_test.py @@ -2,7 +2,7 @@ """Test for the ee.featurecollection module.""" import json -from typing import Any, Dict +from typing import Any from unittest import mock import unittest @@ -12,8 +12,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/filter_test.py b/python/ee/tests/filter_test.py index d2f5067b2..83e373493 100644 --- a/python/ee/tests/filter_test.py +++ b/python/ee/tests/filter_test.py @@ -3,7 +3,7 @@ import datetime import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -11,15 +11,15 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, } -def max_error_expression(max_error: float) -> Dict[str, Any]: +def max_error_expression(max_error: float) -> dict[str, Any]: return { 'functionInvocationValue': { 'functionName': 'ErrorMargin', diff --git a/python/ee/tests/geometry_point_test.py b/python/ee/tests/geometry_point_test.py index d01116b8c..83b620edf 100644 --- a/python/ee/tests/geometry_point_test.py +++ b/python/ee/tests/geometry_point_test.py @@ -2,7 +2,7 @@ """Test for the ee.geometry module Point methods.""" import json -from typing import Any, Dict +from typing import Any from unittest import mock import unittest @@ -45,8 +45,8 @@ def make_expression_graph_geom( - function_name: str, args: Dict[str, Any] -) -> Dict[str, Any]: + function_name: str, args: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': { diff --git a/python/ee/tests/image_converter_test.py b/python/ee/tests/image_converter_test.py index 184050d6c..b89a8a492 100644 --- a/python/ee/tests/image_converter_test.py +++ b/python/ee/tests/image_converter_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Tests for the image_converter module.""" -from typing import Optional, Type +from typing import Optional from absl.testing import parameterized import numpy @@ -20,7 +20,7 @@ class ImageConverterTest(parameterized.TestCase): def test_from_file_format( self, data_format: str, - expected: Optional[Type[image_converter.ImageConverter]], + expected: Optional[type[image_converter.ImageConverter]], ) -> None: """Verifies `from_file_format` returns the correct converter class.""" if expected is None: diff --git a/python/ee/tests/image_test.py b/python/ee/tests/image_test.py index de110aa61..951a0fafd 100644 --- a/python/ee/tests/image_test.py +++ b/python/ee/tests/image_test.py @@ -2,7 +2,7 @@ """Test for the ee.image module.""" import json -from typing import Any, Dict +from typing import Any from unittest import mock import unittest @@ -37,8 +37,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/imagecollection_test.py b/python/ee/tests/imagecollection_test.py index 90bf7e63e..12d0c8ed3 100644 --- a/python/ee/tests/imagecollection_test.py +++ b/python/ee/tests/imagecollection_test.py @@ -2,7 +2,7 @@ """Test for the ee.imagecollection module.""" import json -from typing import Any, Dict +from typing import Any from unittest import mock import unittest @@ -11,8 +11,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/join_test.py b/python/ee/tests/join_test.py index cb0f5993a..6b7d24d18 100644 --- a/python/ee/tests/join_test.py +++ b/python/ee/tests/join_test.py @@ -2,7 +2,7 @@ """Tests for the ee.Join module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -13,8 +13,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/kernel_test.py b/python/ee/tests/kernel_test.py index b062296fa..54af0f0a9 100644 --- a/python/ee/tests/kernel_test.py +++ b/python/ee/tests/kernel_test.py @@ -3,7 +3,7 @@ import json import sys -from typing import Any, Dict +from typing import Any import unittest import unittest @@ -30,8 +30,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/model_test.py b/python/ee/tests/model_test.py index 6125e443e..bb7134698 100644 --- a/python/ee/tests/model_test.py +++ b/python/ee/tests/model_test.py @@ -2,7 +2,7 @@ """Tests for the ee.Model module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -12,15 +12,15 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, } -def make_override_expression(key: str, pixel_type: str) -> Dict[str, Any]: +def make_override_expression(key: str, pixel_type: str) -> dict[str, Any]: return { 'dictionaryValue': { 'values': { @@ -44,7 +44,7 @@ def make_override_expression(key: str, pixel_type: str) -> Dict[str, Any]: def make_type_expression( key: str, pixel_type: str, dimensions: int -) -> Dict[str, Any]: +) -> dict[str, Any]: return { 'dictionaryValue': { 'values': { diff --git a/python/ee/tests/pixeltype_test.py b/python/ee/tests/pixeltype_test.py index 73843f266..0af4d8267 100644 --- a/python/ee/tests/pixeltype_test.py +++ b/python/ee/tests/pixeltype_test.py @@ -3,7 +3,7 @@ import enum import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -25,15 +25,15 @@ class Type(str, enum.Enum): def make_expression_graph( - function_invocation_value: Dict[str, Any] -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any] +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, } -def pixeltype_function_expr(value: Type) -> Dict[str, Any]: +def pixeltype_function_expr(value: Type) -> dict[str, Any]: return { 'functionInvocationValue': { 'functionName': 'PixelType', @@ -42,7 +42,7 @@ def pixeltype_function_expr(value: Type) -> Dict[str, Any]: } -def pixeltype_noargs_expr(type_name: str) -> Dict[str, Any]: +def pixeltype_noargs_expr(type_name: str) -> dict[str, Any]: return { 'result': '0', 'values': { diff --git a/python/ee/tests/projection_test.py b/python/ee/tests/projection_test.py index 4960140b6..678a5ab7f 100644 --- a/python/ee/tests/projection_test.py +++ b/python/ee/tests/projection_test.py @@ -2,7 +2,7 @@ """Tests for the ee.Projection module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -24,8 +24,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/reducer_test.py b/python/ee/tests/reducer_test.py index a75d8e938..6762b84db 100644 --- a/python/ee/tests/reducer_test.py +++ b/python/ee/tests/reducer_test.py @@ -2,7 +2,7 @@ """Tests for ee.Reducer module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -12,8 +12,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}}, diff --git a/python/ee/tests/serializer_test.py b/python/ee/tests/serializer_test.py index 1075bf8a9..6b66b6fe8 100644 --- a/python/ee/tests/serializer_test.py +++ b/python/ee/tests/serializer_test.py @@ -3,7 +3,7 @@ import datetime import json -from typing import Any, Callable, Dict, List, Union +from typing import Any, Callable, Union import unittest import ee @@ -11,7 +11,7 @@ from ee import serializer -def _max_depth(x: Union[Dict[str, Any], List[Any], str]) -> int: +def _max_depth(x: Union[dict[str, Any], list[Any], str]) -> int: """Computes the maximum nesting level of some dict, list, or str.""" if isinstance(x, dict): return 1 + max(_max_depth(v) for v in x.values()) @@ -103,13 +103,13 @@ def __init__(self, value: str): self._value = value # pylint: disable-next=g-bad-name - def encode(self, encoder: Callable[[Any], Any]) -> Dict[str, Any]: + def encode(self, encoder: Callable[[Any], Any]) -> dict[str, Any]: del encoder # Unused. return {'type': 'Bytes', 'value': self._value} def encode_cloud_value( self, encoder: Callable[[Any], Any] - ) -> Dict[str, str]: + ) -> dict[str, str]: del encoder # Unused. # Proto3 JSON embedding of "bytes" values uses base64 encoding, which # this already is. diff --git a/python/ee/tests/table_converter_test.py b/python/ee/tests/table_converter_test.py index e1ba09980..5c8f09cb2 100644 --- a/python/ee/tests/table_converter_test.py +++ b/python/ee/tests/table_converter_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Tests for the table_converter module.""" -from typing import Any, Dict, Optional, Type +from typing import Any, Optional from absl.testing import parameterized import geopandas @@ -15,8 +15,8 @@ class TableConverterTest(parameterized.TestCase): def _make_feature( - self, geometry: Dict[str, Any], properties: Dict[str, Any] - ) -> Dict[str, Any]: + self, geometry: dict[str, Any], properties: dict[str, Any] + ) -> dict[str, Any]: return {'type': 'Feature', 'geometry': geometry, 'properties': properties} @parameterized.named_parameters( @@ -28,7 +28,7 @@ def _make_feature( def test_from_file_format( self, data_format: str, - expected: Optional[Type[table_converter.TableConverter]], + expected: Optional[type[table_converter.TableConverter]], ) -> None: """Verifies `from_file_format` returns the correct converter class.""" if expected is None: diff --git a/python/ee/tests/terrain_test.py b/python/ee/tests/terrain_test.py index 8683fb7bb..9a8069d49 100644 --- a/python/ee/tests/terrain_test.py +++ b/python/ee/tests/terrain_test.py @@ -2,7 +2,7 @@ """Tests for the ee.Terrain module.""" import json -from typing import Any, Dict +from typing import Any import unittest import ee @@ -19,8 +19,8 @@ def make_expression_graph( - function_invocation_value: Dict[str, Any], -) -> Dict[str, Any]: + function_invocation_value: dict[str, Any], +) -> dict[str, Any]: return { 'result': '0', 'values': {'0': {'functionInvocationValue': function_invocation_value}},