-
Notifications
You must be signed in to change notification settings - Fork 224
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
ruff: Ignore the B018 rule (useless expressions) in examples #3750
Conversation
@@ -20,7 +20,7 @@ | |||
|
|||
# Read the example dataset provided by geodatasets. | |||
gdf = gpd.read_file(geodatasets.get_path("geoda airbnb")) | |||
print(gdf) | |||
gdf |
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.
gdf | |
gdf.head() |
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.
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.
Good suggestion. Done in 7e2cace.
@@ -25,7 +25,7 @@ | |||
|
|||
# Convert object to EPSG 4326 coordinate system | |||
gdf = gdf.to_crs("EPSG:4326") | |||
print(gdf.head()) | |||
gdf.head() |
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.
Hm. My background off using print
was that if running the complete script as "normal" Python script no output is shown, only when running this specific section separately (see comment #3711 (comment)).
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.
Yes, output the data head information makes little sense when running the example as a normal Python script.
For this example, we have the # %%
cell separator at line 30, so the gdf.head
information will be shown in the docs.
Our examples are written as Python scripts but are rendered like Jupyter Notebooks.
In Notebooks, the expression in the last notebook cell will be evaluated and printed as the cell's output, which is commonly used, but ruff complains that the expressions are unused (B018), thus we have to use
print
instead.In this PR, the rule
B018
is ignored in examples.Previews: