keystoneauth1.loading.base module¶
- class keystoneauth1.loading.base.Any(*args, **kwargs)
Bases:
objectSpecial type indicating an unconstrained type.
Any is assignable to every type.
Any assumed to have all methods and attributes.
All values are assignable to Any.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any cannot be used with instance checks.
- __annotations_cache__ = {}
- __dict__ = mappingproxy({'__module__': 'typing', '__firstlineno__': 588, '__doc__': 'Special type indicating an unconstrained type.\n\n- Any is assignable to every type.\n- Any assumed to have all methods and attributes.\n- All values are assignable to Any.\n\nNote that all the above statements are true from the point of view of\nstatic type checkers. At runtime, Any cannot be used with instance\nchecks.\n', '__new__': <staticmethod(<function Any.__new__>)>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'Any' objects>, '__weakref__': <attribute '__weakref__' of 'Any' objects>, '__annotations_cache__': {}})
- __doc__ = 'Special type indicating an unconstrained type.\n\n- Any is assignable to every type.\n- Any assumed to have all methods and attributes.\n- All values are assignable to Any.\n\nNote that all the above statements are true from the point of view of\nstatic type checkers. At runtime, Any cannot be used with instance\nchecks.\n'
- __firstlineno__ = 588
- __module__ = 'typing'
- static __new__(cls, *args, **kwargs)
- __static_attributes__ = ()
- __weakref__
list of weak references to the object
- class keystoneauth1.loading.base.BaseLoader
Bases:
_BaseLoader[BaseAuthPluginT]- __abstractmethods__ = frozenset({'get_options'})
- __annotations_cache__ = {}
- __doc__ = None
- __firstlineno__ = 251
- __module__ = 'keystoneauth1.loading.base'
- __orig_bases__ = (keystoneauth1.loading.base._BaseLoader[+BaseAuthPluginT],)
- __parameters__ = (+BaseAuthPluginT,)
- __static_attributes__ = ()
- _abc_impl = <_abc._abc_data object>
- class keystoneauth1.loading.base.Callable
Bases:
object- __abstractmethods__ = frozenset({'__call__'})
- __annotations_cache__ = {}
- abstractmethod __call__(*args, **kwds)
Call self as a function.
- classmethod __class_getitem__(args)
Represent Callable[argtypes, resulttype].
This sets
__args__to a tuple containing the flattenedargtypesfollowed byresulttype.Example:
Callable[[int, str], float]sets__args__to(int, str, float).
- __doc__ = None
- __firstlineno__ = 529
- __module__ = 'collections.abc'
- __slots__ = ()
- __static_attributes__ = ()
- classmethod __subclasshook__(C)
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- _abc_impl = <_abc._abc_data object>
- class keystoneauth1.loading.base.Generic
Bases:
objectAbstract base class for generic types.
On Python 3.12 and newer, generic classes implicitly inherit from Generic when they declare a parameter list after the class’s name:
class Mapping[KT, VT]: def __getitem__(self, key: KT) -> VT: ... # Etc.
On older versions of Python, however, generic classes have to explicitly inherit from Generic.
After a class has been declared to be generic, it can then be used as follows:
def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- __annotate_func__ = None
- __annotations_cache__ = {}
- classmethod __class_getitem__()
Parameterizes a generic class.
At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.
However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….
- __doc__ = "Abstract base class for generic types.\n\nOn Python 3.12 and newer, generic classes implicitly inherit from\nGeneric when they declare a parameter list after the class's name::\n\n class Mapping[KT, VT]:\n def __getitem__(self, key: KT) -> VT:\n ...\n # Etc.\n\nOn older versions of Python, however, generic classes have to\nexplicitly inherit from Generic.\n\nAfter a class has been declared to be generic, it can then be used as\nfollows::\n\n def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:\n try:\n return mapping[key]\n except KeyError:\n return default\n"
- classmethod __init_subclass__()
Function to initialize subclasses.
- __module__ = 'typing'
- class keystoneauth1.loading.base.TypeVar
Bases:
objectType variable.
The preferred way to construct a type variable is via the dedicated syntax for generic functions, classes, and type aliases:
class Sequence[T]: # T is a TypeVar ...
This syntax can also be used to create bound and constrained type variables:
# S is a TypeVar bound to str class StrSequence[S: str]: ... # A is a TypeVar constrained to str or bytes class StrOrBytesSequence[A: (str, bytes)]: ...
Type variables can also have defaults:
- class IntDefault[T = int]:
…
However, if desired, reusable type variables can also be constructed manually, like so:
T = TypeVar('T') # Can be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes D = TypeVar('D', default=int) # Defaults to int
Type variables exist primarily for the benefit of static type checkers. They serve as the parameters for generic types as well as for generic function and type alias definitions.
The variance of type variables is inferred by type checkers when they are created through the type parameter syntax and when
infer_variance=Trueis passed. Manually created type variables may be explicitly marked covariant or contravariant by passingcovariant=Trueorcontravariant=True. By default, manually created type variables are invariant. See PEP 484 and PEP 695 for more details.- __annotate_func__ = None
- __annotations_cache__ = {}
- __bound__
- __constraints__
- __contravariant__
- __covariant__
- __default__
- __doc__ = "Type variable.\n\nThe preferred way to construct a type variable is via the dedicated\nsyntax for generic functions, classes, and type aliases::\n\n class Sequence[T]: # T is a TypeVar\n ...\n\nThis syntax can also be used to create bound and constrained type\nvariables::\n\n # S is a TypeVar bound to str\n class StrSequence[S: str]:\n ...\n\n # A is a TypeVar constrained to str or bytes\n class StrOrBytesSequence[A: (str, bytes)]:\n ...\n\nType variables can also have defaults:\n\n class IntDefault[T = int]:\n ...\n\nHowever, if desired, reusable type variables can also be constructed\nmanually, like so::\n\n T = TypeVar('T') # Can be anything\n S = TypeVar('S', bound=str) # Can be any subtype of str\n A = TypeVar('A', str, bytes) # Must be exactly str or bytes\n D = TypeVar('D', default=int) # Defaults to int\n\nType variables exist primarily for the benefit of static type\ncheckers. They serve as the parameters for generic types as well\nas for generic function and type alias definitions.\n\nThe variance of type variables is inferred by type checkers when they\nare created through the type parameter syntax and when\n``infer_variance=True`` is passed. Manually created type variables may\nbe explicitly marked covariant or contravariant by passing\n``covariant=True`` or ``contravariant=True``. By default, manually\ncreated type variables are invariant. See PEP 484 and PEP 695 for more\ndetails.\n"
- __infer_variance__
- __module__ = 'typing'
- __mro_entries__(object, /)
- __name__ = 'TypeVar'
- classmethod __new__(*args, **kwargs)
- __or__(value, /)
Return self|value.
- __reduce__()
Helper for pickle.
- __repr__()
Return repr(self).
- __ror__(value, /)
Return value|self.
- __typing_prepare_subst__(alias, args, /)
- __typing_subst__(arg, /)
- evaluate_bound
- evaluate_constraints
- evaluate_default
- has_default()
- class keystoneauth1.loading.base._BaseLoader
Bases:
Generic[T]- __abstractmethods__ = frozenset({'get_options'})
- __annotations_cache__ = {}
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.loading.base', '__firstlineno__': 164, 'plugin_class': <property object>, 'create_plugin': <function _BaseLoader.create_plugin>, 'get_options': <function _BaseLoader.get_options>, 'available': <property object>, 'load_from_options': <function _BaseLoader.load_from_options>, 'load_from_options_getter': <function _BaseLoader.load_from_options_getter>, '__static_attributes__': (), '__orig_bases__': (typing.Generic[+T],), '__dict__': <attribute '__dict__' of '_BaseLoader' objects>, '__weakref__': <attribute '__weakref__' of '_BaseLoader' objects>, '__doc__': None, '__parameters__': (+T,), '__abstractmethods__': frozenset({'get_options'}), '_abc_impl': <_abc._abc_data object>, '__annotations_cache__': {}})
- __doc__ = None
- __firstlineno__ = 164
- __module__ = 'keystoneauth1.loading.base'
- __orig_bases__ = (typing.Generic[+T],)
- __parameters__ = (+T,)
- __static_attributes__ = ()
- __weakref__
list of weak references to the object
- _abc_impl = <_abc._abc_data object>
- property available: bool
Return if the plugin is available for loading.
If a plugin is missing dependencies or for some other reason should not be available to the current system it should override this property and return False to exclude itself from the plugin list.
- Returns:
True if the plugin is available for loading, else False.
- create_plugin(**kwargs: Any) T
Create a plugin from the options available for the loader.
Given the options that were specified by the loader create an appropriate plugin. You can override this function in your loader.
This used to be specified by providing the plugin_class property and this is still supported, however specifying a property didn’t let you choose a plugin type based upon the options that were presented.
Override this function if you wish to return different plugins based on the options presented, otherwise you can simply provide the plugin_class property.
Added 2.9
- abstractmethod get_options() list[opts.Opt]
Return the list of parameters associated with the auth plugin.
This list may be used to generate CLI or config arguments.
- Returns:
A list of Param objects describing available plugin parameters.
- load_from_options(**kwargs: Any) T
Create a plugin from the arguments retrieved from get_options.
A client can override this function to do argument validation or to handle differences between the registered options and what is required to create the plugin.
- load_from_options_getter(getter: Callable[[opts.Opt], Any], **kwargs: Any) T
Load a plugin from getter function that returns appropriate values.
To handle cases other than the provided CONF and CLI loading you can specify a custom loader function that will be queried for the option value. The getter is a function that takes a
keystoneauth1.loading.Optand returns a value to load with.- Parameters:
getter – A function that returns a value for the given opt.
- Returns:
An authentication Plugin.
- property plugin_class: type[T]
- keystoneauth1.loading.base._auth_plugin_available(ext: Extension[base.BaseLoader[Any]]) bool
Read the value of available for whether to load this plugin.
- keystoneauth1.loading.base._prefer_out_of_tree_plugin(namespace: str, name: str, extensions: list[Extension[Any]]) Extension[Any]
Resolve duplicate plugin entry points, preferring out-of-tree ones.
keystoneauth1 ships in-tree loaders for some plugins that also have an out-of-tree implementation (e.g.
v3websso). When both are installed they register the same entry-point name; prefer the out-of-tree implementation so deployers can override the one we ship.
- keystoneauth1.loading.base.cast(typ, val)
Cast a value to a type.
This returns the value unchanged. To the type checker this signals that the return value has the designated type, but at runtime we intentionally don’t check anything (we want this to be as fast as possible).
- keystoneauth1.loading.base.get_available_plugin_loaders() dict[str, BaseLoader[BaseAuthPluginT]]
Retrieve all the plugin classes available on the system.
- Returns:
A dict with plugin entrypoint name as the key and the plugin loader as the value.
- keystoneauth1.loading.base.get_available_plugin_names() frozenset[str]
Get the names of all the plugins that are available on the system.
This is particularly useful for help and error text to prompt a user for example what plugins they may specify.
- Returns:
A list of names.
- keystoneauth1.loading.base.get_plugin_loader(name: str) BaseLoader[BaseAuthPluginT]
Retrieve a plugin class by its entrypoint name.
- Parameters:
name – The name of the object to get.
- Returns:
An auth plugin class.
- Raises:
keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin – if a plugin cannot be created.
- keystoneauth1.loading.base.get_plugin_options(name: str) list[opts.Opt]
Get the options for a specific plugin.
This will be the list of options that is registered and loaded by the specified plugin.
- Returns:
A list of
keystoneauth1.loading.Optoptions.- Raises:
keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin – if a plugin cannot be created.