Parse the ``prefetch_schemas_mode`` / ``prefetch_schemas_list`` options. Returns ``None`` when every accessible schema should be prefetched (``always``), an empty list when prefetching is disabled (``never``), or ``schema_list`` when the mode is ``listed``. Unknown modes fall back t
(mode: str, schema_list: list[str])
| 30 | |
| 31 | |
| 32 | def parse_prefetch_config(mode: str, schema_list: list[str]) -> list[str] | None: |
| 33 | """Parse the ``prefetch_schemas_mode`` / ``prefetch_schemas_list`` options. |
| 34 | |
| 35 | Returns ``None`` when every accessible schema should be prefetched |
| 36 | (``always``), an empty list when prefetching is disabled |
| 37 | (``never``), or ``schema_list`` when the mode is ``listed``. |
| 38 | Unknown modes fall back to ``always``. |
| 39 | """ |
| 40 | try: |
| 41 | parsed = PrefetchMode(mode.strip().lower()) |
| 42 | except ValueError: |
| 43 | return None |
| 44 | if parsed is PrefetchMode.NEVER: |
| 45 | return [] |
| 46 | if parsed is PrefetchMode.LISTED: |
| 47 | return schema_list |
| 48 | return None |
| 49 | |
| 50 | |
| 51 | class SchemaPrefetcher: |