Filter (autotransform.filter.base)
The base class and associated classes for Filter components.
- class autotransform.filter.base.BulkFilter(*, inverted: bool = False)
Bases:
Filter
The base for BulkFilter components. Handles validation in bulk to determine valid Items.
- _valid_keys
Whether to invert the results of the filter. Defaults to an None.
- Type:
Optional[List[str]], optional
- name
The name of the component.
- Type:
ClassVar[FilterName]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'inverted': FieldInfo(annotation=bool, required=False, default=False)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_post_init(__context: Any) None
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
__context – The context.
- class autotransform.filter.base.Filter(*, inverted: bool = False)
Bases:
NamedComponent
The base for Filter components. Used by AutoTransform to determine if an Item from an Input is eligible for transformation.
- inverted
Whether to invert the results of the filter. Defaults to False.
- Type:
bool, optional
- name
The name of the component.
- Type:
ClassVar[FilterName]
- inverted: bool
- is_valid(item: Item) bool
Check whether an Item is valid based on the Filter and handle inversion.
- Parameters:
item (Item) – The Item to check.
- Returns:
Returns True if the Item is eligible for transformation.
- Return type:
bool
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'inverted': FieldInfo(annotation=bool, required=False, default=False)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- name: ClassVar[FilterName]