Skip to content

Commit

Permalink
Bugfix: Move loop_root sentinel value above exhaustive conditionals (
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 authored Sep 26, 2024
1 parent 74ca632 commit 4e54d0a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions icepyx/core/granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ def place_order(
status = statuslist[0]
print("Initial status of your order request at NSIDC is: ", status)

loop_root = None
# If status is already finished without going into pending/processing
if status.startswith("complete"):
loop_response = self.session.get(statusURL)
loop_root = ET.fromstring(loop_response.content)

# Continue loop while request is still processing
loop_root = None
while status == "pending" or status == "processing":
print(
"Your order status is still ",
Expand All @@ -443,11 +443,10 @@ def place_order(
continue

if not isinstance(loop_root, ET.Element):
# The typechecker determined that loop_root could be unbound at this
# point. We know for sure this shouldn't be possible, though, because
# the while loop should run once.
# See: https://github.com/microsoft/pyright/discussions/2033
raise RuntimeError("Programmer error!")
# The typechecker needs help knowing that at this point loop_root is
# set, as it can't tell that the conditionals above are supposed to be
# exhaustive.
raise icepyx.core.exceptions.ExhaustiveTypeGuardException

# Order can either complete, complete_with_errors, or fail:
# Provide complete_with_errors error message:
Expand Down

0 comments on commit 4e54d0a

Please sign in to comment.