Skip to content

Commit ed7f451

Browse files
committed
Fix the checking of valid enum values for Python<=3.11
1 parent fd099b0 commit ed7f451

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pygmt/accessors.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def registration(self):
162162
def registration(self, value):
163163
if value in {"gridline", "pixel"}: # Support for string-type values
164164
value = GridReg[value.upper()]
165-
if value not in GridReg:
165+
# Can be simplified to `if value not in GridReg` after requiring Python 3.12+.
166+
if value not in GridReg.__members__.values():
166167
msg = (
167168
f"Invalid grid registration: {value}. "
168169
"Should be either GridReg.GRIDLINE or GridReg.PIXEL."
@@ -182,7 +183,8 @@ def gtype(self):
182183
def gtype(self, value):
183184
if value in {"cartesian", "geographic"}: # Support for string-type values
184185
value = GridType[value.upper()]
185-
if value not in GridType:
186+
# Can be simplified to `if value not in GridType` after requiring Python 3.12+.
187+
if value not in GridType.__members__.values():
186188
msg = (
187189
f"Invalid grid coordinate system type: '{value}'. "
188190
"Should be either GridType.CARTESIAN or GridType.GEOGRAPHIC."

0 commit comments

Comments
 (0)