Open regisb opened 12 months ago
Looking into it
Here's a Dockerfile to reproduce the issue:
# syntax=docker/dockerfile:1
FROM python:3.10
RUN mkdir -p /test
ADD --keep-git-dir=true https://github.com/overhangio/tutor.git#master /test/tutor
ADD --keep-git-dir=true https://github.com/overhangio/tutor-cairn.git#master /test/tutor-cairn
RUN python -m venv /test/venv
ENV PATH /test/venv/bin:${PATH}
RUN pip install --upgrade pip setuptools
RUN pip install -e '/test/tutor[dev]'
WORKDIR /test/tutor-cairn
RUN make test-types
$ docker build .
...
=> ERROR [9/9] RUN make test-types 2.7s
------
> [9/9] RUN make test-types:
0.271 mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ./tutorcairn
2.636 tutorcairn/plugin.py:120: error: Untyped decorator makes function "_print_superset_host" untyped [misc]
2.638 Found 1 error in 1 file (checked 3 source files)
2.644 make: *** [Makefile:16: test-types] Error 1
------
Dockerfile:15
--------------------
13 |
14 | WORKDIR /test/tutor-cairn
15 | >>> RUN make test-types
16 |
--------------------
ERROR: failed to solve: process "/bin/sh -c make test-types" did not complete successfully: exit code: 2
Building the image succeeds when we replace pip install -e
by pip install
.
See this issue in practice in this failed test run: https://github.com/overhangio/tutor-credentials/actions/runs/7568050350/job/20608428713
The strict mode also seems to does the trick. It can be acheived through:
pip install -e . --config-settings editable_mode=strict
@regisb Can you please provide insights on it? If there is no more discussion on it, we can close this.
This issue is still open. For instance, consider the case of nightly. We are telling people to install tutor with pip install -e .
, as they are used to. But that means that they won't be able to run make test-types
on their plugins, which is a shame. It's an upstream issue, and I don't know if we can address it in Tutor, but I don't think it should be closed.
Bug description
Type tests fail when tutor is installed in editable mode. This is inconvenient when testing plugins locally.
How to reproduce
Install tutor in editable mode:
Run type tests for a plugin:
That error is caused by the fact that mypy does not find the tutor module, has the following attests:
Additional context
This is a known issue. See the upstream tickets in mypy and setuptools:
https://github.com/python/mypy/issues/13392 https://github.com/pypa/setuptools/issues/3518
The issue can be bypassed by installing tutor in legacy mode:
Or by installing in non-editable mode: