Page MenuHomeSoftware Heritage

requirements.txt: Add typing-extensions as dependency
ClosedPublic

Authored by anlambert on Jan 10 2020, 1:28 PM.

Details

Summary

The typing_extensions module is used since 764802021812 so we need to add it as explicit dependency.

This is what we get in docker for instance otherwise:

Traceback (most recent call last):
swh-web_1                       |   File "/srv/softwareheritage/venv/bin/django-admin", line 8, in <module>
swh-web_1                       |     sys.exit(execute_from_command_line())
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
swh-web_1                       |     utility.execute()
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 356, in execute
swh-web_1                       |     self.fetch_command(subcommand).run_from_argv(self.argv)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
swh-web_1                       |     self.execute(*args, **cmd_options)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/base.py", line 327, in execute
swh-web_1                       |     self.check()
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/base.py", line 359, in check
swh-web_1                       |     include_deployment_checks=include_deployment_checks,
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
swh-web_1                       |     issues.extend(super(Command, self)._run_checks(**kwargs))
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/management/base.py", line 346, in _run_checks
swh-web_1                       |     return checks.run_checks(**kwargs)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
swh-web_1                       |     new_errors = check(app_configs=app_configs)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
swh-web_1                       |     return check_resolver(resolver)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
swh-web_1                       |     return check_method()
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 256, in check
swh-web_1                       |     for pattern in self.url_patterns:
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/utils/functional.py", line 35, in __get__
swh-web_1                       |     res = instance.__dict__[self.name] = self.func(instance)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
swh-web_1                       |     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/utils/functional.py", line 35, in __get__
swh-web_1                       |     res = instance.__dict__[self.name] = self.func(instance)
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
swh-web_1                       |     return import_module(self.urlconf_name)
swh-web_1                       |   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
swh-web_1                       |     return _bootstrap._gcd_import(name[level:], package, level)
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
swh-web_1                       |   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/urls.py", line 36, in <module>
swh-web_1                       |     url(r'^api/', include('swh.web.api.urls')),
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/django/conf/urls/__init__.py", line 50, in include
swh-web_1                       |     urlconf_module = import_module(urlconf_module)
swh-web_1                       |   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
swh-web_1                       |     return _bootstrap._gcd_import(name[level:], package, level)
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
swh-web_1                       |   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
swh-web_1                       |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/urls.py", line 6, in <module>
swh-web_1                       |     import swh.web.api.views.content # noqa
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/content.py", line 16, in <module>
swh-web_1                       |     from swh.web.api.views.utils import api_lookup
swh-web_1                       |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/utils.py", line 8, in <module>
swh-web_1                       |     from typing_extensions import Protocol
swh-web_1                       | ModuleNotFoundError: No module named 'typing_extensions'

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Update: only the typing-extensions is required, not mypy

anlambert retitled this revision from requirements.txt: Add mypy as dependency to requirements.txt: Add typing-extensions as dependency.Jan 10 2020, 2:06 PM
anlambert edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Jan 10 2020, 2:20 PM
vlorentz requested changes to this revision.EditedJan 10 2020, 2:22 PM

Why do we need typing_extensions?

EnrichFunction could be defined like this:

EnrichFunction = Callable[
    [Mapping[str, str], Optional[HttpRequest]],
    Dict[str, str]
]
This revision now requires changes to proceed.Jan 10 2020, 2:22 PM

Because Callable does not support keyword arguments and the only alternative is to use callback protocols (see https://mypy.readthedocs.io/en/latest/additional_features.html#extended-callable-types)

14:24 $ make typecheck 
Makefile.local:97: avertissement : surchargement de la recette pour la cible « check-mypy »
../Makefile.python:39: avertissement : ancienne recette ignorée pour la cible « check-mypy »
DJANGO_SETTINGS_MODULE=swh.web.settings.development mypy  swh
swh/web/api/views/utils.py:66: error: Unexpected keyword argument "request"
swh/web/api/views/utils.py:67: error: Unexpected keyword argument "request"
This revision is now accepted and ready to land.Jan 10 2020, 2:31 PM
This revision was landed with ongoing or failed builds.Jan 10 2020, 2:38 PM
This revision was automatically updated to reflect the committed changes.