Page MenuHomeSoftware Heritage

db_utils: Fix typing of db/conninfo objects
ClosedPublic

Authored by vlorentz on Mar 3 2022, 1:43 PM.

Details

Summary

swh_set_db_module() takes a db_or_conninfo object, and passes it to execute_sqlfiles,
which only expects a conninfo.

This is detected by mypy when using a recent version of types-psycopg2.

@bchauvet This takes care of the other issue you had

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D7282 (id=26367)

Could not rebase; Attempt merge onto 20da92e353...

Updating 20da92e..d23e03c
Fast-forward
 mypy.ini                |  3 ---
 requirements-test.txt   |  1 +
 swh/core/db/db_utils.py | 10 +++++++++-
 3 files changed, 10 insertions(+), 4 deletions(-)
Changes applied before test
commit d23e03ca4c3d911e6d63d529c9a9e11ed6369443
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Mar 3 13:41:58 2022 +0100

    db_utils: Fix typing of db/conninfo objects
    
    swh_set_db_module() takes a db_or_conninfo object, and passes it to execute_sqlfiles,
    which only expects a conninfo.
    
    This is detected by mypy when using a recent version of types-psycopg2.

commit d58973501d0e9e8f7517db435c937fcd9408cfab
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Mar 3 13:35:37 2022 +0100

    db_utils: Add missing import of psycopg2.errors
    
    This may be needed depending on import order; but it makes mypy complain when
    types-psycopg2 is installed.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/369/ for more details.

Build is green

Patch application report for D7282 (id=26368)

Could not rebase; Attempt merge onto 20da92e353...

Updating 20da92e..83fb36b
Fast-forward
 mypy.ini                |  3 ---
 requirements-test.txt   |  1 +
 swh/core/db/db_utils.py | 14 +++++++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)
Changes applied before test
commit 83fb36b83fc5cb0a2dddb3eb312824f5beb3a754
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Mar 3 13:41:58 2022 +0100

    db_utils: Fix typing of db/conninfo objects
    
    swh_set_db_module() takes a db_or_conninfo object, and passes it to execute_sqlfiles,
    which only expects a conninfo.
    
    This is detected by mypy when using a recent version of types-psycopg2.

commit d58973501d0e9e8f7517db435c937fcd9408cfab
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Mar 3 13:35:37 2022 +0100

    db_utils: Add missing import of psycopg2.errors
    
    This may be needed depending on import order; but it makes mypy complain when
    types-psycopg2 is installed.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/370/ for more details.

This revision is now accepted and ready to land.Mar 3 2022, 6:18 PM