Skip to content
Snippets Groups Projects

Trying to bump mypy to 1.0

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Jérémy Bobbio (Lunar)

    Sadly this is not enough:

    $ tox run -e mypy
    .pkg: _optional_hooks> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
    .pkg: get_requires_for_build_editable> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
    .pkg: get_requires_for_build_sdist> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
    .pkg: build_wheel> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
    .pkg: build_sdist> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
    mypy: recreate env because dependencies removed: mypy==0.942
    mypy: remove tox env folder /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/mypy
    mypy: install_deps> python -I -m pip install 'mypy~=1.0'
    mypy: install_package_deps> python -I -m pip install beautifulsoup4 chardet cryptography decorator django-cors-headers django-js-reverse django-stubs django-test-migrations django-webpack-loader 'django<3' djangorestframework djangorestframework-stubs docutils htmlmin hypothesis iso8601 lxml prometheus-client psycopg2 'pybadges>=2.2.1' pygments pytest-django pytest-mock 'pytest-postgresql<4.0.0' 'pytest>=7.0.0' 'python-magic>=0.4.0' python-memcached pyyaml requests 'requests-mock!=1.9.0,!=1.9.1' sentry-sdk 'swh-scheduler[testing]>=0.5.0' 'swh.auth[django]>=0.6.7' 'swh.core>=0.0.95' 'swh.core[http]>=0.0.95' 'swh.counters>=0.5.1' 'swh.indexer>=2.0.0' 'swh.loader.git>=0.8.0' 'swh.model>=6.3.0' 'swh.scheduler>=0.7.0' 'swh.search>=0.16.0' 'swh.storage>=0.1.1' 'swh.storage>=1.4.0' 'swh.vault>=1.0.0' types-chardet types-cryptography types-docutils types-psycopg2 types-pyyaml types-requests typing-extensions
    mypy: install_package> python -I -m pip install --force-reinstall --no-deps /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tmp/package/6/swh.web-0.2.17.dev2+g2859c740.d20230216.tar.gz
    mypy: commands[0]> mypy swh
    swh/web/mailmap/migrations/0001_initial.py:13: error: Unused "type: ignore" comment
    swh/web/add_forge_now/migrations/0001_initial.py:11: error: Unused "type: ignore" comment
    swh/web/utils/urlsindex.py:18: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    swh/web/utils/archive.py:1186: error: Incompatible default for argument "allowed_statuses" (default has type "None", argument has type "List[str]")  [assignment]
    swh/web/utils/archive.py:1186: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
    swh/web/utils/archive.py:1186: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
    swh/web/tests/data.py:282: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    swh/web/tests/data.py:401: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    swh/web/tests/data.py:403: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    swh/web/save_code_now/management/commands/refresh_savecodenow_statuses.py:36: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    swh/web/api/views/utils.py:71: error: Item "List[Any]" of "Union[Iterator[Any], List[Any]]" has no attribute "__next__"  [union-attr]
    Found 4 errors in 4 files (checked 284 source files)
    mypy: exit 1 (14.33 seconds) /home/lunar/Documents/SWH/swh-environment/swh-web> mypy swh pid=1134052
    .pkg: _exit> python /home/lunar/Documents/SWH/swh-environment/swh-web/.tox/.tox/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
      mypy: FAIL code 1 (40.75=setup[26.41]+cmd[14.33] seconds)
      evaluation failed :( (40.81 seconds)
    diff 729 B
    diff --git a/requirements-test.txt b/requirements-test.txt
    index 9d982281..9323f68a 100644
    --- a/requirements-test.txt
    +++ b/requirements-test.txt
    @@ -3,8 +3,6 @@ djangorestframework-stubs
     django-stubs
     django-test-migrations
     hypothesis
    -# TODO: remove that pin once we bump mypy to > 0.950 in tox.ini
    -mypy == 0.942
     pytest >= 7.0.0 # older versions work too, but assertion failures cause https://github.com/untitaker/pytest-subtesthack/issues/4
     pytest-django
     pytest-mock
    diff --git a/tox.ini b/tox.ini
    index 8a8e3b9f..1fe40107 100644
    --- a/tox.ini
    +++ b/tox.ini
    @@ -30,7 +30,7 @@ setenv = DJANGO_SETTINGS_MODULE = swh.web.settings.development
     extras =
       testing
     deps =
    -  mypy==0.942
    +  mypy~=1.0
     commands =
       mypy swh
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment