-
-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gui: Early exit from functions or loops #4916
base: main
Are you sure you want to change the base?
Conversation
Flattens nested conditionals and moves error messages or returns near the top
Flattens nested conditionals and moves error messages near the top
gui/wxpython/gcp/manager.py
Outdated
(self.GCPcount >= 3 or self.gr_order != 1) | ||
and (self.GCPcount >= 6 or self.gr_order != 2) | ||
and (self.GCPcount >= 10 or self.gr_order != 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be correct, but it's completely unreadable. Maybe evaluate these separately before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get to it next time I can :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I couldn't do better, even using not
before wasn't pretty enough, so I partially reverted. However, by more closely analyzing it (plus type checking), that function could be returning None or a bool. I think that the intent of that (repeated) function, when reading the usages, is to return a bool. That means that the returns False
should have been outside the if msg:
. So I did that, so now it can't return None
, only True
or False
.
There's another possible hole in this logic, as it means that if we have gr_order of 4, 5, 6 or more, we need 0 or more points to return True
. In fact, the property self.GCPcount
could be anything (negative, None, a string, etc), as it is unchecked if self.gr_order
is not 1, 2 or 3.
Analogous to #4910, but for files in gui/.
I verified all the changes when committing them to make sure they are equivalent and that they kept the comments. The places I was unsure I reverted them, so these are the ones that make sense