python-osw-validation 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import os
2
2
  import gc
3
3
  import json
4
4
  import math
5
+ import numbers
5
6
  from typing import Dict, Any, Optional, List, Tuple
6
7
  import geopandas as gpd
7
8
  import jsonschema_rs
@@ -283,9 +284,7 @@ class OSWValidation:
283
284
  def _is_nullish_value(self, value: Any) -> bool:
284
285
  if value is None:
285
286
  return True
286
- if isinstance(value, str) and value.strip().lower() in {"null", "nan"}:
287
- return True
288
- return isinstance(value, float) and math.isnan(value)
287
+ return isinstance(value, numbers.Real) and math.isnan(value)
289
288
 
290
289
  def _collect_nullish_property_paths(self, obj: Any, prefix: str = "") -> List[Tuple[str, Any]]:
291
290
  paths: List[Tuple[str, Any]] = []
@@ -303,6 +302,13 @@ class OSWValidation:
303
302
  paths.append((prefix or "value", obj))
304
303
  return paths
305
304
 
305
+ def _collect_nullish_extension_property_paths(self, props: Dict[str, Any]) -> List[Tuple[str, Any]]:
306
+ paths: List[Tuple[str, Any]] = []
307
+ for key, value in props.items():
308
+ if isinstance(key, str) and key.startswith("ext:"):
309
+ paths.extend(self._collect_nullish_property_paths(value, key))
310
+ return paths
311
+
306
312
  def _contains_disallowed_features_for_02(self, geojson_data: Dict[str, Any]) -> set:
307
313
  """Detect Tree coverage or Custom content in legacy 0.2 datasets.
308
314
 
@@ -676,8 +682,8 @@ class OSWValidation:
676
682
 
677
683
  filename = os.path.basename(file_path)
678
684
 
679
- # Upfront guard: reject null/NaN values in feature properties.
680
- # This runs before schema validation to surface data quality issues first.
685
+ # Upfront guard: reject null/NaN values in free-form extension properties.
686
+ # Schema-owned properties are left to schema validation.
681
687
  features = geojson_data.get("features", []) if isinstance(geojson_data, dict) else []
682
688
  found_nullish = False
683
689
  for idx, feature in enumerate(features):
@@ -686,7 +692,7 @@ class OSWValidation:
686
692
  props = feature.get("properties")
687
693
  if not isinstance(props, dict):
688
694
  continue
689
- bad_paths = self._collect_nullish_property_paths(props)
695
+ bad_paths = self._collect_nullish_extension_property_paths(props)
690
696
  for path, bad_value in bad_paths:
691
697
  if len(self.errors) >= max_errors:
692
698
  return False
@@ -1 +1 @@
1
- __version__ = '0.4.1'
1
+ __version__ = '0.4.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_osw_validation
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Python library for OSW validation
5
5
  Home-page: https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation
6
6
  Author: Sujata Misra
@@ -31,9 +31,9 @@ Dynamic: summary
31
31
 
32
32
  # TDEI python lib OSW validation package
33
33
 
34
- [![PyPI version](https://img.shields.io/pypi/v/python-osw-validation.svg)](https://pypi.org/project/python-osw-validation/)
35
- [![Tests](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml)
36
- [![Coverage](https://img.shields.io/badge/coverage-92%25-brightgreen)](#)
34
+ [![python-osw-validation](https://img.shields.io/pypi/v/python-osw-validation?label=python-osw-validation&cacheSeconds=60&t=1)](https://pypi.org/project/python-osw-validation/)
35
+ [![Unit Tests](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/workflows/unit_tests.yml)
36
+ ![Coverage](https://raw.githubusercontent.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation/actions/badges/coverage.svg)
37
37
 
38
38
  This package validates OSW GeoJSON datasets packaged as a ZIP file.
39
39
 
@@ -48,7 +48,7 @@ This package validates OSW GeoJSON datasets packaged as a ZIP file.
48
48
  - Extracts the provided ZIP file
49
49
  - Finds supported OSW dataset files inside the extracted directory
50
50
  - Validates each file (`edges`, `lines`, `nodes`, `points`, `polygons`, and `zones`) against the matching schema
51
- - Performs an upfront data-quality check for null-like placeholders in feature properties (for example `null`, `NaN`, `"null"`, `"nan"`)
51
+ - Performs an upfront data-quality check for actual null and numeric NaN values in `ext:*` extension properties (for example JSON `null` or numeric `NaN`; string values like `"null"` and `"nan"` are not rejected by this precheck)
52
52
  - Runs cross-file integrity checks such as duplicate `_id` detection and edge or zone references back to nodes
53
53
  - Returns a `ValidationResult` object with `is_valid`, `errors`, and `issues`
54
54
 
@@ -81,8 +81,8 @@ print(result.issues) # capped by the same max_errors limit
81
81
 
82
82
  - `errors`: high-level validation messages, capped by `max_errors` (default `20`).
83
83
  - `issues`: detailed per-feature validation issues, also capped by `max_errors`.
84
- - If null-like placeholders are found in feature `properties`, validation fails early before schema checks with actionable messages such as:
85
- - `Invalid value at 'climb': 'null'. Null/NaN placeholders are not allowed; provide a valid value or remove this property.`
84
+ - If actual null or numeric NaN values are found in `ext:*` extension properties, validation fails early before schema checks with actionable messages such as:
85
+ - `Invalid value at 'ext:metadata.score': nan. Null/NaN placeholders are not allowed; provide a valid value or remove this property.`
86
86
  - For enum validation, long allowed-value lists are summarized as:
87
87
  - first 5 values joined by `|`
88
88
  - followed by `| and N more` when applicable.
@@ -1,8 +1,8 @@
1
- python_osw_validation/__init__.py,sha256=jmTokejVzcwWwuQRgwIjCEH9KDhkJqp1a-e4ubVgOOU,33301
1
+ python_osw_validation/__init__.py,sha256=cK7jzSRUpYZ-QvWUVC3C3dCu7ce-HtKNSTzA1IArpzg,33576
2
2
  python_osw_validation/extracted_data_validator.py,sha256=gEGYLaM_QkK6NrrhVYmNx-jMaNHXC4PbDGf1zKwJre4,6605
3
3
  python_osw_validation/geometry_mapping_validator.py,sha256=KscmfgSwTiXbf8IPx-RXuTIXPYY4PHDwvBeb2WmhpVA,14137
4
4
  python_osw_validation/helpers.py,sha256=iLVJZS1-AaLsbP0ngHZLW208dKSnM2k52JFal4Nuxcg,9203
5
- python_osw_validation/version.py,sha256=qBs4HqYsPn6yUHWEuCN4rGUC05gABbl800d8LBd8h9w,22
5
+ python_osw_validation/version.py,sha256=zrcTwxP3SA3F1Js78afrfeaZeJr8w2hLtFtEZoUqUmg,22
6
6
  python_osw_validation/zipfile_handler.py,sha256=jXnP-8O5AAOBapuNF3-XdFVM1MHiPaWpl_wlbX-aqhY,2631
7
7
  python_osw_validation/schema/opensidewalks.edges.schema-0.3.json,sha256=Egp--i6ahiUDKY55g_fuv71HkVPtnQN5OW8L_okRa8o,79638
8
8
  python_osw_validation/schema/opensidewalks.lines.schema-0.3.json,sha256=3s-VXiMPv0_wv3yU2iGw8iKjE3Ec1w6QKkUsQURp2II,9470
@@ -11,8 +11,8 @@ python_osw_validation/schema/opensidewalks.points.schema-0.3.json,sha256=WYmlC4Q
11
11
  python_osw_validation/schema/opensidewalks.polygons.schema-0.3.json,sha256=VzDpHv1ZVT42cAk9n3gsFZjS7WcflQzSbjN-aNIVTYM,16286
12
12
  python_osw_validation/schema/opensidewalks.schema-0.3.json,sha256=vyyGzPpqLxr1e5wFfNKzlA1sr6tmhHKM7ntaTk8z5k8,278489
13
13
  python_osw_validation/schema/opensidewalks.zones.schema-0.3.json,sha256=JCqoCJj-dCuPVPHWSUQhRJMebaJ9IrzHWwTVAC6j7dY,11281
14
- python_osw_validation-0.4.1.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
- python_osw_validation-0.4.1.dist-info/METADATA,sha256=NytFX-HWBMVtDbxB8PD_Ba4eHr2AoEUaIA2K19vxlR8,6502
16
- python_osw_validation-0.4.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
17
- python_osw_validation-0.4.1.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
18
- python_osw_validation-0.4.1.dist-info/RECORD,,
14
+ python_osw_validation-0.4.2.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
+ python_osw_validation-0.4.2.dist-info/METADATA,sha256=fb8PvRfotgMot9cZ1jJ2RfEBX5hpLBrLDHDUjhYfnsE,6731
16
+ python_osw_validation-0.4.2.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
17
+ python_osw_validation-0.4.2.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
18
+ python_osw_validation-0.4.2.dist-info/RECORD,,