refactor: one keyword-option guard in core

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 13:47:56 +01:00
1 parent 27330be60a
commit b4573d310b
13 files changed
+42 -44

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
"""Keyword options a function takes through a TypedDict, checked as named parameters are."""
from __future__ import annotations
from collections.abc import Mapping
def reject_unknown(function: str, options: Mapping[str, object], known: frozenset[str]) -> None:
"""Refuse a keyword the options do not declare, as a named parameter would."""
for key in options:
if key not in known:
raise TypeError(f"{function}() got an unexpected keyword argument '{key}'")