earthengine-api 1.5.13rc0__py3-none-any.whl → 1.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of earthengine-api might be problematic. Click here for more details.

Files changed (102) hide show
  1. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/METADATA +3 -3
  2. earthengine_api-1.7.4.dist-info/RECORD +109 -0
  3. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/WHEEL +1 -1
  4. ee/__init__.py +29 -28
  5. ee/_arg_types.py +7 -6
  6. ee/_cloud_api_utils.py +95 -78
  7. ee/_helpers.py +17 -13
  8. ee/_state.py +105 -0
  9. ee/_utils.py +2 -1
  10. ee/apifunction.py +21 -19
  11. ee/apitestcase.py +33 -38
  12. ee/batch.py +87 -77
  13. ee/blob.py +10 -12
  14. ee/classifier.py +57 -59
  15. ee/cli/commands.py +178 -114
  16. ee/cli/eecli.py +1 -1
  17. ee/cli/utils.py +61 -42
  18. ee/clusterer.py +39 -41
  19. ee/collection.py +64 -54
  20. ee/computedobject.py +19 -16
  21. ee/confusionmatrix.py +9 -9
  22. ee/customfunction.py +13 -12
  23. ee/data.py +220 -322
  24. ee/daterange.py +10 -10
  25. ee/deprecation.py +21 -13
  26. ee/deserializer.py +25 -20
  27. ee/dictionary.py +11 -11
  28. ee/ee_array.py +22 -20
  29. ee/ee_date.py +23 -23
  30. ee/ee_list.py +15 -16
  31. ee/ee_number.py +11 -21
  32. ee/ee_string.py +24 -32
  33. ee/ee_types.py +4 -4
  34. ee/element.py +15 -15
  35. ee/encodable.py +7 -4
  36. ee/errormargin.py +4 -4
  37. ee/feature.py +68 -71
  38. ee/featurecollection.py +41 -40
  39. ee/filter.py +90 -92
  40. ee/function.py +8 -8
  41. ee/geometry.py +95 -93
  42. ee/image.py +238 -236
  43. ee/image_converter.py +4 -4
  44. ee/imagecollection.py +30 -27
  45. ee/join.py +13 -15
  46. ee/kernel.py +55 -57
  47. ee/mapclient.py +9 -9
  48. ee/model.py +29 -31
  49. ee/oauth.py +76 -63
  50. ee/pixeltype.py +6 -6
  51. ee/projection.py +5 -4
  52. ee/reducer.py +41 -41
  53. ee/serializer.py +14 -14
  54. ee/table_converter.py +7 -6
  55. ee/terrain.py +7 -9
  56. ee/tests/_cloud_api_utils_test.py +21 -6
  57. ee/tests/_helpers_test.py +57 -4
  58. ee/tests/_state_test.py +49 -0
  59. ee/tests/algorithms.json +85 -2
  60. ee/tests/apifunction_test.py +5 -5
  61. ee/tests/batch_test.py +135 -57
  62. ee/tests/blob_test.py +5 -5
  63. ee/tests/classifier_test.py +3 -3
  64. ee/tests/clusterer_test.py +3 -3
  65. ee/tests/collection_test.py +48 -13
  66. ee/tests/confusionmatrix_test.py +3 -3
  67. ee/tests/data_test.py +484 -55
  68. ee/tests/daterange_test.py +4 -4
  69. ee/tests/deprecation_test.py +6 -4
  70. ee/tests/deserializer_test.py +64 -5
  71. ee/tests/dictionary_test.py +12 -12
  72. ee/tests/ee_array_test.py +3 -3
  73. ee/tests/ee_date_test.py +4 -4
  74. ee/tests/ee_list_test.py +3 -3
  75. ee/tests/ee_number_test.py +75 -30
  76. ee/tests/ee_string_test.py +11 -3
  77. ee/tests/ee_test.py +40 -22
  78. ee/tests/element_test.py +2 -2
  79. ee/tests/errormargin_test.py +1 -1
  80. ee/tests/feature_test.py +10 -10
  81. ee/tests/featurecollection_test.py +3 -3
  82. ee/tests/filter_test.py +4 -4
  83. ee/tests/function_test.py +5 -5
  84. ee/tests/geometry_point_test.py +3 -3
  85. ee/tests/geometry_test.py +93 -52
  86. ee/tests/image_converter_test.py +1 -3
  87. ee/tests/image_test.py +3 -3
  88. ee/tests/imagecollection_test.py +3 -3
  89. ee/tests/join_test.py +3 -3
  90. ee/tests/kernel_test.py +7 -3
  91. ee/tests/model_test.py +17 -5
  92. ee/tests/oauth_test.py +189 -7
  93. ee/tests/pixeltype_test.py +6 -7
  94. ee/tests/projection_test.py +5 -6
  95. ee/tests/reducer_test.py +16 -3
  96. ee/tests/serializer_test.py +39 -12
  97. ee/tests/table_converter_test.py +51 -7
  98. ee/tests/terrain_test.py +11 -3
  99. earthengine_api-1.5.13rc0.dist-info/RECORD +0 -107
  100. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/entry_points.txt +0 -0
  101. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/licenses/LICENSE +0 -0
  102. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/top_level.txt +0 -0
ee/ee_date.py CHANGED
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
 
4
4
  import datetime
5
5
  import math
6
- from typing import Any, Dict, Optional, Union
6
+ from typing import Any, Union
7
7
 
8
8
  from ee import _arg_types
9
9
  from ee import _utils
@@ -31,7 +31,7 @@ class Date(computedobject.ComputedObject):
31
31
 
32
32
  @_utils.accept_opt_prefix('opt_tz')
33
33
  def __init__(
34
- self, date: Union[_DateType], tz: Optional[_arg_types.String] = None
34
+ self, date: _DateType, tz: _arg_types.String | None = None
35
35
  ):
36
36
  """Construct a date.
37
37
 
@@ -50,7 +50,7 @@ class Date(computedobject.ComputedObject):
50
50
  self.initialize()
51
51
 
52
52
  func = apifunction.ApiFunction(self.name())
53
- args: Dict[str, Any]
53
+ args: dict[str, Any]
54
54
  var_name = None
55
55
  if isinstance(date, datetime.datetime):
56
56
  args = {'value':
@@ -108,8 +108,8 @@ class Date(computedobject.ComputedObject):
108
108
  delta: _arg_types.Number,
109
109
  unit: _arg_types.String,
110
110
  # pylint: disable-next=invalid-name
111
- timeZone: Optional[_arg_types.String] = None,
112
- ) -> 'Date':
111
+ timeZone: _arg_types.String | None = None,
112
+ ) -> Date:
113
113
  """Create a new Date by adding the specified units to the given Date.
114
114
 
115
115
  Args:
@@ -147,9 +147,9 @@ class Date(computedobject.ComputedObject):
147
147
  def format(
148
148
  self,
149
149
  # pylint: disable-next=redefined-builtin
150
- format: Optional[_arg_types.String] = None,
150
+ format: _arg_types.String | None = None,
151
151
  # pylint: disable-next=invalid-name
152
- timeZone: Optional[_arg_types.String] = None,
152
+ timeZone: _arg_types.String | None = None,
153
153
  ) -> ee_string.String:
154
154
  """Convert a date to string.
155
155
 
@@ -175,8 +175,8 @@ class Date(computedobject.ComputedObject):
175
175
  month: _arg_types.Integer,
176
176
  day: _arg_types.Integer,
177
177
  # pylint: disable=invalid-name
178
- timeZone: Optional[_arg_types.String] = None,
179
- ) -> 'Date':
178
+ timeZone: _arg_types.String | None = None,
179
+ ) -> Date:
180
180
  """Returns a Date given year, month, day.
181
181
 
182
182
  Args:
@@ -194,7 +194,7 @@ class Date(computedobject.ComputedObject):
194
194
  self,
195
195
  unit: _arg_types.String,
196
196
  # pylint: disable-next=invalid-name
197
- timeZone: Optional[_arg_types.String] = None,
197
+ timeZone: _arg_types.String | None = None,
198
198
  ) -> ee_number.Number:
199
199
  """Returns the specified unit of this date.
200
200
 
@@ -215,7 +215,7 @@ class Date(computedobject.ComputedObject):
215
215
  self,
216
216
  unit: _arg_types.String,
217
217
  # pylint: disable-next=invalid-name
218
- timeZone: Optional[_arg_types.String] = None,
218
+ timeZone: _arg_types.String | None = None,
219
219
  ) -> ee_number.Number:
220
220
  """Returns this date's elapsed fraction of the specified unit.
221
221
 
@@ -236,7 +236,7 @@ class Date(computedobject.ComputedObject):
236
236
  self,
237
237
  unit: _arg_types.String,
238
238
  # pylint: disable-next=invalid-name
239
- timeZone: Optional[_arg_types.String] = None,
239
+ timeZone: _arg_types.String | None = None,
240
240
  ) -> daterange.DateRange:
241
241
  """Returns a DateRange covering the unit that contains this date.
242
242
 
@@ -266,7 +266,7 @@ class Date(computedobject.ComputedObject):
266
266
  unit: _arg_types.String,
267
267
  inUnit: _arg_types.String, # pylint: disable=invalid-name
268
268
  # pylint: disable-next=invalid-name
269
- timeZone: Optional[_arg_types.String] = None,
269
+ timeZone: _arg_types.String | None = None,
270
270
  ) -> ee_number.Number:
271
271
  """Returns the specified unit of this date relative to a larger unit.
272
272
 
@@ -295,8 +295,8 @@ class Date(computedobject.ComputedObject):
295
295
  format: _arg_types.String, # pylint: disable=redefined-builtin
296
296
  date: _arg_types.String,
297
297
  # pylint: disable-next=invalid-name
298
- timeZone: Optional[_arg_types.String] = None,
299
- ) -> 'Date':
298
+ timeZone: _arg_types.String | None = None,
299
+ ) -> Date:
300
300
  """Parse a date string, given a string describing its format.
301
301
 
302
302
  Args:
@@ -336,15 +336,15 @@ class Date(computedobject.ComputedObject):
336
336
 
337
337
  def update(
338
338
  self,
339
- year: Optional[_arg_types.Integer] = None,
340
- month: Optional[_arg_types.Integer] = None,
341
- day: Optional[_arg_types.Integer] = None,
342
- hour: Optional[_arg_types.Integer] = None,
343
- minute: Optional[_arg_types.Integer] = None,
344
- second: Optional[_arg_types.Number] = None,
339
+ year: _arg_types.Integer | None = None,
340
+ month: _arg_types.Integer | None = None,
341
+ day: _arg_types.Integer | None = None,
342
+ hour: _arg_types.Integer | None = None,
343
+ minute: _arg_types.Integer | None = None,
344
+ second: _arg_types.Number | None = None,
345
345
  # pylint: disable-next=invalid-name
346
- timeZone: Optional[_arg_types.String] = None,
347
- ) -> 'Date':
346
+ timeZone: _arg_types.String | None = None,
347
+ ) -> Date:
348
348
  """Create a new Date by setting one or more of the units of the given Date.
349
349
 
350
350
  If a timeZone is given the new value(s) is interpreted in that zone. Skip or
ee/ee_list.py CHANGED
@@ -1,8 +1,7 @@
1
1
  """A wrapper for lists."""
2
2
  from __future__ import annotations
3
3
 
4
- # List clashes with the class List, so call it ListType
5
- from typing import Any, List as ListType, Optional, Tuple, Union
4
+ from typing import Any
6
5
 
7
6
  from ee import _arg_types
8
7
  from ee import _utils
@@ -18,16 +17,16 @@ from ee import geometry
18
17
 
19
18
  class List(computedobject.ComputedObject):
20
19
  """An object to represent lists."""
21
- _list: Optional[
22
- Union[ListType[Any], Tuple[Any, Any]]
23
- ]
20
+ _list: None | (
21
+ list[Any] | tuple[Any, Any]
22
+ )
24
23
 
25
24
  _initialized = False
26
25
 
27
26
  # Tell pytype to not complain about dynamic attributes.
28
27
  _HAS_DYNAMIC_ATTRIBUTES = True
29
28
 
30
- def __init__(self, arg: Optional[_arg_types.List]):
29
+ def __init__(self, arg: _arg_types.List | None):
31
30
  """Construct a list wrapper.
32
31
 
33
32
  This constructor accepts the following args:
@@ -65,9 +64,9 @@ class List(computedobject.ComputedObject):
65
64
  @staticmethod
66
65
  def sequence(
67
66
  start: _arg_types.Number,
68
- end: Optional[_arg_types.Number] = None,
69
- step: Optional[_arg_types.Number] = None,
70
- count: Optional[_arg_types.Integer] = None,
67
+ end: _arg_types.Number | None = None,
68
+ step: _arg_types.Number | None = None,
69
+ count: _arg_types.Integer | None = None,
71
70
  ) -> List:
72
71
  """Returns a List of numbers from start to end (inclusive).
73
72
 
@@ -105,7 +104,7 @@ class List(computedobject.ComputedObject):
105
104
  return 'List'
106
105
 
107
106
  @_utils.accept_opt_prefix('opt_encoder')
108
- def encode(self, encoder: Optional[Any] = None) -> Any:
107
+ def encode(self, encoder: Any | None = None) -> Any:
109
108
  if isinstance(self._list, (list, tuple)):
110
109
  assert self._list is not None
111
110
  return [encoder(elem) for elem in self._list]
@@ -113,7 +112,7 @@ class List(computedobject.ComputedObject):
113
112
  return super().encode(encoder)
114
113
 
115
114
  @_utils.accept_opt_prefix('opt_encoder')
116
- def encode_cloud_value(self, encoder: Optional[Any] = None) -> Any:
115
+ def encode_cloud_value(self, encoder: Any | None = None) -> Any:
117
116
  if isinstance(self._list, (list, tuple)):
118
117
  return {'valueReference': encoder(self._list)}
119
118
  else:
@@ -558,7 +557,7 @@ class List(computedobject.ComputedObject):
558
557
  self.name() + '.set', self, index, element
559
558
  )
560
559
 
561
- def shuffle(self, seed: Optional[_arg_types.Integer] = None) -> List:
560
+ def shuffle(self, seed: _arg_types.Integer | None = None) -> List:
562
561
  """Randomly permute the specified list.
563
562
 
564
563
  Note that the permutation order will always be the same for any given seed,
@@ -583,8 +582,8 @@ class List(computedobject.ComputedObject):
583
582
  def slice(
584
583
  self,
585
584
  start: _arg_types.Integer,
586
- end: Optional[_arg_types.Integer] = None,
587
- step: Optional[_arg_types.Integer] = None,
585
+ end: _arg_types.Integer | None = None,
586
+ step: _arg_types.Integer | None = None,
588
587
  ) -> List:
589
588
  """Returns a range of elements from a list.
590
589
 
@@ -608,7 +607,7 @@ class List(computedobject.ComputedObject):
608
607
  self.name() + '.slice', self, start, end, step
609
608
  )
610
609
 
611
- def sort(self, keys: Optional[_arg_types.List] = None) -> List:
610
+ def sort(self, keys: _arg_types.List | None = None) -> List:
612
611
  """Sorts the list into ascending order.
613
612
 
614
613
  If the keys argument is provided, then it is sorted first, and the
@@ -628,7 +627,7 @@ class List(computedobject.ComputedObject):
628
627
  self,
629
628
  start: _arg_types.Integer,
630
629
  count: _arg_types.Integer,
631
- other: Optional[_arg_types.List] = None,
630
+ other: _arg_types.List | None = None,
632
631
  ) -> List:
633
632
  """Removes elements from list and replaces with elements from other.
634
633
 
ee/ee_number.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """A wrapper for numbers."""
2
2
  from __future__ import annotations
3
3
 
4
- from typing import Any, Optional, Union
4
+ from typing import Any
5
5
 
6
6
  from ee import _arg_types
7
7
  from ee import _cloud_api_utils
@@ -15,7 +15,7 @@ from ee import ee_string
15
15
  class Number(computedobject.ComputedObject):
16
16
  """An object to represent numbers."""
17
17
 
18
- _number: Optional[float]
18
+ _number: float | None
19
19
 
20
20
  _initialized = False
21
21
 
@@ -299,7 +299,7 @@ class Number(computedobject.ComputedObject):
299
299
  def expression(
300
300
  expression: _arg_types.String,
301
301
  # pylint: disable-next=redefined-builtin
302
- vars: Optional[_arg_types.Dictionary] = None,
302
+ vars: _arg_types.Dictionary | None = None,
303
303
  ) -> Number:
304
304
  """Returns a number from computing a numeric expression.
305
305
 
@@ -351,7 +351,7 @@ class Number(computedobject.ComputedObject):
351
351
  return apifunction.ApiFunction.call_(self.name() + '.floor', self)
352
352
 
353
353
  def format(
354
- self, pattern: Optional[_arg_types.String] = None
354
+ self, pattern: _arg_types.String | None = None
355
355
  ) -> ee_string.String:
356
356
  r"""Convert a number to a string using printf-style formatting.
357
357
 
@@ -586,10 +586,10 @@ class Number(computedobject.ComputedObject):
586
586
 
587
587
  return apifunction.ApiFunction.call_(self.name() + '.or', self, right)
588
588
 
589
+ @staticmethod
589
590
  def parse(
590
- # pylint: disable=redefined-builtin
591
- input: _arg_types.String,
592
- radix: Optional[_arg_types.Integer] = None,
591
+ input: _arg_types.String, # pylint: disable=redefined-builtin
592
+ radix: _arg_types.Integer | None = None,
593
593
  ) -> Number:
594
594
  """Returns a number from a string.
595
595
 
@@ -772,27 +772,17 @@ class Number(computedobject.ComputedObject):
772
772
 
773
773
  return apifunction.ApiFunction.call_(self.name() + '.uint8', self)
774
774
 
775
- # pylint: disable=redefined-builtin
776
- # pytype: disable=invalid-annotation
777
- def unitScale(
778
- self,
779
- min: Union[int, float, computedobject.ComputedObject],
780
- max: Union[int, float, computedobject.ComputedObject],
781
- ) -> Number:
782
- """Scales the input so that [min, max] becomes [0, 1].
775
+ # pylint: disable-next=redefined-builtin
776
+ def unitScale(self, min: _arg_types.Number, max: _arg_types.Number) -> Number:
777
+ """Returns the input scaled so that [min, max] becomes [0, 1].
783
778
 
784
- Values outside the range are NOT clamped. If min == max, 0 is returned.
779
+ Values outside the range are NOT clamped. If min == max, 0 is returned.
785
780
 
786
781
  Args:
787
782
  min: Minimum value of the input to be scaled to 0.
788
783
  max: Maximum value of the input to be scaled to 1.
789
-
790
- Returns:
791
- An ee.Number.
792
784
  """
793
785
 
794
786
  return apifunction.ApiFunction.call_(
795
787
  self.name() + '.unitScale', self, min, max
796
788
  )
797
- # pytype: enable=invalid-annotation
798
- # pylint: enable=redefined-builtin
ee/ee_string.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """A wrapper for strings."""
2
2
  from __future__ import annotations
3
3
 
4
- from typing import Any, Optional, Union
4
+ from typing import Any
5
5
 
6
6
  from ee import _arg_types
7
7
  from ee import _utils
@@ -15,7 +15,7 @@ from ee import ee_number
15
15
  class String(computedobject.ComputedObject):
16
16
  """An object to represent strings."""
17
17
 
18
- _string: Optional[str]
18
+ _string: str | None
19
19
 
20
20
  _initialized = False
21
21
 
@@ -37,19 +37,19 @@ class String(computedobject.ComputedObject):
37
37
  if isinstance(string, str):
38
38
  super().__init__(None, None)
39
39
  self._string = string
40
-
41
40
  elif isinstance(string, computedobject.ComputedObject):
42
41
  if self.is_func_returning_same(string):
43
42
  # If it's a call that's already returning a String, just cast.
44
43
  super().__init__(string.func, string.args, string.varName)
45
44
  else:
45
+ # Wrap some other ComputedObject.
46
46
  super().__init__(
47
47
  apifunction.ApiFunction(self.name()), {'input': string}
48
48
  )
49
49
  self._string = None
50
50
  else:
51
51
  raise ee_exception.EEException(
52
- 'Invalid argument specified for ee.String(): %s' % string)
52
+ f'Invalid argument specified for ee.String(): {string}')
53
53
 
54
54
  @classmethod
55
55
  def initialize(cls) -> None:
@@ -91,8 +91,7 @@ class String(computedobject.ComputedObject):
91
91
  Returns:
92
92
  Returns the result of joining self and string2.
93
93
  """
94
-
95
- return apifunction.ApiFunction.call_(self.name() + '.cat', self, string2)
94
+ return apifunction.ApiFunction.call_(f'{self.name()}.cat', self, string2)
96
95
 
97
96
  def compareTo(self, string2: _arg_types.String) -> ee_number.Number:
98
97
  """Compares two strings lexicographically.
@@ -107,15 +106,15 @@ class String(computedobject.ComputedObject):
107
106
  """
108
107
 
109
108
  return apifunction.ApiFunction.call_(
110
- self.name() + '.compareTo', self, string2
109
+ f'{self.name()}.compareTo', self, string2
111
110
  )
112
111
 
113
112
  def decodeJSON(self) -> computedobject.ComputedObject:
114
113
  """Decodes self as a JSON string."""
115
-
116
- return apifunction.ApiFunction.call_(self.name() + '.decodeJSON', self)
114
+ return apifunction.ApiFunction.call_(f'{self.name()}.decodeJSON', self)
117
115
 
118
116
  @staticmethod
117
+ # pylint: disable=redefined-builtin
119
118
  def encodeJSON(object: _arg_types.Any) -> String:
120
119
  """Returns an ee.String with an object encoded as JSON.
121
120
 
@@ -124,7 +123,7 @@ class String(computedobject.ComputedObject):
124
123
  Args:
125
124
  object: The object to encode.
126
125
  """
127
-
126
+ # object is probably not an ee.String, so use "String." instead of object.
128
127
  return apifunction.ApiFunction.call_('String.encodeJSON', object)
129
128
 
130
129
  def equals(self, target: _arg_types.String) -> computedobject.ComputedObject:
@@ -137,8 +136,7 @@ class String(computedobject.ComputedObject):
137
136
  True if the target is a string and is lexicographically equal to the
138
137
  reference, or false otherwise.
139
138
  """
140
-
141
- return apifunction.ApiFunction.call_(self.name() + '.equals', self, target)
139
+ return apifunction.ApiFunction.call_(f'{self.name()}.equals', self, target)
142
140
 
143
141
  def index(self, pattern: _arg_types.String) -> ee_number.Number:
144
142
  """Searches a string for the first occurrence of a substring.
@@ -149,16 +147,14 @@ class String(computedobject.ComputedObject):
149
147
  Returns:
150
148
  The index of the first match, or -1.
151
149
  """
152
-
153
- return apifunction.ApiFunction.call_(self.name() + '.index', self, pattern)
150
+ return apifunction.ApiFunction.call_(f'{self.name()}.index', self, pattern)
154
151
 
155
152
  def length(self) -> ee_number.Number:
156
153
  """Returns the length of a string."""
157
-
158
- return apifunction.ApiFunction.call_(self.name() + '.length', self)
154
+ return apifunction.ApiFunction.call_(f'{self.name()}.length', self)
159
155
 
160
156
  def match(
161
- self, regex: _arg_types.String, flags: Optional[_arg_types.String] = None
157
+ self, regex: _arg_types.String, flags: _arg_types.String | None = None
162
158
  ) -> ee_list.List:
163
159
  """Matches a string against a regular expression.
164
160
 
@@ -172,14 +168,14 @@ class String(computedobject.ComputedObject):
172
168
  """
173
169
 
174
170
  return apifunction.ApiFunction.call_(
175
- self.name() + '.match', self, regex, flags
171
+ f'{self.name()}.match', self, regex, flags
176
172
  )
177
173
 
178
174
  def replace(
179
175
  self,
180
176
  regex: _arg_types.String,
181
177
  replacement: _arg_types.String,
182
- flags: Optional[_arg_types.String] = None,
178
+ flags: _arg_types.String | None = None,
183
179
  ) -> String:
184
180
  """Returns a string with some or all matches of a pattern replaced.
185
181
 
@@ -194,7 +190,7 @@ class String(computedobject.ComputedObject):
194
190
  """
195
191
 
196
192
  return apifunction.ApiFunction.call_(
197
- self.name() + '.replace', self, regex, replacement, flags
193
+ f'{self.name()}.replace', self, regex, replacement, flags
198
194
  )
199
195
 
200
196
  def rindex(self, pattern: _arg_types.String) -> ee_number.Number:
@@ -206,11 +202,10 @@ class String(computedobject.ComputedObject):
206
202
  Returns:
207
203
  The index of the first match or -1 if no match.
208
204
  """
209
-
210
- return apifunction.ApiFunction.call_(self.name() + '.rindex', self, pattern)
205
+ return apifunction.ApiFunction.call_(f'{self.name()}.rindex', self, pattern)
211
206
 
212
207
  def slice(
213
- self, start: _arg_types.Integer, end: Optional[_arg_types.Integer] = None
208
+ self, start: _arg_types.Integer, end: _arg_types.Integer | None = None
214
209
  ) -> String:
215
210
  """Returns a substring of the given string.
216
211
 
@@ -228,11 +223,11 @@ class String(computedobject.ComputedObject):
228
223
  """
229
224
 
230
225
  return apifunction.ApiFunction.call_(
231
- self.name() + '.slice', self, start, end
226
+ f'{self.name()}.slice', self, start, end
232
227
  )
233
228
 
234
229
  def split(
235
- self, regex: _arg_types.String, flags: Optional[_arg_types.String] = None
230
+ self, regex: _arg_types.String, flags: _arg_types.String | None = None
236
231
  ) -> ee_list.List:
237
232
  """Splits a string on a regular expression into a list of strings.
238
233
 
@@ -246,20 +241,17 @@ class String(computedobject.ComputedObject):
246
241
  """
247
242
 
248
243
  return apifunction.ApiFunction.call_(
249
- self.name() + '.split', self, regex, flags
244
+ f'{self.name()}.split', self, regex, flags
250
245
  )
251
246
 
252
247
  def toLowerCase(self) -> String:
253
248
  """Converts all of the characters in a string to lower case."""
254
-
255
- return apifunction.ApiFunction.call_(self.name() + '.toLowerCase', self)
249
+ return apifunction.ApiFunction.call_(f'{self.name()}.toLowerCase', self)
256
250
 
257
251
  def toUpperCase(self) -> String:
258
252
  """Converts all of the characters in a string to upper case."""
259
-
260
- return apifunction.ApiFunction.call_(self.name() + '.toUpperCase', self)
253
+ return apifunction.ApiFunction.call_(f'{self.name()}.toUpperCase', self)
261
254
 
262
255
  def trim(self) -> String:
263
256
  """Returns a string with any leading and trailing whitespace removed."""
264
-
265
- return apifunction.ApiFunction.call_(self.name() + '.trim', self)
257
+ return apifunction.ApiFunction.call_(f'{self.name()}.trim', self)
ee/ee_types.py CHANGED
@@ -4,12 +4,12 @@
4
4
  # pylint: disable=g-bad-name
5
5
 
6
6
  import datetime
7
- from typing import Any, Type
7
+ from typing import Any
8
8
 
9
9
  from ee import computedobject
10
10
 
11
11
 
12
- # A dictionary of the classes in the ee module. Set by registerClasses.
12
+ # A dictionary of the classes in the ee module. Set by registerClasses.
13
13
  _registered_classes = {}
14
14
 
15
15
 
@@ -23,7 +23,7 @@ def _registerClasses(classes) -> None:
23
23
  _registered_classes = classes
24
24
 
25
25
 
26
- def classToName(a_class: Type[Any]) -> str:
26
+ def classToName(a_class: type[Any]) -> str:
27
27
  """Converts a class to the API-friendly type name.
28
28
 
29
29
  Args:
@@ -48,7 +48,7 @@ def classToName(a_class: Type[Any]) -> str:
48
48
 
49
49
  # TODO(user): Any -> Optional[type[Any]].
50
50
  def nameToClass(name: str) -> Any:
51
- """Converts a class name to a class. Returns None if not an ee class.
51
+ """Converts a class name to a class. Returns None if not an ee class.
52
52
 
53
53
  Args:
54
54
  name: The class name.
ee/element.py CHANGED
@@ -6,7 +6,7 @@ This class is never intended to be instantiated by the user.
6
6
  from __future__ import annotations
7
7
 
8
8
  import datetime
9
- from typing import Any, Dict, Optional, Union
9
+ from typing import Any
10
10
 
11
11
  from ee import _arg_types
12
12
  from ee import _utils
@@ -29,9 +29,9 @@ class Element(computedobject.ComputedObject):
29
29
  @_utils.accept_opt_prefix('opt_varName')
30
30
  def __init__(
31
31
  self,
32
- func: Optional[apifunction.ApiFunction],
33
- args: Optional[Dict[str, Any]],
34
- varName: Optional[str] = None, # pylint: disable=g-bad-name
32
+ func: apifunction.ApiFunction | None,
33
+ args: dict[str, Any] | None,
34
+ varName: str | None = None, # pylint: disable=g-bad-name
35
35
  ):
36
36
  """Constructs a collection by initializing its ComputedObject."""
37
37
  super().__init__(func, args, varName)
@@ -58,8 +58,8 @@ class Element(computedobject.ComputedObject):
58
58
  def copyProperties(
59
59
  self,
60
60
  source: _arg_types.Element,
61
- properties: Optional[_arg_types.List] = None,
62
- exclude: Optional[_arg_types.List] = None,
61
+ properties: _arg_types.List | None = None,
62
+ exclude: _arg_types.List | None = None,
63
63
  ) -> Element:
64
64
  """Copies metadata properties from one element to another.
65
65
 
@@ -121,13 +121,13 @@ class Element(computedobject.ComputedObject):
121
121
 
122
122
  def set(
123
123
  self,
124
- *args: Union[
125
- Dict[str, Any],
126
- float,
127
- str,
128
- datetime.datetime,
129
- computedobject.ComputedObject,
130
- ],
124
+ *args: (
125
+ dict[str, Any] |
126
+ float |
127
+ str |
128
+ datetime.datetime |
129
+ computedobject.ComputedObject
130
+ ),
131
131
  ) -> Element:
132
132
  """Overrides one or more metadata properties of an Element.
133
133
 
@@ -182,12 +182,12 @@ class Element(computedobject.ComputedObject):
182
182
  return self._cast(result)
183
183
 
184
184
  def toDictionary(
185
- self, properties: Optional[_arg_types.List] = None
185
+ self, properties: _arg_types.List | None = None
186
186
  ) -> dictionary.Dictionary:
187
187
  """Returns properties from a feature as a dictionary.
188
188
 
189
189
  Args:
190
- properties: The list of properties to extract. Defaults to all non-system
190
+ properties: The list of properties to extract. Defaults to all non-system
191
191
  properties
192
192
  """
193
193
 
ee/encodable.py CHANGED
@@ -1,10 +1,13 @@
1
1
  """Interfaces implemented by serializable objects."""
2
2
 
3
+ from collections.abc import Callable
4
+ from typing import Any
5
+
3
6
 
4
7
  class Encodable:
5
8
  """An interface implemented by objects that can serialize themselves."""
6
9
 
7
- def encode(self, encoder):
10
+ def encode(self, encoder: Callable[[Any], Any]) -> Any:
8
11
  """Encodes the object in a format compatible with Serializer.
9
12
 
10
13
  Args:
@@ -16,7 +19,7 @@ class Encodable:
16
19
  """
17
20
  raise NotImplementedError('Encodable classes must implement encode().')
18
21
 
19
- def encode_cloud_value(self, encoder):
22
+ def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> Any:
20
23
  """Encodes the object as a ValueNode.
21
24
 
22
25
  Args:
@@ -33,7 +36,7 @@ class Encodable:
33
36
  class EncodableFunction:
34
37
  """An interface implemented by functions that can serialize themselves."""
35
38
 
36
- def encode_invocation(self, encoder):
39
+ def encode_invocation(self, encoder: Callable[[Any], Any]) -> Any:
37
40
  """Encodes the function in a format compatible with Serializer.
38
41
 
39
42
  Args:
@@ -46,7 +49,7 @@ class EncodableFunction:
46
49
  raise NotImplementedError(
47
50
  'EncodableFunction classes must implement encode_invocation().')
48
51
 
49
- def encode_cloud_invocation(self, encoder):
52
+ def encode_cloud_invocation(self, encoder: Callable[[Any], Any]) -> Any:
50
53
  """Encodes the function as a FunctionInvocation.
51
54
 
52
55
  Args:
ee/errormargin.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """A wrapper for ErrorMargins."""
2
2
  from __future__ import annotations
3
3
 
4
- from typing import Any, Dict, Optional
4
+ from typing import Any
5
5
 
6
6
  from ee import _arg_types
7
7
  from ee import apifunction
@@ -36,8 +36,8 @@ class ErrorMargin(computedobject.ComputedObject):
36
36
 
37
37
  def __init__(
38
38
  self,
39
- value: Optional[_arg_types.Number] = None,
40
- unit: Optional[_arg_types.String] = None,
39
+ value: _arg_types.Number | None = None,
40
+ unit: _arg_types.String | None = None,
41
41
  ):
42
42
  """Creates a ErrorMargin wrapper.
43
43
 
@@ -64,7 +64,7 @@ class ErrorMargin(computedobject.ComputedObject):
64
64
  ):
65
65
  raise TypeError('value must be provided if unit is not infinite')
66
66
 
67
- args: Dict[str, Any] = {}
67
+ args: dict[str, Any] = {}
68
68
  if value is not None:
69
69
  args['value'] = value
70
70
  if unit is not None: