Skip to content

Commit 266229b

Browse files
committed
Remove compatibility codes for Python<3.12
1 parent 4d5fb26 commit 266229b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pygmt/src/_common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,14 @@ def __init__(
190190
191191
Doesn't apply to the conventions ``"aki"``, ``"gcmt"``, and ``"partial"``.
192192
"""
193-
# TODO(Python>=3.12): Simplify to "convention in _FocalMechanismConventionCode".
194-
if convention in _FocalMechanismConventionCode.__members__.values():
193+
if convention in _FocalMechanismConventionCode:
195194
# Convention is specified via the actual single-letter convention code.
196195
self.code = _FocalMechanismConventionCode(convention)
197196
# Parse the convention from the convention code name.
198197
self._convention = "_".join(self.code.name.split("_")[:-1]).lower()
199198
else: # Convention is specified via "convention" and "component".
200199
name = f"{convention.upper()}_{component.upper()}" # e.g., "AKI_DC"
201-
if name not in _FocalMechanismConventionCode.__members__:
200+
if name not in _FocalMechanismConventionCode:
202201
_value = f"convention='{convention}', component='{component}'"
203202
raise GMTValueError(_value, description="focal mechanism convention")
204203
self.code = _FocalMechanismConventionCode[name]

pygmt/xarray/accessor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ def registration(self) -> GridRegistration:
209209

210210
@registration.setter
211211
def registration(self, value: GridRegistration | int):
212-
# TODO(Python>=3.12): Simplify to `if value not in GridRegistration`.
213-
if value not in GridRegistration.__members__.values():
212+
if value not in GridRegistration:
214213
raise GMTValueError(
215214
value, description="grid registration", choices=GridRegistration
216215
)
@@ -225,8 +224,7 @@ def gtype(self) -> GridType:
225224

226225
@gtype.setter
227226
def gtype(self, value: GridType | int):
228-
# TODO(Python>=3.12): Simplify to `if value not in GridType`.
229-
if value not in GridType.__members__.values():
227+
if value not in GridType:
230228
raise GMTValueError(
231229
value, description="grid coordinate system type", choices=GridType
232230
)

0 commit comments

Comments
 (0)