soleil.resolvers.modifiers#
Module Attributes
The member should not be passed as an argument to type |
|
The member should be passed as a type arg |
|
|
Change the name of the member when passed as a type arg |
|
Used to format the value after pre-processing but before resolution |
Indicates that the specified member should not be used by |
Functions
|
Used to format the value after pre-processing but before resolution |
|
Converts the annotation to a |
|
Fails if there are clashing values. |
|
Change the name of the member when passed as a type arg |
Classes
|
To be used as a type hint or class decorator that modifies the behaviour of annotated members of a resolvable object. |
- class soleil.resolvers.modifiers.Modifiers(dict=None, /, **kwargs)#
Bases:
UserDictTo be used as a type hint or class decorator that modifies the behaviour of annotated members of a resolvable object. Supported entries of this modifier depend on the resolver.
Pre-instantiated modifier objects or object factories that make code more readable are provided as part of various soleil modules:
name(value:str): Specifies that the annotated member should be passed to its type with this name instead of its declared variable name.hidden: The annotated member should not be passed to its type.cast(value:Callable): The value assigned to the member will be mapped with this callable before resolution.promoted: Valid only to annotate root-level members of solconf modules. The promoted member will be returned when the module is loaded instead of the module itself, andCLI override variable paths that point to the containing module will instead be re-directed to the annotated member. Modules resolved with a promoted member (assuming the default module type)
Note that modifiers can be changed in derived classes without changing the class value.
class A: a = 1 class B(A): a:hidden
Modifiers can be applied to classes by using value-less annotation declarations:
A:(hidden, noid) class A: ...
Alternatively, all modifier objects can be used as class decorators:
@hidden @noid class A: ...
- __call__(cls)#
Used to allow the modifiers object to decorate classes.
Appends the specified modifier to the class
The member should not be passed as an argument to type
- soleil.resolvers.modifiers.visible = {'hidden': False}#
The member should be passed as a type arg
- soleil.resolvers.modifiers.name(value)#
Change the name of the member when passed as a type arg
- soleil.resolvers.modifiers.cast(value)#
Used to format the value after pre-processing but before resolution
- soleil.resolvers.modifiers.noid = {'noid': True}#
Indicates that the specified member should not be used by
soleil.utils.id_str()
- soleil.resolvers.modifiers.merge_modifiers(*modifiers: Modifiers)#
Fails if there are clashing values. The type of the output will be that of the most-specialized modifier in the inputs.
- soleil.resolvers.modifiers.from_annotation(annotation: Modifiers | Tuple[Modifiers]) None | Modifiers#
Converts the annotation to a
Modifiersobject or returnsNoneif the annotation does not specify aModifiers. If the input is a tuple, the returned object is the merge of all the modifiers. An exception is raised if only some but not all tuple members areModifiers.