Skip to content

Commit 98d68f7

Browse files
authored
Enable more ruff linters (#753)
There are still some failing lints. Tomorrow we can fix a few more but mostly relax lints to be able to merge.
1 parent 8d21506 commit 98d68f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1245
-946
lines changed

Diff for: .github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
if: "${{ matrix.python-version == 3.11 }}"
7373
run: uv run --group docs mkdocs build --strict
7474

75+
# Use ruff-action so we get annotations in the Github UI
76+
- uses: astral-sh/ruff-action@v3
77+
7578
- name: Cache pre-commit virtualenvs
7679
uses: actions/cache@v4
7780
if: "${{ matrix.python-version == 3.11 }}"

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
args: ["--maxkb=5500"]
1919

2020
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: v0.3.4
21+
rev: v0.9.6
2222
hooks:
2323
- id: ruff
2424
args: ["--fix"]

Diff for: examples/ais-movingpandas.ipynb

+9-3
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
"outputs": [],
326326
"source": [
327327
"traj_collection = mpd.MinTimeDeltaGeneralizer(traj_collection).generalize(\n",
328-
" tolerance=timedelta(minutes=1)\n",
328+
" tolerance=timedelta(minutes=1),\n",
329329
")"
330330
]
331331
},
@@ -430,7 +430,10 @@
430430
],
431431
"source": [
432432
"trips_layer = TripsLayer.from_movingpandas(\n",
433-
" traj_collection, get_color=get_color, width_min_pixels=5, trail_length = 200\n",
433+
" traj_collection,\n",
434+
" get_color=get_color,\n",
435+
" width_min_pixels=5,\n",
436+
" trail_length=200,\n",
434437
")"
435438
]
436439
},
@@ -515,7 +518,10 @@
515518
"outputs": [],
516519
"source": [
517520
"linestring_layer = PathLayer(\n",
518-
" table=trips_layer.table, get_color=get_color, width_min_pixels=1, opacity=0.005\n",
521+
" table=trips_layer.table,\n",
522+
" get_color=get_color,\n",
523+
" width_min_pixels=1,\n",
524+
" opacity=0.005,\n",
519525
")"
520526
]
521527
},

Diff for: examples/clicked-point.ipynb

+12-7
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,23 @@
2828
"clicked_x_display = widgets.FloatText(description=\"last clicked x:\")\n",
2929
"clicked_y_display = widgets.FloatText(description=\"last clicked y:\")\n",
3030
"\n",
31-
"def on_map_click(coordinate:Tuple[float, float]) -> None:\n",
32-
" x,y = coordinate\n",
31+
"\n",
32+
"def on_map_click(coordinate: Tuple[float, float]) -> None:\n",
33+
" x, y = coordinate\n",
3334
" clicked_x_display.value = x\n",
3435
" clicked_y_display.value = y\n",
36+
"\n",
37+
"\n",
3538
"m.on_click(on_map_click)\n",
3639
"\n",
3740
"## show the widgets\n",
38-
"widgets.VBox([\n",
39-
" m,\n",
40-
" clicked_x_display,\n",
41-
" clicked_y_display\n",
42-
"])"
41+
"widgets.VBox(\n",
42+
" [\n",
43+
" m,\n",
44+
" clicked_x_display,\n",
45+
" clicked_y_display,\n",
46+
" ],\n",
47+
")"
4348
]
4449
}
4550
],

Diff for: examples/column-layer.ipynb

+14-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"outputs": [],
4848
"source": [
4949
"import geopandas as gpd\n",
50-
"from lonboard import Map, ColumnLayer"
50+
"\n",
51+
"from lonboard import ColumnLayer, Map"
5152
]
5253
},
5354
{
@@ -57,7 +58,7 @@
5758
"metadata": {},
5859
"outputs": [],
5960
"source": [
60-
"DATA_URL = 'https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson'"
61+
"DATA_URL = \"https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson\""
6162
]
6263
},
6364
{
@@ -78,10 +79,10 @@
7879
"outputs": [],
7980
"source": [
8081
"layer = ColumnLayer.from_geopandas(\n",
81-
" df, \n",
82-
" get_elevation=df[\"FUNDING_NUMERIC\"], \n",
83-
" get_fill_color = [255, 255, 0, 140],\n",
84-
" elevation_scale=.01,\n",
82+
" df,\n",
83+
" get_elevation=df[\"FUNDING_NUMERIC\"],\n",
84+
" get_fill_color=[255, 255, 0, 140],\n",
85+
" elevation_scale=0.01,\n",
8586
" radius=10000,\n",
8687
" pickable=True,\n",
8788
" auto_highlight=True,\n",
@@ -97,7 +98,13 @@
9798
"source": [
9899
"m = Map(\n",
99100
" layer,\n",
100-
" view_state={\"longitude\": -100, \"latitude\": 35, \"zoom\": 4, \"pitch\": 45, \"bearing\": 0},\n",
101+
" view_state={\n",
102+
" \"longitude\": -100,\n",
103+
" \"latitude\": 35,\n",
104+
" \"zoom\": 4,\n",
105+
" \"pitch\": 45,\n",
106+
" \"bearing\": 0,\n",
107+
" },\n",
101108
")\n",
102109
"m"
103110
]

Diff for: examples/data-filter-extension.ipynb

+27-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@
9696
" tile_geometries = shapely.from_wkt(df[\"tile\"])\n",
9797
" tile_centroids = shapely.centroid(tile_geometries)\n",
9898
" non_geom_columns = [col for col in columns if col != \"tile\"]\n",
99-
" gdf = gpd.GeoDataFrame(df[non_geom_columns], geometry=tile_centroids, crs=\"EPSG:4326\")\n",
99+
" gdf = gpd.GeoDataFrame(\n",
100+
" df[non_geom_columns],\n",
101+
" geometry=tile_centroids,\n",
102+
" crs=\"EPSG:4326\",\n",
103+
" )\n",
100104
" gdf.to_parquet(local_path)"
101105
]
102106
},
@@ -325,7 +329,7 @@
325329
"outputs": [],
326330
"source": [
327331
"filter_values = np.column_stack(\n",
328-
" [gdf[\"avg_d_kbps\"], gdf[\"avg_u_kbps\"], gdf[\"avg_lat_ms\"]]\n",
332+
" [gdf[\"avg_d_kbps\"], gdf[\"avg_u_kbps\"], gdf[\"avg_lat_ms\"]],\n",
329333
")\n",
330334
"initial_filter_range = [\n",
331335
" [10_000, 50_000],\n",
@@ -408,9 +412,27 @@
408412
}
409413
],
410414
"source": [
411-
"download_slider = FloatRangeSlider(value=initial_filter_range[0], min=0, max=70_000, step=0.1, description=\"Download: \")\n",
412-
"upload_slider = FloatRangeSlider(value=initial_filter_range[1], min=0, max=50_000, step=1, description=\"Upload: \")\n",
413-
"latency_slider = FloatRangeSlider(value=initial_filter_range[2], min=0, max=500, step=1, description=\"Latency: \")\n",
415+
"download_slider = FloatRangeSlider(\n",
416+
" value=initial_filter_range[0],\n",
417+
" min=0,\n",
418+
" max=70_000,\n",
419+
" step=0.1,\n",
420+
" description=\"Download: \",\n",
421+
")\n",
422+
"upload_slider = FloatRangeSlider(\n",
423+
" value=initial_filter_range[1],\n",
424+
" min=0,\n",
425+
" max=50_000,\n",
426+
" step=1,\n",
427+
" description=\"Upload: \",\n",
428+
")\n",
429+
"latency_slider = FloatRangeSlider(\n",
430+
" value=initial_filter_range[2],\n",
431+
" min=0,\n",
432+
" max=500,\n",
433+
" step=1,\n",
434+
" description=\"Latency: \",\n",
435+
")\n",
414436
"multi_slider = MultiRangeSlider([download_slider, upload_slider, latency_slider])\n",
415437
"multi_slider"
416438
]

Diff for: examples/duckdb.ipynb

+16-15
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"source": [
88
"# DuckDB Spatial\n",
99
"\n",
10-
"This is a short example notebook to show how to use [DuckDB Spatial](https://duckdb.org/docs/extensions/spatial.html) with Lonboard. We'll create a [HeatmapLayer](https://developmentseed.org/lonboard/latest/api/layers/heatmap-layer/) with NYC Taxi data. \n",
10+
"This is a short example notebook to show how to use [DuckDB Spatial](https://duckdb.org/docs/extensions/spatial.html) with Lonboard. We'll create a [HeatmapLayer](https://developmentseed.org/lonboard/latest/api/layers/heatmap-layer/) with NYC Taxi data.\n",
1111
"\n",
12-
"For full information on how to use DuckDB with Lonboard, [refer to the documentation](https://developmentseed.org/lonboard/latest/ecosystem/duckdb/)."
12+
"For full information on how to use DuckDB with Lonboard, [refer to the documentation](https://developmentseed.org/lonboard/latest/ecosystem/duckdb/).\n"
1313
]
1414
},
1515
{
@@ -22,7 +22,7 @@
2222
"id": "453b95d2-cb02-4507-bd4a-57ef30278298",
2323
"metadata": {},
2424
"source": [
25-
"![Screenshot 2024-05-06 at 12.55.26 PM.png](attachment:c90edb21-2f4c-4ca4-be23-e289fde13e6e.png)"
25+
"![Screenshot 2024-05-06 at 12.55.26 PM.png](attachment:c90edb21-2f4c-4ca4-be23-e289fde13e6e.png)\n"
2626
]
2727
},
2828
{
@@ -33,6 +33,7 @@
3333
"outputs": [],
3434
"source": [
3535
"import duckdb\n",
36+
"\n",
3637
"from lonboard import HeatmapLayer, Map"
3738
]
3839
},
@@ -41,7 +42,7 @@
4142
"id": "e89f04b2-0b22-4d8a-a7cd-9d37d4ac6323",
4243
"metadata": {},
4344
"source": [
44-
"Create a database connection and install and load the Spatial extension:"
45+
"Create a database connection and install and load the Spatial extension:\n"
4546
]
4647
},
4748
{
@@ -65,7 +66,7 @@
6566
"\n",
6667
"There are a few incorrect location values in this dataset with longitude/latitude near \"null island\" at (0, 0), so we pass in bounding-box filtering around the New York City region.\n",
6768
"\n",
68-
"Then we execute this query in our connection."
69+
"Then we execute this query in our connection.\n"
6970
]
7071
},
7172
{
@@ -77,10 +78,10 @@
7778
"source": [
7879
"sql = \"\"\"\n",
7980
"CREATE TABLE rides AS\n",
80-
"SELECT \n",
81+
"SELECT\n",
8182
" *,\n",
8283
" ST_Point(dropoff_longitude, dropoff_latitude) as geometry\n",
83-
"FROM \"https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2010-03.parquet\" \n",
84+
"FROM \"https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2010-03.parquet\"\n",
8485
"WHERE\n",
8586
" dropoff_longitude >= -74.6087 AND\n",
8687
" dropoff_latitude >= 40.2738 AND\n",
@@ -97,7 +98,7 @@
9798
"id": "53b67335-4560-41a7-8329-1cef2d952c84",
9899
"metadata": {},
99100
"source": [
100-
"Inspecting this table, we can see a variety of columns, plus our `geometry` column:"
101+
"Inspecting this table, we can see a variety of columns, plus our `geometry` column:\n"
101102
]
102103
},
103104
{
@@ -115,7 +116,7 @@
115116
"id": "85f78761-b1b8-49a1-be25-b13f104b6071",
116117
"metadata": {},
117118
"source": [
118-
"To pass this data into Lonboard, we can pass a string query or \"relation object\" into the `from_duckdb` class method, plus a reference to our connection. Here the `con.table(\"rides\")` call creates a relation that refers to the entire `rides` table."
119+
"To pass this data into Lonboard, we can pass a string query or \"relation object\" into the `from_duckdb` class method, plus a reference to our connection. Here the `con.table(\"rides\")` call creates a relation that refers to the entire `rides` table.\n"
119120
]
120121
},
121122
{
@@ -144,7 +145,7 @@
144145
"id": "9fbce4ad-02ce-406c-9003-93f084e5a5c3",
145146
"metadata": {},
146147
"source": [
147-
"DuckDB Spatial does not currently export coordinate reference system information, but in this case we know the data is already in the EPSG:4326 (WGS84) coordinate system, so we can ignore the generated warning."
148+
"DuckDB Spatial does not currently export coordinate reference system information, but in this case we know the data is already in the EPSG:4326 (WGS84) coordinate system, so we can ignore the generated warning.\n"
148149
]
149150
},
150151
{
@@ -154,7 +155,7 @@
154155
"source": [
155156
"The heatmap by default assigns a weight of 1 to each row, so the heatmap shows the unweighted density of rides. We can change this by modifying the [`get_weight`](https://developmentseed.org/lonboard/latest/api/layers/heatmap-layer/#lonboard.HeatmapLayer.get_weight) attribute.\n",
156157
"\n",
157-
"Let's weight the heatmap by the cost of the ride. We can do this by passing in a column from `total_amount`. We can access this column by selecting a table with only that data:"
158+
"Let's weight the heatmap by the cost of the ride. We can do this by passing in a column from `total_amount`. We can access this column by selecting a table with only that data:\n"
158159
]
159160
},
160161
{
@@ -172,7 +173,7 @@
172173
"id": "1d011e61-b82c-474f-972c-9c4bbb654895",
173174
"metadata": {},
174175
"source": [
175-
"We want a single column to pass in to the layer, so we select the `total_amount` column:"
176+
"We want a single column to pass in to the layer, so we select the `total_amount` column:\n"
176177
]
177178
},
178179
{
@@ -190,7 +191,7 @@
190191
"id": "c6483078-c296-40ff-ac5f-534cac768dee",
191192
"metadata": {},
192193
"source": [
193-
"Then we assign this onto the `get_weight` accessor"
194+
"Then we assign this onto the `get_weight` accessor\n"
194195
]
195196
},
196197
{
@@ -208,7 +209,7 @@
208209
"id": "1a9c8255-17ee-4f71-84a7-b33dd86c94dd",
209210
"metadata": {},
210211
"source": [
211-
"Note that the heatmap around airports such as LaGuardia is now darker. There are fewer total rides dropping off at the airport, but each one is expensive!"
212+
"Note that the heatmap around airports such as LaGuardia is now darker. There are fewer total rides dropping off at the airport, but each one is expensive!\n"
212213
]
213214
}
214215
],
@@ -228,7 +229,7 @@
228229
"name": "python",
229230
"nbconvert_exporter": "python",
230231
"pygments_lexer": "ipython3",
231-
"version": "3.11.4"
232+
"version": "3.11.8"
232233
},
233234
"widgets": {
234235
"application/vnd.jupyter.widget-state+json": {

Diff for: examples/global-boundaries.ipynb

+9-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
},
102102
{
103103
"cell_type": "code",
104-
"execution_count": 4,
104+
"execution_count": null,
105105
"id": "510879f3-b6b3-475e-9e59-7eef526dbf25",
106106
"metadata": {
107107
"scrolled": true
@@ -117,13 +117,15 @@
117117
" total_size = int(response.headers.get(\"content-length\", 0))\n",
118118
" block_size = 1024\n",
119119
"\n",
120-
" with tqdm(total=total_size, unit=\"B\", unit_scale=True) as progress_bar:\n",
121-
" with open(filepath, \"wb\") as file:\n",
122-
" for data in response.iter_content(block_size):\n",
123-
" progress_bar.update(len(data))\n",
124-
" file.write(data)\n",
120+
" with (\n",
121+
" tqdm(total=total_size, unit=\"B\", unit_scale=True) as progress_bar,\n",
122+
" open(filepath, \"wb\") as file,\n",
123+
" ):\n",
124+
" for data in response.iter_content(block_size):\n",
125+
" progress_bar.update(len(data))\n",
126+
" file.write(data)\n",
125127
"\n",
126-
" if total_size != 0 and progress_bar.n != total_size:\n",
128+
" if total_size not in (0, progress_bar.n):\n",
127129
" raise RuntimeError(\"Could not download file\")"
128130
]
129131
},

Diff for: examples/integrations/color-picker.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@
232232
],
233233
"source": [
234234
"ipywidgets.dlink(\n",
235-
" (color_picker, 'value'),\n",
236-
" (layer, 'get_fill_color')\n",
235+
" (color_picker, \"value\"),\n",
236+
" (layer, \"get_fill_color\"),\n",
237237
")"
238238
]
239239
},

0 commit comments

Comments
 (0)