Yield `(properties_path, schema)` for every schema position in `root`. `properties_path` is the chain of `properties` keys from the root to the position, or `None` once any other applicator keyword has been crossed. The root itself yields `()`. Only the JSON Schema 2020-12 applicators
(root: Any)
| 112 | |
| 113 | |
| 114 | def _walk_schema_positions(root: Any) -> Iterator[tuple[tuple[str, ...] | None, dict[str, Any]]]: |
| 115 | """Yield `(properties_path, schema)` for every schema position in `root`. |
| 116 | |
| 117 | `properties_path` is the chain of `properties` keys from the root to the |
| 118 | position, or `None` once any other applicator keyword has been crossed. |
| 119 | The root itself yields `()`. Only the JSON Schema 2020-12 applicators |
| 120 | listed above are entered; instance-data keywords are not, and `$ref` is |
| 121 | not dereferenced, so the walk terminates on any finite JSON value. An |
| 122 | explicit stack keeps the function total even on pathologically deep input. |
| 123 | """ |
| 124 | stack: list[tuple[tuple[str, ...] | None, Any]] = [((), root)] |
| 125 | while stack: |
| 126 | path, node = stack.pop() |
| 127 | if not isinstance(node, dict): |
| 128 | continue |
| 129 | schema = cast(dict[str, Any], node) |
| 130 | yield path, schema |
| 131 | for kw, val in schema.items(): |
| 132 | if kw == "properties" and isinstance(val, dict): |
| 133 | for name, sub in cast(dict[str, Any], val).items(): |
| 134 | stack.append(((*path, name) if path is not None else None, sub)) |
| 135 | elif kw in _SUBSCHEMA_SINGLE: |
| 136 | stack.append((None, val)) |
| 137 | elif kw in _SUBSCHEMA_LIST and isinstance(val, list): |
| 138 | stack.extend((None, sub) for sub in cast(list[Any], val)) |
| 139 | elif kw in _SUBSCHEMA_MAP and isinstance(val, dict): |
| 140 | stack.extend((None, sub) for sub in cast(dict[str, Any], val).values()) |
| 141 | |
| 142 | |
| 143 | def encode_header_value(value: str) -> str: |
no outgoing calls
no test coverage detected