Type issues in drivers (filesystem and VMware)

Bug #1813092 reported by Cyril Roelandt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glance_store
Fix Released
Undecided
Cyril Roelandt

Bug Description

The _get_datadir_path_and_priority and _parse_datastore_info_and_weight methods may return the priority (or weight) as an integer or a string. This causes a few issues:

- the caller must cast the result to an integer
- the code is harder to read
- static checkers such as mypy have a hard time processing these methods

Running mypy shows the issue:

$ mypy glance_store/_drivers/filesystem.py
...
glance_store/_drivers/filesystem.py:494: error: "int" has no attribute "isdigit"
$ mypy glance_store/_drivers/vmware_datastore.py
...
glance_store/_drivers/vmware_datastore.py:467: error: "int" has no attribute "isdigit"

This happens because the "priority" and "weight" variables are initialized using an integer, and are later assigned to a string. Obviously, mypy is a bit too strong, but following its recommendations make the code much clearer.

Changed in glance-store:
assignee: nobody → Cyril Roelandt (cyril-roelandt)
Changed in glance-store:
status: New → In Progress
Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :

Fix proposed to master branch, https://review.openstack.org/#/c/631994

Changed in glance-store:
milestone: none → 1.0.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance_store (master)

Reviewed: https://review.openstack.org/631994
Committed: https://git.openstack.org/cgit/openstack/glance_store/commit/?id=ac5abddb6ff48e3cafb31a51ba39abf5ab93e698
Submitter: Zuul
Branch: master

commit ac5abddb6ff48e3cafb31a51ba39abf5ab93e698
Author: Cyril Roelandt <email address hidden>
Date: Sun Jan 20 00:35:17 2019 +0100

    Fix some types in the FS and VMware drivers

    The _get_datadir_path_and_priority and _parse_datastore_info_and_weight methods
    may return the priority (or weight) as an integer or a string. This causes a few
    issues:

    - the caller must cast the result to an integer
    - the code is harder to read
    - static checkers such as mypy have a hard time processing these methods

    We make sure that both methods now return the priority as an integer.

    Closes-Bug: #1813092
    Change-Id: I9435c88560b01737f9310fe2cba1ca4c84e0f3fa

Changed in glance-store:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance_store 0.28.0

This issue was fixed in the openstack/glance_store 0.28.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.