@@ -49,8 +49,8 @@ impl PyStreetNetwork {
4949 ) -> PyResult < Self > {
5050 SETUP_LOGGER . call_once ( || env_logger:: init ( ) ) ;
5151
52- let input: ImportOptions =
53- serde_json :: from_str ( input . extract :: < & str > ( py ) ? ) . map_err ( |e| err_to_py_value ( format ! ( "Failed to parse input: {}" , e) ) ) ?;
52+ let input: ImportOptions = serde_json :: from_str ( input . extract :: < & str > ( py ) ? )
53+ . map_err ( |e| err_to_py_value ( format ! ( "Failed to parse input: {}" , e) ) ) ?;
5454
5555 // Parse clip points if provided
5656 let clip_pts = if clip_pts_geojson. is_empty ( ) {
@@ -230,19 +230,15 @@ impl PyStreetNetwork {
230230 if let Some ( ref way) = self . ways . get ( & osm:: WayID ( id) ) {
231231 Ok ( serde_json:: to_string_pretty ( & way. tags ) . unwrap ( ) )
232232 } else {
233- Err ( err_to_py_value ( format ! (
234- "unknown way {}" ,
235- id
236- ) ) )
233+ Err ( err_to_py_value ( format ! ( "unknown way {}" , id) ) )
237234 }
238235 }
239236
240237 /// Converts the entire `StreetNetwork` to a JSON format.
241238 ///
242239 /// Returns a JSON string representing the full `StreetNetwork` data structure.
243240 pub fn to_json ( & self ) -> PyResult < String > {
244- serde_json:: to_string_pretty ( & self . inner )
245- . map_err ( err_to_py_runtime)
241+ serde_json:: to_string_pretty ( & self . inner ) . map_err ( err_to_py_runtime)
246242 }
247243
248244 /// Retrieves the geometry of a way (road or path) as a buffered polygon in GeoJSON format.
@@ -293,10 +289,7 @@ impl PyStreetNetwork {
293289 /// Returns an XML string for the way, or an error if the way does not exist.
294290 pub fn way_to_xml ( & self , id : i64 ) -> PyResult < String > {
295291 let Some ( ref way) = self . ways . get ( & osm:: WayID ( id) ) else {
296- return Err ( err_to_py_value ( format ! (
297- "unknown way {}" ,
298- id
299- ) ) ) ;
292+ return Err ( err_to_py_value ( format ! ( "unknown way {}" , id) ) ) ;
300293 } ;
301294 let mut out = format ! ( r#"<way id="{}""# , id) ;
302295 if let Some ( version) = way. version {
@@ -359,8 +352,8 @@ impl PyStreetNetwork {
359352 /// Updates the roads and intersections connected to this way based on the new tags.
360353 pub fn overwrite_osm_tags_for_way ( & mut self , id : i64 , tags : & str ) -> PyResult < ( ) > {
361354 let id = osm:: WayID ( id) ;
362- let tags: Tags = serde_json:: from_str ( tags) . map_err ( |e| err_to_py_value ( format ! ( "Failed to parse tags: {}" , e ) )
363- ) ?;
355+ let tags: Tags = serde_json:: from_str ( tags)
356+ . map_err ( |e| err_to_py_value ( format ! ( "Failed to parse tags: {}" , e ) ) ) ?;
364357
365358 let mut intersections = BTreeSet :: new ( ) ;
366359 for road in self . inner . roads . values_mut ( ) {
@@ -382,10 +375,7 @@ impl PyStreetNetwork {
382375 if let Some ( way) = self . ways . get_mut ( & id) {
383376 way. tags = tags;
384377 } else {
385- return Err ( err_to_py_value ( format ! (
386- "Unknown way ID {}" ,
387- id
388- ) ) ) ;
378+ return Err ( err_to_py_value ( format ! ( "Unknown way ID {}" , id) ) ) ;
389379 }
390380 Ok ( ( ) )
391381 }
@@ -458,9 +448,8 @@ fn err_to_py_runtime<E: std::fmt::Display>(err: E) -> PyErr {
458448 pyo3:: exceptions:: PyRuntimeError :: new_err ( err. to_string ( ) )
459449}
460450
461-
462451/// Converts any error implementing `std::fmt::Display` into a `PyValueError`.
463452/// Used for invalid inputs or incorrect arguments passed by the user.
464453fn err_to_py_value < E : std:: fmt:: Display > ( err : E ) -> PyErr {
465454 pyo3:: exceptions:: PyValueError :: new_err ( err. to_string ( ) )
466- }
455+ }
0 commit comments