Skip to content

types-boto 2.49.18.20240205 regression: boto.iam.connection import triggers an error saying I need to install types-boto, which is already installed #11381

Closed as not planned

Description

@adamnovak

With types-boto==2.49.18.9 and boto==2.49.0 installed in my virtual environment, I am able to typecheck code that does this:

from boto.iam.connection import IAMConnection

If I make a fresh virtual environment and install the current types-boto==2.49.18.20240205 instead, it no longer typechecks. It thinks that the boto stubs are not installed, when actually they are.

This works:

rm -Rf venv1 .mypy_cache test.py
python3.11 -m virtualenv venv1
. venv1/bin/activate
pip install --upgrade types-boto==2.49.18.9 boto==2.49.0 mypy==1.8.0
cat <<'EOF' >test.py
from boto.iam.connection import IAMConnection
EOF
mypy --strict test.py
Success: no issues found in 1 source file

This fails:

rm -Rf venv2 .mypy_cache test.py
python3.11 -m virtualenv venv2
. venv2/bin/activate
pip install --upgrade types-boto==2.49.18.20240205 boto==2.49.0 mypy==1.8.0
cat <<'EOF' >test.py
from boto.iam.connection import IAMConnection
EOF
mypy --strict test.py
test.py:1: error: Library stubs not installed for "boto.iam.connection"  [import-untyped]
test.py:1: note: Hint: "python3 -m pip install types-boto"
test.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
test.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

There also seems to be something not quite right with MyPy's caching: if in the failing environment I install the old working stubs, typecheck, and then install the new stubs, suddenly the type checking passes with the new stubs installed. It only fails if they are installed in a fresh virtual environment, or if I try to typecheck after uninstalling the old stubs and before installing the new ones.

(venv2) [anovak@swords type-test]% mypy --strict test.py
test.py:1: error: Library stubs not installed for "boto.iam.connection"  [import-untyped]
test.py:1: note: Hint: "python3 -m pip install types-boto"
test.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
test.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
(venv2) [anovak@swords type-test]% pip install --upgrade types-boto==2.49.18.9
Collecting types-boto==2.49.18.9
  Using cached types_boto-2.49.18.9-py3-none-any.whl.metadata (1.5 kB)
Using cached types_boto-2.49.18.9-py3-none-any.whl (23 kB)
Installing collected packages: types-boto
  Attempting uninstall: types-boto
    Found existing installation: types-boto 2.49.18.20240205
    Uninstalling types-boto-2.49.18.20240205:
      Successfully uninstalled types-boto-2.49.18.20240205
Successfully installed types-boto-2.49.18.9

[notice] A new release of pip is available: 23.3.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
(venv2) [anovak@swords type-test]% mypy --strict test.py
Success: no issues found in 1 source file
(venv2) [anovak@swords type-test]% pip install --upgrade types-boto==2.49.18.20240205
Collecting types-boto==2.49.18.20240205
  Using cached types_boto-2.49.18.20240205-py3-none-any.whl.metadata (1.7 kB)
Using cached types_boto-2.49.18.20240205-py3-none-any.whl (24 kB)
Installing collected packages: types-boto
  Attempting uninstall: types-boto
    Found existing installation: types-boto 2.49.18.9
    Uninstalling types-boto-2.49.18.9:
      Successfully uninstalled types-boto-2.49.18.9
Successfully installed types-boto-2.49.18.20240205

[notice] A new release of pip is available: 23.3.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
(venv2) [anovak@swords type-test]% mypy --strict test.py
Success: no issues found in 1 source file

Activity

  1. srittau commented on Feb 8, 2024

    @srittau
    Collaborator

    This seems to be a mypy problem. The new stubs include a py.typed marker set to "partial", which is true, since e.g. the stubs for boto.iam are missing. Mypy should merge the stubs with the implementation. In fact, the old stubs should have made mypy print an error, while the new stubs should work. See the typing spec for details. The weird caching behavior is another indicator that something wonky is going on with mypy.

  2. srittau commented on Feb 9, 2024

    @srittau
    Collaborator

    Thanks for reporting this on the mypy issue tracker.

  3. added a commit that references this issue on May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions