-
Notifications
You must be signed in to change notification settings - Fork 218
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
Enable ruff's flake8-bugbear (B) rules #2825
Conversation
examples/gallery/images/rgb_image.py
Outdated
@@ -28,7 +28,7 @@ | |||
# Subset to area of Lāhainā in EPSG:32604 coordinates | |||
image = img.rio.clip_box(minx=738000, maxx=755000, miny=2300000, maxy=2318000) | |||
image = image.load() # Force loading the DataArray into memory | |||
image | |||
print(image) |
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 now shows the plaintext version of the xarray.DataArray instead of the repr - https://pygmt-dev--2825.org.readthedocs.build/en/2825/gallery/images/rgb_image.html#sphx-glr-gallery-images-rgb-image-py. Maybe try
print(image) | |
repr(image) |
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.
It looks worse now.
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.
The fancy representation on this page (https://www.pygmt.org/dev/gallery/images/rgb_image.html#sphx-glr-gallery-images-rgb-image-py) is done by the xarray.DataArray's _repr_html_
method (https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display), which is different the repr
function.
Our options:
- Use
print(image)
- Completely remove
imgae
- Ignore the error
image # noqa: B018
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.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Description of proposed changes
Related to #2741.
Enabling flake8-bugbear rules result in following errors and they look good to me. Actually, some of the errors were reported by pylint but not by ruff's pylint rules (see #2815).
Fixes #
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version