Skip to content

Commit

Permalink
ruff: Ignore the B018 rule (useless expressions) in examples (#3750)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jan 8, 2025
1 parent 0ba87ba commit 664a9ed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/gallery/images/rgb_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 # noqa: B018
image

# %%
# Plot the RGB imagery:
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/lines/linestrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Convert object to EPSG 4326 coordinate system
gdf = gdf.to_crs("EPSG:4326")
print(gdf.head())
gdf.head()

# %%
fig = pygmt.Figure()
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/maps/choropleth_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Read the example dataset provided by geodatasets.
gdf = gpd.read_file(geodatasets.get_path("geoda airbnb"))
print(gdf)
print(gdf.head())

# %%
fig = pygmt.Figure()
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/basics/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
# The data are loaded as a :class:`pandas.DataFrame`.

data = pygmt.datasets.load_sample_data(name="japan_quakes")
data.head()

# %%
# Set the region for the plot to be slightly larger than the data bounds.
region = [
data.longitude.min() - 1,
data.longitude.max() + 1,
data.latitude.min() - 1,
data.latitude.max() + 1,
]

print(region)
print(data.head())
region

# %%
# We'll use the :meth:`pygmt.Figure.plot` method to plot circles on the
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ known-third-party = ["pygmt"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Ignore `F401` (unused-import) in all `__init__.py` files
"*/tests/test_*.py" = ["S101"] # Ignore `S101` (use of assert) in all tests files
"examples/**/*.py" = ["T201"] # Allow `print` in examples
"examples/**/*.py" = [ # Ignore rules in examples
"B018", # Allow useless expressions in Jupyter Notebooks
"T201", # Allow `print` statements
]

[tool.ruff.lint.pycodestyle]
max-doc-length = 88
Expand Down

0 comments on commit 664a9ed

Please sign in to comment.