-
Notifications
You must be signed in to change notification settings - Fork 107
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
A collection of "low-hanging fruit" refactors #612
base: typecheck-spatial
Are you sure you want to change the base?
Conversation
"ATL23", | ||
], error_msg | ||
else: | ||
if not isinstance(product, str): |
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 find the style of:
if not valid:
raise ...
# main logic here
more readable than:
if valid:
# main logic here
else:
raise ...
@@ -330,13 +332,13 @@ def gt2spot(gt, sc_orient): | |||
elif gr_lr == "r": | |||
spot = 6 | |||
|
|||
if "spot" not in locals(): |
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.
Looking at locals()
is a smell to me. I feel it may throw off some other code-readers.
if not hasattr(self, "_granules") or self._granules is None: | ||
self._granules = Granules() | ||
|
||
return self._granules |
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.
Looks to me like self.granules
is static and could be set at init-time as a class attribute, but then we wouldn't get this awesome docstring. I changed the method to a cached_property
to, IMO, get the best qualities of both.
if self._ext_type == "bounding_box": | ||
cmr_extent = ",".join(map(str, self._spatial_ext)) | ||
if self.extent_type == "bounding_box": | ||
return ",".join(map(str, self._spatial_ext)) |
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.
When there's an assignment like this, that tells me that something may be done to this variable after the conditional ends. Instead, return
tells the reader right away that nothing further will happen.
91bd9a8
to
b75d000
Compare
Important
To be merged only after merging #605 and rebasing
I'm happy to split this in to multiple PRs, but there's a lot of disparate changes here and I didn't want to flood the queue before showing you the whole pile. Let me know!