Skip to content
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 linting #1158

Merged
merged 10 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Tests
on:
push:
branches:
- master
- master
pull_request:
branches:
- master
- master

defaults:
run:
Expand All @@ -23,35 +23,35 @@ jobs:
python-version: [3.8]

steps:
- uses: actions/checkout@v2

- name: Setup conda
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
condarc: |
dependencies:
- python==${{ matrix.python-version }}

- name: Install ipyleaflet
run: pip install . --no-deps

- name: Check installation files
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet/package.json

- name: Python Linters
run: flake8 ipyleaflet --ignore=E501,E731

- name: JS Linters
run: |
yarn install
yarn run lint:check
working-directory: js

- name: Import check
run: python -c 'import ipyleaflet'
- uses: actions/checkout@v2

- name: Setup conda
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
condarc: |
dependencies:
- python==${{ matrix.python-version }}

- name: Install ipyleaflet
run: pip install . --no-deps

- name: Check installation files
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-leaflet/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-leaflet/package.json

- name: Python Linters
run: ruff check --output-format=github .

- name: JS Linters
run: |
yarn install
yarn run lint:check
working-directory: js

- name: Import check
run: python -c 'import ipyleaflet'
70 changes: 38 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# -*- coding: utf-8 -*-

extensions = [
'jupyter_sphinx', 'jupyterlite_sphinx', 'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon','sphinx.ext.todo', 'sphinx.ext.viewcode'
"jupyter_sphinx",
"jupyterlite_sphinx",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
]

templates_path = ['_templates']
templates_path = ["_templates"]

jupyterlite_dir = "."
jupyterlite_contents = [
Expand All @@ -17,71 +23,71 @@
"../../examples/AntPath.ipynb",
"../../examples/AwesomeIcons.ipynb",
"../../examples/BaseMap.ipynb",
# "../../examples/CanvasRenderer.ipynb", # no python wheel for shapely
# "../../examples/CanvasRenderer.ipynb", # no python wheel for shapely
"../../examples/Choropleth.ipynb",
"../../examples/Choropleth_with_NANS.ipynb",
# "../../examples/CountriesGeoJSON.ipynb", # cannot access ./europe_110.geo.json
# "../../examples/CountriesGeoJSON.ipynb", # cannot access ./europe_110.geo.json
"../../examples/CustomProjections.ipynb",
"../../examples/CustomTMS.ipynb",
# "../../examples/CustomTileServer.ipynb", # Some problem with flask: 'DummyMod' object has no attribute 'startswith'
# "../../examples/CustomTileServer.ipynb", # Some problem with flask: 'DummyMod' object has no attribute 'startswith'
"../../examples/DrawControl.ipynb",
"../../examples/DropdownControl.ipynb",
"../../examples/Fullscreen.ipynb",
# "../../examples/GPX.ipynb", # error installing geopandas (missing wheel for pyproj)
# "../../examples/GeoData.ipynb", # error installing geopandas (missing wheel for pyproj)
# "../../examples/GeoData_on_hover.ipynb", # error installing geopandas (missing wheel for pyproj)
# "../../examples/GPX.ipynb", # error installing geopandas (missing wheel for pyproj)
# "../../examples/GeoData.ipynb", # error installing geopandas (missing wheel for pyproj)
# "../../examples/GeoData_on_hover.ipynb", # error installing geopandas (missing wheel for pyproj)
"../../examples/GeoJSON.ipynb",
# "../../examples/GeoJson_EU_on_hover.ipynb", # cannot load file europe_110.geo.json
# "../../examples/GeoJson_EU_on_hover.ipynb", # cannot load file europe_110.geo.json
"../../examples/Heatmap.ipynb",
# "../../examples/Image_slider.ipynb", # error installing rasterio
# "../../examples/KML.ipynb", # error installing geopandas
# "../../examples/Image_slider.ipynb", # error installing rasterio
# "../../examples/KML.ipynb", # error installing geopandas
"../../examples/LayerGroup.ipynb",
"../../examples/LegendControl.ipynb",
"../../examples/MagnifyingGlass.ipynb",
"../../examples/MapContainer.ipynb",
"../../examples/MapCursorStyle.ipynb",
"../../examples/MapPanes.ipynb", # This works even though it also needs the europe_110.geo.json, so check example above again!
# "../../examples/MarkerCluster-GeoJson.ipynb", # error installing geopandas
# "../../examples/MarkerCluster.ipynb", #error install geopandas
# "../../examples/Max_zoom.ipynb", # test again - not sure if localtileserver package has problems
"../../examples/MapPanes.ipynb", # This works even though it also needs the europe_110.geo.json, so check example above again!
# "../../examples/MarkerCluster-GeoJson.ipynb", # error installing geopandas
# "../../examples/MarkerCluster.ipynb", #error install geopandas
# "../../examples/Max_zoom.ipynb", # test again - not sure if localtileserver package has problems
"../../examples/MeasureControl.ipynb",
# "../../examples/Numpy.ipynb", # error installing reasterio
# "../../examples/Numpy.ipynb", # error installing reasterio
"../../examples/Primitives.ipynb",
"../../examples/Radiation.ipynb",
"../../examples/ScaleControl.ipynb",
# "../../examples/SearchControl.ipynb", # error installing shapely. Looks like reading a file works if it is readonly (opened with "r")
# "../../examples/SearchControl.ipynb", # error installing shapely. Looks like reading a file works if it is readonly (opened with "r")
"../../examples/Select-GeoJson.ipynb",
"../../examples/SplitMap.ipynb",
"../../examples/TileLayer-loading.ipynb",
"../../examples/Transform.ipynb",
"../../examples/VectorTiles.ipynb",
# "../../examples/Velocity.ipynb", # seems like issues with downloading wind-global.nc dataset? Takes a long time
# "../../examples/Video.ipynb", # error installing rasterio
# "../../examples/WKTLayer.ipynb", #error importing shapely
# "../../examples/Velocity.ipynb", # seems like issues with downloading wind-global.nc dataset? Takes a long time
# "../../examples/Video.ipynb", # error installing rasterio
# "../../examples/WKTLayer.ipynb", #error importing shapely
"../../examples/WMSLayer.ipynb",
# "../../examples/WealthOfNations.ipynb", # did not install bqplot widget as a federated extension?
# "../../examples/WealthOfNations.ipynb", # did not install bqplot widget as a federated extension?
"../../examples/WidgetControl.ipynb",
]

# Output file base name for HTML help builder.
html_theme = "pydata_sphinx_theme"
#html_theme_path = [pydata_sphinx_theme.get_html_theme_path()]
htmlhelp_basename = 'ipyleafletdoc'
html_static_path = ['_static']
# html_theme_path = [pydata_sphinx_theme.get_html_theme_path()]
htmlhelp_basename = "ipyleafletdoc"
html_static_path = ["_static"]


def setup(app):
app.add_css_file("main_stylesheet.css")

master_doc = 'index'
source_suffix = '.rst'

master_doc = "index"
source_suffix = ".rst"

# General information about the project.
project = 'ipyleaflet'
copyright = '(c) Jupyter Development Team'
author = 'Jupyter Development Team'
project = "ipyleaflet"
copyright = "(c) Jupyter Development Team"
author = "Jupyter Development Team"

exclude_patterns = []
highlight_language = 'python'
pygments_style = 'sphinx'

highlight_language = "python"
pygments_style = "sphinx"
4 changes: 3 additions & 1 deletion docs/ipyleaflet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outputs": [],
"source": [
"from ipyleaflet import Map, Marker\n",
"\n",
"center = (52.204793, 360.121558)\n",
"map = Map(center=center, zoom=12)\n",
"\n",
Expand Down Expand Up @@ -42,8 +43,9 @@
"def on_location_changed(value):\n",
" map.center = value.new\n",
"\n",
"\n",
"# Call the on_location_changed function when marker.location changes\n",
"marker.observe(on_location_changed, 'location')"
"marker.observe(on_location_changed, \"location\")"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ channels:
dependencies:
- pip
- wheel
- flake8
- jupyterlab~=4.0
- jupyter-packaging~=0.12
- ipywidgets
Expand All @@ -13,3 +12,4 @@ dependencies:
- traittypes
- pandas
- yarn~=3.0
- ruff
2 changes: 1 addition & 1 deletion examples/CanvasRenderer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"m = Map(center=(48.1, 17.1), zoom=8, prefer_canvas=True)\n",
"\n",
"gdf = geopandas.GeoDataFrame(\n",
" geometry=[shapely.geometry.Point(l) for l in random_locs], crs=\"EPSG:4326\"\n",
" geometry=[shapely.geometry.Point(loc) for loc in random_locs], crs=\"EPSG:4326\"\n",
")\n",
"\n",
"geo_data = GeoData(\n",
Expand Down
4 changes: 1 addition & 3 deletions examples/Choropleth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@
" State name:\n",
" <b>{}\\n</b>\n",
" {}\n",
" \"\"\".format(\n",
" id, feature[\"properties\"][\"name\"]\n",
" )\n",
" \"\"\".format(id, feature[\"properties\"][\"name\"])\n",
"\n",
"\n",
"layer.on_hover(update_html)"
Expand Down
6 changes: 3 additions & 3 deletions examples/Choropleth_with_NANS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
" geo_data=geo_json_data,\n",
" choro_data=data_unemployment,\n",
" colormap=colormap_choice,\n",
" style={\"dashArray\": \"5, 5\"}\n",
" style={\"dashArray\": \"5, 5\"},\n",
")"
]
},
Expand All @@ -58,7 +58,7 @@
"out = Output()\n",
"\n",
"with out:\n",
" colormap = colormap_choice.scale(layer.value_min,layer.value_max)\n",
" colormap = colormap_choice.scale(layer.value_min, layer.value_max)\n",
" display(colormap)"
]
},
Expand All @@ -69,7 +69,7 @@
"outputs": [],
"source": [
"m.add(layer)\n",
"m.add(WidgetControl(widget=out, position='topright'))\n",
"m.add(WidgetControl(widget=out, position=\"topright\"))\n",
"m"
]
}
Expand Down
6 changes: 3 additions & 3 deletions examples/ColormapControl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"outputs": [],
"source": [
"colormap_control = ipyleaflet.ColormapControl(\n",
" caption='Unemployment rate',\n",
" caption=\"Unemployment rate\",\n",
" colormap=colormap,\n",
" value_min=layer.value_min,\n",
" value_max=layer.value_max,\n",
" position='topright',\n",
" transparent_bg=True\n",
" position=\"topright\",\n",
" transparent_bg=True,\n",
")"
]
},
Expand Down
10 changes: 5 additions & 5 deletions examples/CustomProjections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
"\n",
"# MODIS Mosaic of Antarctica (MOA)\n",
"MOA3031 = dict(\n",
" name='EPSG:3031',\n",
" name=\"EPSG:3031\",\n",
" custom=True,\n",
" proj4def=\"\"\"+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1\n",
" +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs\"\"\",\n",
" bounds=[[-3174450,-2816050],[2867175,2406325]]\n",
" bounds=[[-3174450, -2816050], [2867175, 2406325]],\n",
")\n",
"\n",
"MOA = WMSLayer(\n",
Expand All @@ -83,11 +83,11 @@
" National Aeronautics and Space Administration (NASA)\n",
" \"\"\",\n",
" layers=\"MOA_125_HP1_090_230\",\n",
" format='image/png',\n",
" format=\"image/png\",\n",
" transparent=False,\n",
" opacity=0.5,\n",
" url='https://nimbus.cr.usgs.gov/arcgis/services/Antarctica/USGS_EROS_Antarctica_Reference/MapServer/WmsServer',\n",
" crs=MOA3031\n",
" url=\"https://nimbus.cr.usgs.gov/arcgis/services/Antarctica/USGS_EROS_Antarctica_Reference/MapServer/WmsServer\",\n",
" crs=MOA3031,\n",
")\n",
"m2.add(MOA)\n",
"\n",
Expand Down
3 changes: 2 additions & 1 deletion examples/DropdownControl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
" name = item[\"name\"]\n",
" basemap = \"basemaps.{}\".format(name)\n",
" ee_basemaps[name] = basemap_to_tiles(eval(basemap))\n",
" except:\n",
" except Exception as e:\n",
" for sub_item in item:\n",
" name = item[sub_item][\"name\"]\n",
" basemap = \"basemaps.{}\".format(name)\n",
Expand All @@ -40,6 +40,7 @@
" description=\"Basemaps\",\n",
")\n",
"\n",
"\n",
"# Handles Dropdown control event\n",
"def on_click(change):\n",
" basemap_name = change[\"new\"]\n",
Expand Down
4 changes: 1 addition & 3 deletions examples/GeoJson_EU_on_hover.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
" <h4>EU population density</h4>\n",
" <h4><b>{}</b></h4>\n",
" {} people / mi^2\n",
" \"\"\".format(\n",
" feature[\"properties\"][\"name\"], feature[\"properties\"][\"pop_est\"]\n",
" )\n",
" \"\"\".format(feature[\"properties\"][\"name\"], feature[\"properties\"][\"pop_est\"])\n",
"\n",
"\n",
"geo_json.on_hover(update_html)"
Expand Down
Loading