Skip to content

Commit

Permalink
update pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Nov 24, 2024
1 parent 09d6c2e commit cf46a70
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [markdown, yaml]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: "v0.42.0"
rev: "v0.43.0"
hooks:
- id: markdownlint
args: [--disable=MD013]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.4"
rev: "v0.8.0"
hooks:
- id: ruff
args: [--fix]
Expand Down
4 changes: 2 additions & 2 deletions osmnx/_overpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import numpy as np
import requests
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError as RequestsConnectionError

from . import _http
from . import projection
Expand Down Expand Up @@ -179,7 +179,7 @@ def _get_overpass_pause(
**settings.requests_kwargs,
)
response_text = response.text
except ConnectionError as e: # pragma: no cover
except RequestsConnectionError as e: # pragma: no cover
# cannot reach status endpoint: log error and return default duration
msg = f"Unable to query {url}, {e}"
utils.log(msg, level=lg.ERROR)
Expand Down
6 changes: 3 additions & 3 deletions osmnx/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
from matplotlib import cm
from matplotlib import colormaps
from matplotlib import colors
from matplotlib.axes._axes import Axes # noqa: TCH002
from matplotlib.figure import Figure # noqa: TCH002
from matplotlib.projections.polar import PolarAxes # noqa: TCH002
from matplotlib.axes._axes import Axes # noqa: TC002
from matplotlib.figure import Figure # noqa: TC002
from matplotlib.projections.polar import PolarAxes # noqa: TC002

mpl_available = True

Expand Down
14 changes: 7 additions & 7 deletions osmnx/simplification.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,17 @@ def simplify_graph( # noqa: C901, PLR0912
path_attributes[attr] = [edge_data[attr]]

# consolidate the path's edge segments' attribute values
for attr in path_attributes:
if attr in edge_attr_aggs:
for attr_name, attr_values in path_attributes.items():
if attr_name in edge_attr_aggs:
# if this attribute's values must be aggregated, do so now
agg_func = edge_attr_aggs[attr]
path_attributes[attr] = agg_func(path_attributes[attr])
elif len(set(path_attributes[attr])) == 1:
agg_func = edge_attr_aggs[attr_name]
path_attributes[attr_name] = agg_func(attr_values)
elif len(set(attr_values)) == 1:
# if there's only 1 unique value, keep that single value
path_attributes[attr] = path_attributes[attr][0]
path_attributes[attr_name] = attr_values[0]
else:
# otherwise, if there are multiple uniques, keep one of each
path_attributes[attr] = list(set(path_attributes[attr]))
path_attributes[attr_name] = list(set(attr_values))

# construct the new consolidated edge's geometry for this path
path_attributes["geometry"] = LineString(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_osmnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import pandas as pd
import pytest
from lxml import etree
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError as RequestsConnectionError
from shapely import Point
from shapely import Polygon
from shapely import wkt
Expand Down Expand Up @@ -462,7 +462,7 @@ def test_endpoints() -> None:
# This should fail because we didn't provide a valid endpoint
ox.settings.overpass_rate_limit = False
ox.settings.overpass_url = "http://NOT_A_VALID_ENDPOINT/api/"
with pytest.raises(ConnectionError, match="Max retries exceeded with url"):
with pytest.raises(RequestsConnectionError, match="Max retries exceeded with url"):
G = ox.graph_from_place(place1, network_type="all")

ox.settings.overpass_rate_limit = default_overpass_rate_limit
Expand Down

0 comments on commit cf46a70

Please sign in to comment.