Page MenuHomeSoftware Heritage

Fix upcoming type warning with swh.core > v0.1.2.
ClosedPublic

Authored by vlorentz on Wed, Jul 29, 10:31 AM.

Details

Reviewers
ardumont
Group Reviewers
Reviewers
Summary

origin_visit_status_get_latest expects an int, not Optional[int];
but this error wasn't detected so far because mypy couldn't detect
the type of the function.

The next release of swh.core fixes that issue, so this fix is now
needed to not trigger a mypy error.

Diff Detail

Repository
rDSTO Storage manager
Branch
types
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14027
Build 21532: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 21531: arc lint + arc unit

Unit TestsFailed

TimeTest
1,429 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_api_client.TestStorage::test_types
self = <swh.storage.tests.test_api_client.TestStorage object at 0x7f922bed6e10> swh_storage_backend_config = {'cls': 'local', 'db': 'postgresql://postgres@127.0.0.1:20553/tests', 'journal_writer': {'cls': 'memory'}, 'objstorage': {'args': {}, 'cls': 'memory'}}
476 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_directory_add_from_generator
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f91d0429e10> swh_storage = <swh.storage.cassandra.storage.CassandraStorage object at 0x7f91d042d358> sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f91d02cfcc0>
529 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_revision_add_from_generator
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f91b07077f0> swh_storage = <swh.storage.cassandra.storage.CassandraStorage object at 0x7f91b07036a0> sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f91d007a748>
541 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_snapshot_add_many_from_generator
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f912c409b70> swh_storage = <swh.storage.cassandra.storage.CassandraStorage object at 0x7f912c3fde80> sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f912c25d7b8>
652 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_cassandra.TestCassandraStorage::test_types
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f9228425198> swh_storage_backend_config = {'cls': 'cassandra', 'hosts': ['127.0.0.1'], 'journal_writer': {'cls': 'memory'}, 'keyspace': '0535b0c3c0a6a0ed146f', ...}
View Full Test Results (10 Failed · 750 Passed · 17 Skipped)

Event Timeline

vlorentz created this revision.Wed, Jul 29, 10:31 AM

Build has FAILED

Patch application report for D3637 (id=12797)

Could not rebase; Attempt merge onto 77960ca4b5...

Updating 77960ca4..31d4dee8
Fast-forward
 swh/storage/algos/origin.py      |  5 ++--
 swh/storage/algos/snapshot.py    |  4 ++--
 swh/storage/cassandra/storage.py | 46 ++++++++++++++----------------------
 swh/storage/in_memory.py         | 41 ++++++++++++++------------------
 swh/storage/interface.py         | 48 +++++++++++++++++--------------------
 swh/storage/storage.py           | 51 ++++++++++++++++------------------------
 6 files changed, 83 insertions(+), 112 deletions(-)
Changes applied before test
commit 31d4dee85eb6b8a7106119ca08b87a5bf917f5f1
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Jul 29 10:30:45 2020 +0200

    Fix upcoming type warning with swh.core > v0.1.2.
    
    origin_visit_status_get_latest expects an int, not Optional[int];
    but this error wasn't detected so far because mypy couldn't detect
    the type of the function.
    
    The next release of swh.core fixes that issue, so this fix is now
    needed to not trigger a mypy error.

commit c56616b4f39fb783a83516c01e3c744c7a0cfbd9
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Jul 29 10:26:32 2020 +0200

    Make API endpoints take Lists instead of Iterables as arguments
    
    1. clients crash when they call the API with an iterator
    2. some backend implementations violate the contract by assuming
       the argument is a sequence (eg. by iterating twice on it, and
       assuming the elements are the same)
    3. no matter what we do, the endpoints will always get a list
       as argument in practice, because they go through the RPC framework
    4. there is no concrete (ha!) advantage in taking an Iterable rather
       than a List.

Link to build: https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/587/
See console output for more information: https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/587/console

This revision is now accepted and ready to land.Wed, Jul 29, 2:15 PM