From cf46a7049667616273e4c3db6ce258f403eb4b5a Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Sun, 24 Nov 2024 08:46:39 -0800 Subject: [PATCH] update pre-commit config --- .pre-commit-config.yaml | 6 +++--- osmnx/_overpass.py | 4 ++-- osmnx/plot.py | 6 +++--- osmnx/simplification.py | 14 +++++++------- tests/test_osmnx.py | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8e8b408..5359af07 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/osmnx/_overpass.py b/osmnx/_overpass.py index 4831114b..387d640c 100644 --- a/osmnx/_overpass.py +++ b/osmnx/_overpass.py @@ -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 @@ -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) diff --git a/osmnx/plot.py b/osmnx/plot.py index a8feb572..9056296a 100644 --- a/osmnx/plot.py +++ b/osmnx/plot.py @@ -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 diff --git a/osmnx/simplification.py b/osmnx/simplification.py index 0267dcc0..7de4d062 100644 --- a/osmnx/simplification.py +++ b/osmnx/simplification.py @@ -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( diff --git a/tests/test_osmnx.py b/tests/test_osmnx.py index f057e933..78febd75 100644 --- a/tests/test_osmnx.py +++ b/tests/test_osmnx.py @@ -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 @@ -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