Skip to content

Commit 664a9ed

Browse files
authored
ruff: Ignore the B018 rule (useless expressions) in examples (#3750)
1 parent 0ba87ba commit 664a9ed

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

examples/gallery/images/rgb_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Subset to area of Lāhainā in EPSG:32604 coordinates
2929
image = img.rio.clip_box(minx=738000, maxx=755000, miny=2300000, maxy=2318000)
3030
image = image.load() # Force loading the DataArray into memory
31-
image # noqa: B018
31+
image
3232

3333
# %%
3434
# Plot the RGB imagery:

examples/gallery/lines/linestrings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# Convert object to EPSG 4326 coordinate system
2727
gdf = gdf.to_crs("EPSG:4326")
28-
print(gdf.head())
28+
gdf.head()
2929

3030
# %%
3131
fig = pygmt.Figure()

examples/gallery/maps/choropleth_map.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# Read the example dataset provided by geodatasets.
2222
gdf = gpd.read_file(geodatasets.get_path("geoda airbnb"))
23-
print(gdf)
23+
print(gdf.head())
2424

2525
# %%
2626
fig = pygmt.Figure()

examples/tutorials/basics/plot.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
# The data are loaded as a :class:`pandas.DataFrame`.
1919

2020
data = pygmt.datasets.load_sample_data(name="japan_quakes")
21+
data.head()
2122

23+
# %%
2224
# Set the region for the plot to be slightly larger than the data bounds.
2325
region = [
2426
data.longitude.min() - 1,
2527
data.longitude.max() + 1,
2628
data.latitude.min() - 1,
2729
data.latitude.max() + 1,
2830
]
29-
30-
print(region)
31-
print(data.head())
31+
region
3232

3333
# %%
3434
# We'll use the :meth:`pygmt.Figure.plot` method to plot circles on the

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ known-third-party = ["pygmt"]
160160
[tool.ruff.lint.per-file-ignores]
161161
"__init__.py" = ["F401"] # Ignore `F401` (unused-import) in all `__init__.py` files
162162
"*/tests/test_*.py" = ["S101"] # Ignore `S101` (use of assert) in all tests files
163-
"examples/**/*.py" = ["T201"] # Allow `print` in examples
163+
"examples/**/*.py" = [ # Ignore rules in examples
164+
"B018", # Allow useless expressions in Jupyter Notebooks
165+
"T201", # Allow `print` statements
166+
]
164167

165168
[tool.ruff.lint.pycodestyle]
166169
max-doc-length = 88

0 commit comments

Comments
 (0)