mypy: Address issues with remaining service modules

The changes here are all small enough to be bundled into one.

Change-Id: Ia585244e314a9bd18a7cd2388a2936517e25dbf2
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-07-27 10:18:59 +01:00
parent a7cfc5342f
commit 554dc6284c
11 changed files with 19 additions and 35 deletions

View File

@ -53,19 +53,8 @@ repos:
| openstack/tests/functional/.*
| openstack/tests/unit/.*
| openstack/tests/fixtures.py
| openstack/accelerator/.*
| openstack/cloud/.*
| openstack/container_infrastructure_management/.*
| openstack/database/.*
| openstack/dns/.*
| openstack/fixture/.*
| openstack/instance_ha/.*
| openstack/key_manager/.*
| openstack/load_balancer/.*
| openstack/message/.*
| openstack/placement/.*
| openstack/shared_file_system/.*
| openstack/workflow/.*
| doc/.*
| examples/.*
| releasenotes/.*

View File

@ -89,7 +89,7 @@ class Instance(resource.Resource):
:returns: ``None``
"""
body = {'restart': {}}
body = {'restart': None}
url = utils.urljoin(self.base_path, self.id, 'action')
session.post(url, json=body)

View File

@ -9,6 +9,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import typing as ty
import urllib.parse
from openstack import exceptions
@ -73,7 +75,7 @@ class Resource(resource.Resource):
@classmethod
def _get_next_link(cls, uri, response, data, marker, limit, total_yielded):
next_link = None
params = {}
params: ty.Dict[str, ty.Union[ty.List[str], str]] = {}
if isinstance(data, dict):
links = data.get('links')
if links:

View File

@ -29,17 +29,16 @@ class ZoneShare(_base.Resource):
_query_mapping = resource.QueryParameters('target_project_id')
# Properties
#: The ID of the zone being shared.
zone_id = resource.URI('zone_id')
#: Timestamp when the share was created.
created_at = resource.Body('created_at')
#: Timestamp when the member was last updated.
updated_at = resource.Body('updated_at')
# FIXME(stephenfin): This conflicts since there is a zone ID in the URI
#: The zone ID of the zone being shared.
zone_id = resource.Body('zone_id')
# zone_id = resource.Body('zone_id')
#: The project ID that owns the share.
project_id = resource.Body('project_id')
#: The target project ID that the zone is shared with.
target_project_id = resource.Body('target_project_id')
# URI Properties
#: The ID of the zone being shared.
zone_id = resource.URI('zone_id')

View File

@ -32,8 +32,6 @@ class Host(resource.Resource):
allow_commit = True
allow_delete = True
#: A ID of representing this host
id = resource.URI("id")
#: A Uuid of representing this host
uuid = resource.Body("uuid")
#: A failover segment ID of this host(in URI)

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import typing as ty
import uuid
from openstack import resource
@ -53,6 +54,10 @@ class Message(resource.Resource):
#: in case keystone auth is not enabled in Zaqar service.
project_id = resource.Header("X-PROJECT-ID")
# FIXME(stephenfin): This is actually a query arg but we need it for
# deletions and resource.delete doesn't respect these currently
claim_id: ty.Optional[str] = None
def post(self, session, messages):
request = self._prepare_request(requires_id=False, prepend_key=True)
headers = {

View File

@ -19,7 +19,9 @@ class ResourceProviderInventory(resource.Resource):
resources_key = None
base_path = '/resource_providers/%(resource_provider_id)s/inventories'
_query_mapping = {}
_query_mapping = resource.QueryParameters(
include_pagination_defaults=False
)
# Capabilities

View File

@ -468,7 +468,7 @@ class Resource(dict):
#: The name of this resource.
name: ty.Union[Body, URI] = Body("name")
#: The OpenStack location of this resource.
location: ty.Union[Computed, Body] = Computed('location')
location: ty.Union[Computed, Body, Header] = Computed('location')
#: Mapping of accepted query parameter names.
_query_mapping = QueryParameters()

View File

@ -97,7 +97,7 @@ class TestInstance(base.TestCase):
self.assertIsNone(sot.restart(sess))
url = "instances/%s/action" % IDENTIFIER
body = {'restart': {}}
body = {'restart': None}
sess.post.assert_called_with(url, json=body)
def test_action_resize(self):

View File

@ -39,7 +39,7 @@ class TestResourceProviderInventory(base.TestCase):
self.assertTrue(sot.allow_list)
self.assertFalse(sot.allow_patch)
self.assertDictEqual({}, sot._query_mapping)
self.assertDictEqual({}, sot._query_mapping._mapping)
def test_make_it(self):
sot = resource_provider_inventory.ResourceProviderInventory(**FAKE)

View File

@ -47,19 +47,8 @@ exclude = (?x)(
| openstack/tests/functional
| openstack/tests/unit
| openstack/tests/fixtures.py
| openstack/accelerator
| openstack/cloud
| openstack/container_infrastructure_management
| openstack/database
| openstack/dns
| openstack/fixture
| openstack/instance_ha
| openstack/key_manager
| openstack/load_balancer
| openstack/message
| openstack/placement
| openstack/shared_file_system
| openstack/workflow
| doc
| examples
| releasenotes