# -*- coding: utf-8 -*-"""Sentinel value for distinguishing "not provided" from ``None``.In many boto3 APIs, ``None`` is a meaningful value (e.g. ``region_name=None``means "let boto3 resolve the region from the environment"). A plain ``None``default therefore cannot tell whether the caller explicitly passed ``None`` orsimply omitted the argument. The ``NOTHING`` sentinel fills that gap: anyparameter whose default is ``NOTHING`` is treated as *not provided* and will bestripped out by :func:`resolve_kwargs` before forwarding to boto3.``NOTHING`` is also used as the "uninitialised" marker for lazy-loaded cachedproperties (e.g. ``_boto_ses_cache``, ``_aws_account_id_cache``), where thecached value itself could legitimately be ``None``.This module requires Python 3.10+. The previous implementation was borrowed fromthe *boltons* library circa 2014 and carried legacy Python 2 compatibility code(``__nonzero__``, ``sys._getframe`` for pickle support, dynamic inner classes).None of that machinery is needed in modern Python, so it has been replaced withthe minimal implementation below."""importtypingasTclass_Nothing:"""Sentinel singleton. Do **not** instantiate directly; use :data:`NOTHING`."""__slots__=()def__repr__(self)->str:return"NOTHING"def__bool__(self)->bool:returnFalseNOTHING=_Nothing()
[docs]defresolve_kwargs(_mapper:T.Optional[dict[str,str]]=None,**kwargs,)->dict[str,T.Any]:"""Return a dict of *kwargs* with all ``NOTHING`` values removed. This lets callers write ``resolve_kwargs(region_name=self.region_name, ...)`` and get back only the keys that were explicitly provided. :param _mapper: optional key-rename mapping, e.g. ``{"role_arn": "RoleArn"}`` translates the Python-style key to the AWS API name. """if_mapperisNone:_mapper=dict()return{_mapper.get(key,key):valueforkey,valueinkwargs.items()ifvalueisnotNOTHING}