# swegym / python__mypy-10937 - taskset: [swegym](https://harnessreport.com/tasks/swegym.md) - difficulty: hard - category: debugging - language: - runnable from the site: no - agent timeout: 3000s ## Results by harness _none yet_ ## Instruction ``` Cache causes mypy to fail every 2nd run for module importing from aws_cdk **Bug Report** When `mypy` is run multiple times on a Python module containing `from aws_cdk import core` it will fail every 2nd time due to the error "Skipping analyzing 'aws_cdk': found module but no type hints or library stubs". Disabling the mypy cache with `--no-incremental` will result in `mypy` passing every time. **To Reproduce** 1. Install `mypy` and `aws-cdk.core`. 2. Create a Python module with `from aws_cdk import core`. 3. Run `mypy` on the module and it will pass. 4. Run `mypy` on the module again and it will fail. Subsequent runs will cycle between passing and failing. ``` $ python3.8 -m venv .venv && source .venv/bin/activate (.venv) $ pip install mypy==0.790 aws-cdk.core==1.80.0 (.venv) $ echo 'from aws_cdk import core' > repro.py (.venv) $ mypy repro.py Success: no issues found in 1 source file (.venv) $ mypy repro.py repro.py:1: error: Skipping analyzing 'aws_cdk': found module but no type hints or library stubs repro.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports Found 1 error in 1 file (checked 1 source file) (.venv) $ mypy repro.py Success: no issues found in 1 source file (.venv) $ mypy repro.py repro.py:1: error: Skipping analyzing 'aws_cdk': found module but no type hints or library stubs repro.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports Found 1 error in 1 file (checked 1 source file) ``` **Expected Behavior** Running `mypy` on a module containing only `from aws_cdk import core` should always pass. **Actual Behavior** Every second time `mypy` is run on the module it will report an error. **Your Environment** - Mypy version used: 0.790 - Mypy command-line flags: none - Mypy configuration options from `mypy.ini` (and other config files): none - Python version used: 3.8.2 - Operating system and version: macOS - `aws-cdk.core` version used: 1.80.0 The problem may be related to how the package that is installed is `aws-cdk.core` but the namespace being imported from is `aws_cdk`. A workaround is to change: ```python from aws_cdk import core ``` to: ```python import aws_cdk.core as core ``` The first form is what is generated by [the `cdk` tool](https://docs.aws.amazon.com/cdk/latest/guide/hello_world.html#hello_world_tutorial_create_app) and used in the cdk [example code](https://github.com/aws-samples/aws-cdk-examples/tree/master/python). ``` --- Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp