Page MenuHomeSoftware Heritage

Fix mypy error in swh/deposit/urls.py
ClosedPublic

Authored by vlorentz on Nov 26 2020, 4:19 PM.

Details

Summary

If djangorestframework-stubs does not contain the stub for
format_suffix_patterns, then mypy does not see any issue on passing it
a List[object] as argument, so the # type: ignore is useless,
so mypy complains about it.

Diff Detail

Repository
rDDEP Push deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build has FAILED

Patch application report for D4608 (id=16351)

Could not rebase; Attempt merge onto ad6041d312...

Updating ad6041d3..cb09d873
Fast-forward
 docs/endpoints/collection.rst                      |  2 --
 docs/specs/spec-loading.rst                        |  3 +-
 docs/specs/swh.xsd                                 | 35 ++++++++++++-------
 swh/deposit/api/collection.py                      | 12 ++-----
 swh/deposit/api/common.py                          | 39 +++++++++-------------
 swh/deposit/cli/client.py                          | 16 ++++-----
 swh/deposit/client.py                              | 19 +++++++----
 swh/deposit/errors.py                              | 15 ---------
 .../0021_deposit_origin_url_20201124_1438.py       | 28 ++++++++++++++++
 swh/deposit/models.py                              |  9 +++--
 swh/deposit/tests/api/test_collection_post_atom.py | 19 ++++++++---
 .../tests/api/test_collection_post_binary.py       | 18 +++++++---
 .../tests/api/test_collection_post_multipart.py    | 18 +++++++---
 .../api/test_deposit_private_read_metadata.py      | 13 +++-----
 swh/deposit/tests/cli/test_client.py               |  8 ++---
 swh/deposit/urls.py                                |  4 +--
 16 files changed, 148 insertions(+), 110 deletions(-)
 create mode 100644 swh/deposit/migrations/0021_deposit_origin_url_20201124_1438.py
Changes applied before test
commit cb09d873dbe8a8037f34b3322bf83209d85ca706
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 19:32:12 2020 +0100

    Fix mypy error.
    
    The 'type: ignore' comment makes errors on my machine,
    but removing it errors on Jenkins.
    So I'm fixing it by removing the name clash.

commit f863ea93a22b3132749261d479f9d2a8117d52bd
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 26 14:45:48 2020 +0100

    Don't generate slugs on the client side
    
    They are not mandatory anymore.

commit fa3a3591e6932e16c13890f45b1bd26296954e74
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 17:49:13 2020 +0100

    Make the Slug header optional.
    
    To follow the SWORD specification.

commit 45b596f198df963edb2d6f5353763704b16fd05d
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 15:50:47 2020 +0100

    Defer origin_url computation until the deposit completes.
    
    In a future commit, the origin_url computation will only be a fallback
    in case it's not provided in any of the Atom entries; so we have
    to compute this fallback after all Atom entries are given, ie. when
    the deposit completes.

commit 1a2da5e1805f7d65cdd6c22b6180ad6fb00d623a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 15:52:36 2020 +0100

    add column 'origin_url' on Deposit.
    
    For now, it's only computed based on the external_id, but clients
    will provide it in future versions.

commit 2e4a524a2480dbd3baa6f59390528fd694ea7390
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:20:19 2020 +0100

    swh.xsd: Use the https://www.softwareheritage.org/schema/2018/deposit namespace

commit 88b102aec44185b97b06135d862821bb4c138acc
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:11:31 2020 +0100

    swh.xsd: Improve readability
    
    This also moves the inner element definitions of <swh:reference> to
    root elements, so they can be reused by new definitions in the future.

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

swh/deposit/urls.py:31: error: Argument 1 to "format_suffix_patterns" has incompatible type "List[object]"; expected "List[URLPattern]"

computer still says no... ¯\_(ツ)_/¯

Build is green

Patch application report for D4608 (id=16374)

Could not rebase; Attempt merge onto ad6041d312...

Updating ad6041d3..54859210
Fast-forward
 docs/endpoints/collection.rst                      |  2 --
 docs/specs/spec-loading.rst                        |  3 +-
 docs/specs/swh.xsd                                 | 35 ++++++++++++-------
 swh/deposit/api/collection.py                      | 12 ++-----
 swh/deposit/api/common.py                          | 39 +++++++++-------------
 swh/deposit/cli/client.py                          | 16 ++++-----
 swh/deposit/client.py                              | 19 +++++++----
 swh/deposit/errors.py                              | 15 ---------
 .../0021_deposit_origin_url_20201124_1438.py       | 28 ++++++++++++++++
 swh/deposit/models.py                              |  9 +++--
 swh/deposit/tests/api/test_collection_post_atom.py | 19 ++++++++---
 .../tests/api/test_collection_post_binary.py       | 18 +++++++---
 .../tests/api/test_collection_post_multipart.py    | 18 +++++++---
 .../api/test_deposit_private_read_metadata.py      | 13 +++-----
 swh/deposit/tests/cli/test_client.py               |  8 ++---
 tox.ini                                            |  2 +-
 16 files changed, 147 insertions(+), 109 deletions(-)
 create mode 100644 swh/deposit/migrations/0021_deposit_origin_url_20201124_1438.py
Changes applied before test
commit 54859210bb5be911d26df0c47b7a1a7d4c2f35d1
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 26 14:45:48 2020 +0100

    Don't generate slugs on the client side
    
    They are not mandatory anymore.

commit fa3a3591e6932e16c13890f45b1bd26296954e74
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 17:49:13 2020 +0100

    Make the Slug header optional.
    
    To follow the SWORD specification.

commit 45b596f198df963edb2d6f5353763704b16fd05d
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 15:50:47 2020 +0100

    Defer origin_url computation until the deposit completes.
    
    In a future commit, the origin_url computation will only be a fallback
    in case it's not provided in any of the Atom entries; so we have
    to compute this fallback after all Atom entries are given, ie. when
    the deposit completes.

commit 1a2da5e1805f7d65cdd6c22b6180ad6fb00d623a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 15:52:36 2020 +0100

    add column 'origin_url' on Deposit.
    
    For now, it's only computed based on the external_id, but clients
    will provide it in future versions.

commit 2e4a524a2480dbd3baa6f59390528fd694ea7390
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:20:19 2020 +0100

    swh.xsd: Use the https://www.softwareheritage.org/schema/2018/deposit namespace

commit 88b102aec44185b97b06135d862821bb4c138acc
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:11:31 2020 +0100

    swh.xsd: Improve readability
    
    This also moves the inner element definitions of <swh:reference> to
    root elements, so they can be reused by new definitions in the future.

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

vlorentz retitled this revision from Fix mypy error. to Fix mypy error in swh/deposit/urls.py.Nov 27 2020, 11:18 AM
vlorentz edited the summary of this revision. (Show Details)

Build is green

Patch application report for D4608 (id=16375)

Could not rebase; Attempt merge onto ad6041d312...

Updating ad6041d3..08606f2e
Fast-forward
 docs/endpoints/collection.rst                      |  2 --
 docs/specs/spec-loading.rst                        |  3 +-
 docs/specs/swh.xsd                                 | 35 ++++++++++++-------
 swh/deposit/api/collection.py                      | 12 ++-----
 swh/deposit/api/common.py                          | 39 +++++++++-------------
 swh/deposit/cli/client.py                          | 16 ++++-----
 swh/deposit/client.py                              | 19 +++++++----
 swh/deposit/errors.py                              | 15 ---------
 .../0021_deposit_origin_url_20201124_1438.py       | 28 ++++++++++++++++
 swh/deposit/models.py                              |  9 +++--
 swh/deposit/tests/api/test_collection_post_atom.py | 19 ++++++++---
 .../tests/api/test_collection_post_binary.py       | 18 +++++++---
 .../tests/api/test_collection_post_multipart.py    | 18 +++++++---
 .../api/test_deposit_private_read_metadata.py      | 13 +++-----
 swh/deposit/tests/cli/test_client.py               |  8 ++---
 tox.ini                                            |  2 +-
 16 files changed, 147 insertions(+), 109 deletions(-)
 create mode 100644 swh/deposit/migrations/0021_deposit_origin_url_20201124_1438.py
Changes applied before test
commit 08606f2e2c4d39e34fbd215cdb56a75101d436b7
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Nov 27 11:11:12 2020 +0100

    fix mypy error in swh/deposit/urls.py
    
    If djangorestframework-stubs does not contain the stub for
    `format_suffix_patterns`, then mypy does not see any issue on passing it
    a `List[object]` as argument, so the `# type: ignore` is useless,
    so mypy complains about it.

commit 064406d8f788643f134707e356e3bbda6f07790d
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 26 14:45:48 2020 +0100

    Don't generate slugs on the client side
    
    They are not mandatory anymore.

commit fa3a3591e6932e16c13890f45b1bd26296954e74
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 17:49:13 2020 +0100

    Make the Slug header optional.
    
    To follow the SWORD specification.

commit 45b596f198df963edb2d6f5353763704b16fd05d
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 15:50:47 2020 +0100

    Defer origin_url computation until the deposit completes.
    
    In a future commit, the origin_url computation will only be a fallback
    in case it's not provided in any of the Atom entries; so we have
    to compute this fallback after all Atom entries are given, ie. when
    the deposit completes.

commit 1a2da5e1805f7d65cdd6c22b6180ad6fb00d623a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 15:52:36 2020 +0100

    add column 'origin_url' on Deposit.
    
    For now, it's only computed based on the external_id, but clients
    will provide it in future versions.

commit 2e4a524a2480dbd3baa6f59390528fd694ea7390
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:20:19 2020 +0100

    swh.xsd: Use the https://www.softwareheritage.org/schema/2018/deposit namespace

commit 88b102aec44185b97b06135d862821bb4c138acc
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:11:31 2020 +0100

    swh.xsd: Improve readability
    
    This also moves the inner element definitions of <swh:reference> to
    root elements, so they can be reused by new definitions in the future.

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

vlorentz edited the summary of this revision. (Show Details)

rebase

Build is green

Patch application report for D4608 (id=16380)

Could not rebase; Attempt merge onto ad6041d312...

Updating ad6041d3..f02b7f71
Fast-forward
 docs/endpoints/collection.rst                      |  2 --
 docs/specs/spec-loading.rst                        |  3 +-
 docs/specs/swh.xsd                                 | 35 ++++++++++++-------
 swh/deposit/api/collection.py                      | 12 ++-----
 swh/deposit/api/common.py                          | 39 +++++++++-------------
 swh/deposit/cli/client.py                          | 16 ++++-----
 swh/deposit/client.py                              | 19 +++++++----
 swh/deposit/errors.py                              | 15 ---------
 .../0021_deposit_origin_url_20201124_1438.py       | 28 ++++++++++++++++
 swh/deposit/models.py                              |  9 +++--
 swh/deposit/tests/api/test_collection_post_atom.py | 19 ++++++++---
 .../tests/api/test_collection_post_binary.py       | 18 +++++++---
 .../tests/api/test_collection_post_multipart.py    | 18 +++++++---
 .../api/test_deposit_private_read_metadata.py      | 13 +++-----
 swh/deposit/tests/cli/test_client.py               |  8 ++---
 tox.ini                                            |  2 +-
 16 files changed, 147 insertions(+), 109 deletions(-)
 create mode 100644 swh/deposit/migrations/0021_deposit_origin_url_20201124_1438.py
Changes applied before test
commit f02b7f71fba1aeb6c3fdc1c7eb4e9118e13de2a0
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Fri Nov 27 11:11:12 2020 +0100

    fix mypy error in swh/deposit/urls.py
    
    If djangorestframework-stubs does not contain the stub for
    `format_suffix_patterns`, then mypy does not see any issue on passing it
    a `List[object]` as argument, so the `# type: ignore` is useless,
    so mypy complains about it.

commit 5989af38c9e6b3d5e32e20bd125aa149d6668e8a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 26 14:45:48 2020 +0100

    Don't generate slugs on the client side
    
    They are not mandatory anymore.

commit fc5a5ee0b1c67c90c3eaf5a924a6c46eb6fb0f7f
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 17:49:13 2020 +0100

    Make the Slug header optional.
    
    To follow the SWORD specification.

commit e7316d6d8a527eb4a96eb2e9d46daa0045c6b851
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Nov 25 15:50:47 2020 +0100

    Defer origin_url computation until the deposit completes.
    
    In a future commit, the origin_url computation will only be a fallback
    in case it's not provided in any of the Atom entries; so we have
    to compute this fallback after all Atom entries are given, ie. when
    the deposit completes.

commit a21961284e3b88a3c21fc0b67cae793351331e7f
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 15:52:36 2020 +0100

    add column 'origin_url' on Deposit.
    
    For now, it's only computed based on the external_id, but clients
    will provide it in future versions.

commit 2e4a524a2480dbd3baa6f59390528fd694ea7390
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:20:19 2020 +0100

    swh.xsd: Use the https://www.softwareheritage.org/schema/2018/deposit namespace

commit 88b102aec44185b97b06135d862821bb4c138acc
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Nov 24 12:11:31 2020 +0100

    swh.xsd: Improve readability
    
    This also moves the inner element definitions of <swh:reference> to
    root elements, so they can be reused by new definitions in the future.

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

build is green but i no longer see the original fix.
Does that still fix something?

other than that, i don't see anything wrong with this...

This revision is now accepted and ready to land.Nov 27 2020, 1:24 PM

nah, no fix was needed, I just had an outdated env on my computer. this change ensures tox will get the right version

This revision was automatically updated to reflect the committed changes.