Skip to content

Commit 4d3d6c1

Browse files
Ruff linting (#1158)
* Add Black * Run Black * Run Black again * Add Notebooks to format workflow * Format notebooks * Remove extraneous source option * Switch from Black to Ruff * Lint with Ruff * Notebook fix * Update Playwright Snapshots --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c26f630 commit 4d3d6c1

Some content is hidden

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

50 files changed

+1064
-787
lines changed

.github/workflows/main.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Tests
33
on:
44
push:
55
branches:
6-
- master
6+
- master
77
pull_request:
88
branches:
9-
- master
9+
- master
1010

1111
defaults:
1212
run:
@@ -23,35 +23,35 @@ jobs:
2323
python-version: [3.8]
2424

2525
steps:
26-
- uses: actions/checkout@v2
27-
28-
- name: Setup conda
29-
uses: mamba-org/setup-micromamba@v1
30-
with:
31-
environment-file: environment-dev.yml
32-
condarc: |
33-
dependencies:
34-
- python==${{ matrix.python-version }}
35-
36-
- name: Install ipyleaflet
37-
run: pip install . --no-deps
38-
39-
- name: Check installation files
40-
run: |
41-
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet
42-
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/extension.js
43-
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/index.js
44-
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet
45-
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet/package.json
46-
47-
- name: Python Linters
48-
run: flake8 ipyleaflet --ignore=E501,E731
49-
50-
- name: JS Linters
51-
run: |
52-
yarn install
53-
yarn run lint:check
54-
working-directory: js
55-
56-
- name: Import check
57-
run: python -c 'import ipyleaflet'
26+
- uses: actions/checkout@v2
27+
28+
- name: Setup conda
29+
uses: mamba-org/setup-micromamba@v1
30+
with:
31+
environment-file: environment-dev.yml
32+
condarc: |
33+
dependencies:
34+
- python==${{ matrix.python-version }}
35+
36+
- name: Install ipyleaflet
37+
run: pip install . --no-deps
38+
39+
- name: Check installation files
40+
run: |
41+
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet
42+
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/extension.js
43+
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/index.js
44+
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet
45+
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet/package.json
46+
47+
- name: Python Linters
48+
run: ruff check --output-format=github .
49+
50+
- name: JS Linters
51+
run: |
52+
yarn install
53+
yarn run lint:check
54+
working-directory: js
55+
56+
- name: Import check
57+
run: python -c 'import ipyleaflet'

docs/conf.py

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# -*- coding: utf-8 -*-
22

33
extensions = [
4-
'jupyter_sphinx', 'jupyterlite_sphinx', 'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon','sphinx.ext.todo', 'sphinx.ext.viewcode'
4+
"jupyter_sphinx",
5+
"jupyterlite_sphinx",
6+
"sphinx.ext.autodoc",
7+
"sphinx.ext.coverage",
8+
"sphinx.ext.napoleon",
9+
"sphinx.ext.todo",
10+
"sphinx.ext.viewcode",
511
]
612

7-
templates_path = ['_templates']
13+
templates_path = ["_templates"]
814

915
jupyterlite_dir = "."
1016
jupyterlite_contents = [
@@ -17,71 +23,71 @@
1723
"../../examples/AntPath.ipynb",
1824
"../../examples/AwesomeIcons.ipynb",
1925
"../../examples/BaseMap.ipynb",
20-
# "../../examples/CanvasRenderer.ipynb", # no python wheel for shapely
26+
# "../../examples/CanvasRenderer.ipynb", # no python wheel for shapely
2127
"../../examples/Choropleth.ipynb",
2228
"../../examples/Choropleth_with_NANS.ipynb",
23-
# "../../examples/CountriesGeoJSON.ipynb", # cannot access ./europe_110.geo.json
29+
# "../../examples/CountriesGeoJSON.ipynb", # cannot access ./europe_110.geo.json
2430
"../../examples/CustomProjections.ipynb",
2531
"../../examples/CustomTMS.ipynb",
26-
# "../../examples/CustomTileServer.ipynb", # Some problem with flask: 'DummyMod' object has no attribute 'startswith'
32+
# "../../examples/CustomTileServer.ipynb", # Some problem with flask: 'DummyMod' object has no attribute 'startswith'
2733
"../../examples/DrawControl.ipynb",
2834
"../../examples/DropdownControl.ipynb",
2935
"../../examples/Fullscreen.ipynb",
30-
# "../../examples/GPX.ipynb", # error installing geopandas (missing wheel for pyproj)
31-
# "../../examples/GeoData.ipynb", # error installing geopandas (missing wheel for pyproj)
32-
# "../../examples/GeoData_on_hover.ipynb", # error installing geopandas (missing wheel for pyproj)
36+
# "../../examples/GPX.ipynb", # error installing geopandas (missing wheel for pyproj)
37+
# "../../examples/GeoData.ipynb", # error installing geopandas (missing wheel for pyproj)
38+
# "../../examples/GeoData_on_hover.ipynb", # error installing geopandas (missing wheel for pyproj)
3339
"../../examples/GeoJSON.ipynb",
34-
# "../../examples/GeoJson_EU_on_hover.ipynb", # cannot load file europe_110.geo.json
40+
# "../../examples/GeoJson_EU_on_hover.ipynb", # cannot load file europe_110.geo.json
3541
"../../examples/Heatmap.ipynb",
36-
# "../../examples/Image_slider.ipynb", # error installing rasterio
37-
# "../../examples/KML.ipynb", # error installing geopandas
42+
# "../../examples/Image_slider.ipynb", # error installing rasterio
43+
# "../../examples/KML.ipynb", # error installing geopandas
3844
"../../examples/LayerGroup.ipynb",
3945
"../../examples/LegendControl.ipynb",
4046
"../../examples/MagnifyingGlass.ipynb",
4147
"../../examples/MapContainer.ipynb",
4248
"../../examples/MapCursorStyle.ipynb",
43-
"../../examples/MapPanes.ipynb", # This works even though it also needs the europe_110.geo.json, so check example above again!
44-
# "../../examples/MarkerCluster-GeoJson.ipynb", # error installing geopandas
45-
# "../../examples/MarkerCluster.ipynb", #error install geopandas
46-
# "../../examples/Max_zoom.ipynb", # test again - not sure if localtileserver package has problems
49+
"../../examples/MapPanes.ipynb", # This works even though it also needs the europe_110.geo.json, so check example above again!
50+
# "../../examples/MarkerCluster-GeoJson.ipynb", # error installing geopandas
51+
# "../../examples/MarkerCluster.ipynb", #error install geopandas
52+
# "../../examples/Max_zoom.ipynb", # test again - not sure if localtileserver package has problems
4753
"../../examples/MeasureControl.ipynb",
48-
# "../../examples/Numpy.ipynb", # error installing reasterio
54+
# "../../examples/Numpy.ipynb", # error installing reasterio
4955
"../../examples/Primitives.ipynb",
5056
"../../examples/Radiation.ipynb",
5157
"../../examples/ScaleControl.ipynb",
52-
# "../../examples/SearchControl.ipynb", # error installing shapely. Looks like reading a file works if it is readonly (opened with "r")
58+
# "../../examples/SearchControl.ipynb", # error installing shapely. Looks like reading a file works if it is readonly (opened with "r")
5359
"../../examples/Select-GeoJson.ipynb",
5460
"../../examples/SplitMap.ipynb",
5561
"../../examples/TileLayer-loading.ipynb",
5662
"../../examples/Transform.ipynb",
5763
"../../examples/VectorTiles.ipynb",
58-
# "../../examples/Velocity.ipynb", # seems like issues with downloading wind-global.nc dataset? Takes a long time
59-
# "../../examples/Video.ipynb", # error installing rasterio
60-
# "../../examples/WKTLayer.ipynb", #error importing shapely
64+
# "../../examples/Velocity.ipynb", # seems like issues with downloading wind-global.nc dataset? Takes a long time
65+
# "../../examples/Video.ipynb", # error installing rasterio
66+
# "../../examples/WKTLayer.ipynb", #error importing shapely
6167
"../../examples/WMSLayer.ipynb",
62-
# "../../examples/WealthOfNations.ipynb", # did not install bqplot widget as a federated extension?
68+
# "../../examples/WealthOfNations.ipynb", # did not install bqplot widget as a federated extension?
6369
"../../examples/WidgetControl.ipynb",
6470
]
6571

6672
# Output file base name for HTML help builder.
6773
html_theme = "pydata_sphinx_theme"
68-
#html_theme_path = [pydata_sphinx_theme.get_html_theme_path()]
69-
htmlhelp_basename = 'ipyleafletdoc'
70-
html_static_path = ['_static']
74+
# html_theme_path = [pydata_sphinx_theme.get_html_theme_path()]
75+
htmlhelp_basename = "ipyleafletdoc"
76+
html_static_path = ["_static"]
7177

7278

7379
def setup(app):
7480
app.add_css_file("main_stylesheet.css")
7581

76-
master_doc = 'index'
77-
source_suffix = '.rst'
82+
83+
master_doc = "index"
84+
source_suffix = ".rst"
7885

7986
# General information about the project.
80-
project = 'ipyleaflet'
81-
copyright = '(c) Jupyter Development Team'
82-
author = 'Jupyter Development Team'
87+
project = "ipyleaflet"
88+
copyright = "(c) Jupyter Development Team"
89+
author = "Jupyter Development Team"
8390

8491
exclude_patterns = []
85-
highlight_language = 'python'
86-
pygments_style = 'sphinx'
87-
92+
highlight_language = "python"
93+
pygments_style = "sphinx"

docs/ipyleaflet.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"outputs": [],
99
"source": [
1010
"from ipyleaflet import Map, Marker\n",
11+
"\n",
1112
"center = (52.204793, 360.121558)\n",
1213
"map = Map(center=center, zoom=12)\n",
1314
"\n",
@@ -42,8 +43,9 @@
4243
"def on_location_changed(value):\n",
4344
" map.center = value.new\n",
4445
"\n",
46+
"\n",
4547
"# Call the on_location_changed function when marker.location changes\n",
46-
"marker.observe(on_location_changed, 'location')"
48+
"marker.observe(on_location_changed, \"location\")"
4749
]
4850
}
4951
],

environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ channels:
44
dependencies:
55
- pip
66
- wheel
7-
- flake8
87
- jupyterlab~=4.0
98
- jupyter-packaging~=0.12
109
- ipywidgets
@@ -13,3 +12,4 @@ dependencies:
1312
- traittypes
1413
- pandas
1514
- yarn~=3.0
15+
- ruff

examples/CanvasRenderer.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"m = Map(center=(48.1, 17.1), zoom=8, prefer_canvas=True)\n",
4040
"\n",
4141
"gdf = geopandas.GeoDataFrame(\n",
42-
" geometry=[shapely.geometry.Point(l) for l in random_locs], crs=\"EPSG:4326\"\n",
42+
" geometry=[shapely.geometry.Point(loc) for loc in random_locs], crs=\"EPSG:4326\"\n",
4343
")\n",
4444
"\n",
4545
"geo_data = GeoData(\n",

examples/Choropleth.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@
166166
" State name:\n",
167167
" <b>{}\\n</b>\n",
168168
" {}\n",
169-
" \"\"\".format(\n",
170-
" id, feature[\"properties\"][\"name\"]\n",
171-
" )\n",
169+
" \"\"\".format(id, feature[\"properties\"][\"name\"])\n",
172170
"\n",
173171
"\n",
174172
"layer.on_hover(update_html)"

examples/Choropleth_with_NANS.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
" geo_data=geo_json_data,\n",
4242
" choro_data=data_unemployment,\n",
4343
" colormap=colormap_choice,\n",
44-
" style={\"dashArray\": \"5, 5\"}\n",
44+
" style={\"dashArray\": \"5, 5\"},\n",
4545
")"
4646
]
4747
},
@@ -58,7 +58,7 @@
5858
"out = Output()\n",
5959
"\n",
6060
"with out:\n",
61-
" colormap = colormap_choice.scale(layer.value_min,layer.value_max)\n",
61+
" colormap = colormap_choice.scale(layer.value_min, layer.value_max)\n",
6262
" display(colormap)"
6363
]
6464
},
@@ -69,7 +69,7 @@
6969
"outputs": [],
7070
"source": [
7171
"m.add(layer)\n",
72-
"m.add(WidgetControl(widget=out, position='topright'))\n",
72+
"m.add(WidgetControl(widget=out, position=\"topright\"))\n",
7373
"m"
7474
]
7575
}

examples/ColormapControl.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
"outputs": [],
5050
"source": [
5151
"colormap_control = ipyleaflet.ColormapControl(\n",
52-
" caption='Unemployment rate',\n",
52+
" caption=\"Unemployment rate\",\n",
5353
" colormap=colormap,\n",
5454
" value_min=layer.value_min,\n",
5555
" value_max=layer.value_max,\n",
56-
" position='topright',\n",
57-
" transparent_bg=True\n",
56+
" position=\"topright\",\n",
57+
" transparent_bg=True,\n",
5858
")"
5959
]
6060
},

examples/CustomProjections.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070
"\n",
7171
"# MODIS Mosaic of Antarctica (MOA)\n",
7272
"MOA3031 = dict(\n",
73-
" name='EPSG:3031',\n",
73+
" name=\"EPSG:3031\",\n",
7474
" custom=True,\n",
7575
" proj4def=\"\"\"+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1\n",
7676
" +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs\"\"\",\n",
77-
" bounds=[[-3174450,-2816050],[2867175,2406325]]\n",
77+
" bounds=[[-3174450, -2816050], [2867175, 2406325]],\n",
7878
")\n",
7979
"\n",
8080
"MOA = WMSLayer(\n",
@@ -83,11 +83,11 @@
8383
" National Aeronautics and Space Administration (NASA)\n",
8484
" \"\"\",\n",
8585
" layers=\"MOA_125_HP1_090_230\",\n",
86-
" format='image/png',\n",
86+
" format=\"image/png\",\n",
8787
" transparent=False,\n",
8888
" opacity=0.5,\n",
89-
" url='https://nimbus.cr.usgs.gov/arcgis/services/Antarctica/USGS_EROS_Antarctica_Reference/MapServer/WmsServer',\n",
90-
" crs=MOA3031\n",
89+
" url=\"https://nimbus.cr.usgs.gov/arcgis/services/Antarctica/USGS_EROS_Antarctica_Reference/MapServer/WmsServer\",\n",
90+
" crs=MOA3031,\n",
9191
")\n",
9292
"m2.add(MOA)\n",
9393
"\n",

examples/DropdownControl.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
" name = item[\"name\"]\n",
2727
" basemap = \"basemaps.{}\".format(name)\n",
2828
" ee_basemaps[name] = basemap_to_tiles(eval(basemap))\n",
29-
" except:\n",
29+
" except Exception as e:\n",
3030
" for sub_item in item:\n",
3131
" name = item[sub_item][\"name\"]\n",
3232
" basemap = \"basemaps.{}\".format(name)\n",
@@ -40,6 +40,7 @@
4040
" description=\"Basemaps\",\n",
4141
")\n",
4242
"\n",
43+
"\n",
4344
"# Handles Dropdown control event\n",
4445
"def on_click(change):\n",
4546
" basemap_name = change[\"new\"]\n",

0 commit comments

Comments
 (0)