typing: Annotate openstack.config.cloud_config
Change-Id: Ia5ebf735fbe5e24d54f7c4fd502a5c114235e68b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -36,6 +36,7 @@ repos:
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- dogpile.cache
|
||||
- keystoneauth1>=5.11.0
|
||||
- types-decorator
|
||||
- types-PyYAML
|
||||
|
@@ -12,12 +12,84 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import typing as ty
|
||||
import warnings
|
||||
# TODO(mordred) This is only here to ease the OSC transition
|
||||
|
||||
from openstack.config import cloud_region
|
||||
from openstack import warnings as os_warnings
|
||||
|
||||
if ty.TYPE_CHECKING:
|
||||
from keystoneauth1 import discover
|
||||
from keystoneauth1 import plugin
|
||||
from keystoneauth1 import session as ks_session
|
||||
import prometheus_client
|
||||
|
||||
from openstack.config import loader
|
||||
|
||||
|
||||
class CloudConfig(cloud_region.CloudRegion):
|
||||
def __init__(self, name, region, config, **kwargs):
|
||||
super().__init__(name, region, config, **kwargs)
|
||||
def __init__(
|
||||
self,
|
||||
name: str | None,
|
||||
region: str | None,
|
||||
config: dict[str, ty.Any] | None,
|
||||
force_ipv4: bool = False,
|
||||
auth_plugin: ty.Optional['plugin.BaseAuthPlugin'] = None,
|
||||
openstack_config: ty.Optional['loader.OpenStackConfig'] = None,
|
||||
session_constructor: type['ks_session.Session'] | None = None,
|
||||
app_name: str | None = None,
|
||||
app_version: str | None = None,
|
||||
session: ty.Optional['ks_session.Session'] = None,
|
||||
discovery_cache: dict[str, 'discover.Discover'] | None = None,
|
||||
extra_config: dict[str, ty.Any] | None = None,
|
||||
cache_expiration_time: int = 0,
|
||||
cache_expirations: dict[str, int] | None = None,
|
||||
cache_path: str | None = None,
|
||||
cache_class: str = 'dogpile.cache.null',
|
||||
cache_arguments: dict[str, ty.Any] | None = None,
|
||||
password_callback: cloud_region._PasswordCallback | None = None,
|
||||
statsd_host: str | None = None,
|
||||
statsd_port: str | None = None,
|
||||
statsd_prefix: str | None = None,
|
||||
# TODO(stephenfin): Add better types
|
||||
influxdb_config: dict[str, ty.Any] | None = None,
|
||||
collector_registry: ty.Optional[
|
||||
'prometheus_client.CollectorRegistry'
|
||||
] = None,
|
||||
cache_auth: bool = False,
|
||||
) -> None:
|
||||
warnings.warn(
|
||||
'The CloudConfig class has been deprecated in favour of '
|
||||
'CloudRegion. Please update your references.',
|
||||
os_warnings.RemovedInSDK60Warning,
|
||||
)
|
||||
|
||||
self.region = region
|
||||
|
||||
super().__init__(
|
||||
name,
|
||||
region,
|
||||
config,
|
||||
force_ipv4=force_ipv4,
|
||||
auth_plugin=auth_plugin,
|
||||
openstack_config=openstack_config,
|
||||
session_constructor=session_constructor,
|
||||
app_name=app_name,
|
||||
app_version=app_version,
|
||||
session=session,
|
||||
discovery_cache=discovery_cache,
|
||||
extra_config=extra_config,
|
||||
cache_expiration_time=cache_expiration_time,
|
||||
cache_expirations=cache_expirations,
|
||||
cache_path=cache_path,
|
||||
cache_class=cache_class,
|
||||
cache_arguments=cache_arguments,
|
||||
password_callback=password_callback,
|
||||
statsd_host=statsd_host,
|
||||
statsd_port=statsd_port,
|
||||
statsd_prefix=statsd_prefix,
|
||||
influxdb_config=influxdb_config,
|
||||
collector_registry=collector_registry,
|
||||
cache_auth=cache_auth,
|
||||
)
|
||||
|
@@ -222,6 +222,7 @@ class Proxy(adapter.Adapter):
|
||||
|
||||
try:
|
||||
if conn.cache_enabled and not skip_cache and method == 'GET':
|
||||
assert key is not None # type narrow
|
||||
# Get the object expiration time from config
|
||||
# default to 0 to disable caching for this resource type
|
||||
expiration_time = int(
|
||||
|
@@ -245,7 +245,7 @@ class BaseFunctionalTest(base.TestCase):
|
||||
service_type=service_type, **kwargs
|
||||
)
|
||||
|
||||
if not (
|
||||
if not data or not (
|
||||
data.min_microversion
|
||||
and data.max_microversion
|
||||
and discover.version_between(
|
||||
|
@@ -35,6 +35,7 @@ module = [
|
||||
"openstack.common.*",
|
||||
"openstack.config._util",
|
||||
"openstack.config.defaults",
|
||||
"openstack.config.cloud_config",
|
||||
"openstack.config.cloud_region",
|
||||
"openstack.config.loader",
|
||||
"openstack.config.vendors",
|
||||
|
Reference in New Issue
Block a user