id_translation.translator_typing#
Types that are specific to the Translator implementation.
Module Attributes
Data for translating using only the default id and name placeholders. |
|
Data for translating using arbitrary placeholders; see |
|
Internal types related to fetching. |
|
All valid input types for creating a |
|
High-level reason why a cached |
Classes
Keyword arguments for the |
|
All arguments of |
|
All arguments of |
|
Arguments of |
|
All arguments of |
|
Arguments of |
|
Keyword arguments of |
|
Arguments of |
- class AbstractFetcherParams[source]#
Bases:
TypedDict,Generic[SourceType,IdType]Keyword arguments for the
AbstractFetcherbase class.- allow_fetch_all#
- cache_access#
- identifiers#
- mapper#
- optional#
- selective_fetch_all#
- class AllTranslateParams[source]#
Bases:
TranslateParams[NameType,SourceType,IdType]All arguments of
Translator.translate().- translatable#
- CacheMissReasonType#
High-level reason why a cached
Translatorwas rejected.alias of
Literal[‘metadata-missing’, ‘metadata-changed’, ‘too-old’]
- class CopyParams[source]#
Bases:
UniqueCopyParams[NameType,SourceType,IdType]All arguments of
Translator.copy().- fmt#
- class ExtractNamesParams[source]#
Bases:
TypedDict,Generic[NameType,SourceType,IdType]Arguments of
Translator.extract_names().- ignore_names#
- io_kwargs#
- raising#
- translatable#
- class FetchParams[source]#
Bases:
TypedDict,Generic[NameType,SourceType,IdType]All arguments of
Translator.fetch()andTranslator.go_offline().- fmt#
- ignore_names#
- io_kwargs#
- max_fails#
- names#
- override_function#
- translatable#
- FetcherTypes = id_translation.offline._translation_map.TranslationMap[~NameType, ~SourceType, ~IdType] | id_translation.fetching._fetcher.Fetcher[~SourceType, ~IdType] | dict[~SourceType, id_translation.offline.types.PlaceholderTranslations[~SourceType]] | dict[~SourceType, dict[~IdType, str]] | collections.abc.Mapping[~SourceType, id_translation.offline.types.PlaceholderTranslations[~SourceType] | ForwardRef('pandas.DataFrame') | typing.Mapping[str, collections.abc.Sequence[typing.Any]] | typing.Mapping[~IdType, str]]#
All valid input types for creating a
Translator.
- class MapParams[source]#
Bases:
TypedDict,Generic[NameType,SourceType,IdType]Arguments of
Translator.map()andTranslator.map_scores().- ignore_names#
- io_kwargs#
- names#
- override_function#
- translatable#
- NativeFetcherTypes = id_translation.offline._translation_map.TranslationMap[~NameType, ~SourceType, ~IdType] | id_translation.fetching._fetcher.Fetcher[~SourceType, ~IdType] | dict[~SourceType, id_translation.offline.types.PlaceholderTranslations[~SourceType]]#
Internal types related to fetching.
- SimpleDictFetcherTypes#
Data for translating using only the default id and name placeholders.
Must be on the form
{source: {id: name}}.alias of
dict[SourceType,dict[IdType,str]]
- SourceToPlaceholderTranslationsMakeTypes#
Data for translating using arbitrary placeholders; see
PlaceholderTranslations.make()alias of
Mapping[SourceType,PlaceholderTranslations[SourceType] |pandas.DataFrame|Mapping[str,Sequence[Any]] |Mapping[IdType,str]]
- class TranslateParams[source]#
Bases:
TypedDict,Generic[NameType,SourceType,IdType]Keyword arguments of
Translator.translate().Note
Does not include translatable or copy.
Motivation
Allowing these to be passed as keyword arguments causes issues with typing, especially method overloading. For example:
def func(**kwargs: Unpack[AllTranslateParams]): translatable = kwargs["translatable"] if isinstance(translatable, list) and kwargs.get(copy, True): raise CustomException("we don't do that here") else: # Do whatever
using
AllTranslateParamsis typically not as safe as:@overload def func(...): ... @overload def func( translatable: list, copy: Literal[False], **kwargs: Unpack[TranslateParams] ) -> Never: ... def func(translatable, copy, **kwargs: Unpack[TranslateParams]): "Implementation as above"
since
func(translatable=[], copy=False)does not behave likeTranslator.translate([], copy=False)would. Functions that transparently wrapTranslator.translate()should probably usefunctools.wraps()instead.- fmt#
- ignore_names#
- io_kwargs#
- max_fails#
- names#
- override_function#
- reverse#
- class UniqueCopyParams[source]#
Bases:
TypedDict,Generic[NameType,SourceType,IdType]Arguments of
Translator.copy()that do not overlap withAllTranslateParams.- default_fmt#
- default_fmt_placeholders#
- enable_uuid_heuristics#
- fetcher#
- mapper#
- transformers#