File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77try :
88 import ryml
9-
10- _HAS_RYML = True
119except ImportError :
12- _HAS_RYML = False
10+ ryml = None # type: ignore[assignment]
11+
12+ _HAS_RYML = ryml is not None
1313
1414
1515def _handle_subdir (path : Path , file_handler : Callable ):
@@ -38,7 +38,11 @@ def _rapidyaml_load(path: Path) -> Dict[Any, Any]:
3838 The one semantic diff to watch for is YAML 1.1-isms that rapidyaml (YAML
3939 1.2) does not treat as typed: e.g. ``yes``/``no`` stay strings, and
4040 sexagesimal numbers stay strings. Existing Sift configs do not use these.
41+
42+ Only call this when ``_HAS_RYML`` is true; the ``assert`` below narrows the
43+ type for static analysis and is an invariant the dispatcher upholds.
4144 """
45+ assert ryml is not None , "rapidyaml is not installed; call _pyyaml_load instead"
4246 with open (path , "rb" ) as f :
4347 tree = ryml .parse_in_arena (f .read ())
4448 resolve = getattr (tree , "resolve" , None )
You can’t perform that action at this time.
0 commit comments