typing: Removing additional unused kwargs (1/2)
Remove kwargs from the following methods in 'keystoneauth1.plugin.BaseAuthPlugin' and all subclasses as they are not used in any subclass nor provided by the 'keystoneauth1.session.Session' or 'keystoneauth1.adapter.Adapter' classes: get_user_id get_project_id get_sp_auth_url get_sp_url Also remove kwargs from the following methods in 'BaseAuthPlugin' and all subclasses, along with the equivalent wrapping method in 'Session'. While these are provided by the 'Session' method, none of the 'BaseAuthPlugin' subclasses are actually using them. keystoneauth1.plugin.BaseAuthPlugin.get_all_version_data keystoneauth1.session.Session.get_all_version_data Note that the equivalent method in Adapter never allowed kwargs so that doesn't need updates. Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Change-Id: I73a30fd2c878d57474447f30cb07ae0f47385e04
This commit is contained in:
@@ -75,10 +75,10 @@ class TestPlugin(plugin.BaseAuthPlugin):
|
||||
def get_token(self, session):
|
||||
return self.token
|
||||
|
||||
def get_user_id(self, session, **kwargs):
|
||||
def get_user_id(self, session):
|
||||
return self.user_id
|
||||
|
||||
def get_project_id(self, session, **kwargs):
|
||||
def get_project_id(self, session):
|
||||
return self.project_id
|
||||
|
||||
def invalidate(self):
|
||||
|
||||
@@ -587,7 +587,6 @@ class BaseIdentityPlugin(plugin.BaseAuthPlugin, metaclass=abc.ABCMeta):
|
||||
interface: str = 'public',
|
||||
region_name: ty.Optional[str] = None,
|
||||
service_type: ty.Optional[str] = None,
|
||||
**kwargs: ty.Any,
|
||||
) -> dict[str, dict[str, dict[str, list[discover.VersionData]]]]:
|
||||
"""Get version data for all services in the catalog.
|
||||
|
||||
@@ -644,18 +643,14 @@ class BaseIdentityPlugin(plugin.BaseAuthPlugin, metaclass=abc.ABCMeta):
|
||||
|
||||
return version_data
|
||||
|
||||
def get_user_id(
|
||||
self, session: ks_session.Session, **kwargs: ty.Any
|
||||
) -> ty.Optional[str]:
|
||||
def get_user_id(self, session: ks_session.Session) -> ty.Optional[str]:
|
||||
return self.get_access(session).user_id
|
||||
|
||||
def get_project_id(
|
||||
self, session: ks_session.Session, **kwargs: ty.Any
|
||||
) -> ty.Optional[str]:
|
||||
def get_project_id(self, session: ks_session.Session) -> ty.Optional[str]:
|
||||
return self.get_access(session).project_id
|
||||
|
||||
def get_sp_auth_url(
|
||||
self, session: ks_session.Session, sp_id: str, **kwargs: ty.Any
|
||||
self, session: ks_session.Session, sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
service_providers = self.get_access(session).service_providers
|
||||
if not service_providers:
|
||||
@@ -666,7 +661,7 @@ class BaseIdentityPlugin(plugin.BaseAuthPlugin, metaclass=abc.ABCMeta):
|
||||
return None
|
||||
|
||||
def get_sp_url(
|
||||
self, session: ks_session.Session, sp_id: str, **kwargs: ty.Any
|
||||
self, session: ks_session.Session, sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
service_providers = self.get_access(session).service_providers
|
||||
if not service_providers:
|
||||
|
||||
@@ -207,7 +207,6 @@ class BaseAuthPlugin:
|
||||
interface: str = 'public',
|
||||
region_name: ty.Optional[str] = None,
|
||||
service_type: ty.Optional[str] = None,
|
||||
**kwargs: ty.Any,
|
||||
) -> dict[str, dict[str, dict[str, list[discover.VersionData]]]]:
|
||||
"""Get version data for all services in the catalog.
|
||||
|
||||
@@ -224,6 +223,7 @@ class BaseAuthPlugin:
|
||||
:param string service_type:
|
||||
Limit the version data to a single service. (optional, defaults
|
||||
to None)
|
||||
|
||||
:returns: A dictionary keyed by region_name with values containing
|
||||
dictionaries keyed by interface with values being a list of
|
||||
:class:`~keystoneauth1.discover.VersionData`.
|
||||
@@ -247,6 +247,7 @@ class BaseAuthPlugin:
|
||||
|
||||
:param session: The session object that the auth_plugin belongs to.
|
||||
:type session: keystoneauth1.session.Session
|
||||
:param kwargs: Ignored.
|
||||
|
||||
:returns: The base URL that will be used to talk to the required
|
||||
service or None if not available.
|
||||
@@ -266,6 +267,7 @@ class BaseAuthPlugin:
|
||||
|
||||
:param session: The session object that the auth_plugin belongs to.
|
||||
:type session: keystoneauth1.session.Session
|
||||
:param kwargs: Ignored.
|
||||
|
||||
:returns: Headers that are set to authenticate a message or None for
|
||||
failure. Note that when checking this value that the empty
|
||||
@@ -290,9 +292,7 @@ class BaseAuthPlugin:
|
||||
"""
|
||||
return False
|
||||
|
||||
def get_user_id(
|
||||
self, session: 'ks_session.Session', **kwargs: ty.Any
|
||||
) -> ty.Optional[str]:
|
||||
def get_user_id(self, session: 'ks_session.Session') -> ty.Optional[str]:
|
||||
"""Return a unique user identifier of the plugin.
|
||||
|
||||
Wherever possible the user id should be inferred from the token however
|
||||
@@ -308,7 +308,7 @@ class BaseAuthPlugin:
|
||||
return None
|
||||
|
||||
def get_project_id(
|
||||
self, session: 'ks_session.Session', **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session'
|
||||
) -> ty.Optional[str]:
|
||||
"""Return the project id that we are authenticated to.
|
||||
|
||||
@@ -325,7 +325,7 @@ class BaseAuthPlugin:
|
||||
return None
|
||||
|
||||
def get_sp_auth_url(
|
||||
self, session: 'ks_session.Session', sp_id: str, **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session', sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
"""Return auth_url from the Service Provider object.
|
||||
|
||||
@@ -342,7 +342,7 @@ class BaseAuthPlugin:
|
||||
return None
|
||||
|
||||
def get_sp_url(
|
||||
self, session: 'ks_session.Session', sp_id: str, **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session', sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
"""Return sp_url from the Service Provider object.
|
||||
|
||||
@@ -413,7 +413,10 @@ class FixedEndpointPlugin(BaseAuthPlugin):
|
||||
self.endpoint = endpoint
|
||||
|
||||
def get_endpoint(
|
||||
self, session: 'ks_session.Session', **kwargs: ty.Any
|
||||
self,
|
||||
session: 'ks_session.Session',
|
||||
endpoint_override: ty.Optional[str] = None,
|
||||
**kwargs: ty.Any,
|
||||
) -> ty.Optional[str]:
|
||||
"""Return the supplied endpoint.
|
||||
|
||||
@@ -421,7 +424,7 @@ class FixedEndpointPlugin(BaseAuthPlugin):
|
||||
parameters passed to the plugin. endpoint_override overrides the
|
||||
endpoint specified when constructing the plugin.
|
||||
"""
|
||||
return kwargs.get('endpoint_override') or self.endpoint
|
||||
return endpoint_override or self.endpoint
|
||||
|
||||
def get_endpoint_data(
|
||||
self,
|
||||
|
||||
@@ -75,22 +75,20 @@ class ServiceTokenAuthWrapper(plugin.BaseAuthPlugin):
|
||||
) -> ty.Optional[str]:
|
||||
return self.user_auth.get_endpoint(session, **kwargs)
|
||||
|
||||
def get_user_id(
|
||||
self, session: 'ks_session.Session', **kwargs: ty.Any
|
||||
) -> ty.Optional[str]:
|
||||
return self.user_auth.get_user_id(session, **kwargs)
|
||||
def get_user_id(self, session: 'ks_session.Session') -> ty.Optional[str]:
|
||||
return self.user_auth.get_user_id(session)
|
||||
|
||||
def get_project_id(
|
||||
self, session: 'ks_session.Session', **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session'
|
||||
) -> ty.Optional[str]:
|
||||
return self.user_auth.get_project_id(session, **kwargs)
|
||||
return self.user_auth.get_project_id(session)
|
||||
|
||||
def get_sp_auth_url(
|
||||
self, session: 'ks_session.Session', sp_id: str, **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session', sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
return self.user_auth.get_sp_auth_url(session, sp_id, **kwargs)
|
||||
return self.user_auth.get_sp_auth_url(session, sp_id)
|
||||
|
||||
def get_sp_url(
|
||||
self, session: 'ks_session.Session', sp_id: str, **kwargs: ty.Any
|
||||
self, session: 'ks_session.Session', sp_id: str
|
||||
) -> ty.Optional[str]:
|
||||
return self.user_auth.get_sp_url(session, sp_id, **kwargs)
|
||||
return self.user_auth.get_sp_url(session, sp_id)
|
||||
|
||||
@@ -1483,7 +1483,6 @@ class Session:
|
||||
interface: str = 'public',
|
||||
region_name: ty.Optional[str] = None,
|
||||
service_type: ty.Optional[str] = None,
|
||||
**kwargs: ty.Any,
|
||||
) -> dict[str, dict[str, dict[str, list[discover.VersionData]]]]:
|
||||
"""Get version data for all services in the catalog.
|
||||
|
||||
@@ -1512,7 +1511,6 @@ class Session:
|
||||
interface=interface,
|
||||
region_name=region_name,
|
||||
service_type=service_type,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def get_auth_connection_params(
|
||||
@@ -1527,7 +1525,7 @@ class Session:
|
||||
|
||||
We restrict the values that may be returned from this function to
|
||||
prevent an auth plugin overriding values unrelated to connection
|
||||
parmeters. The values that are currently accepted are:
|
||||
parameters. The values that are currently accepted are:
|
||||
|
||||
- `cert`: a path to a client certificate, or tuple of client
|
||||
certificate and key pair that are used with this request.
|
||||
|
||||
@@ -1106,14 +1106,14 @@ class CalledAuthPlugin(plugin.BaseAuthPlugin):
|
||||
self.invalidate_called = True
|
||||
return self._invalidate
|
||||
|
||||
def get_project_id(self, session, **kwargs):
|
||||
self.get_project_id_called = True
|
||||
return self.PROJECT_ID
|
||||
|
||||
def get_user_id(self, session, **kwargs):
|
||||
def get_user_id(self, session):
|
||||
self.get_user_id_called = True
|
||||
return self.USER_ID
|
||||
|
||||
def get_project_id(self, session):
|
||||
self.get_project_id_called = True
|
||||
return self.PROJECT_ID
|
||||
|
||||
|
||||
class SessionAuthTests(utils.TestCase):
|
||||
TEST_URL = 'http://127.0.0.1:5000/'
|
||||
|
||||
Reference in New Issue
Block a user