← All tasks
pythongetsentry/responses #377Not a task: already works

Incorrect stub packaging in latest responses release.

envgap__getsentry__responses-377

01 / FAILURE SIGNATURE

As reported upstream

.../responses_bug.py:3: error: Call to untyped function (unknown) in typed context
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
2bcfaf3333b1bd80d525c41e2593784eeb73dbc8
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

getsentry/responses #377 · read the original issue
Stubs introduced in recent `responses` release are causing Spurious mypy failures.



### Steps to Reproduce



Given the following file:



```py

# ~/sandbox/responses_bug.py

import responses



responses.add(

    responses.Response(

        method='GET',

        url='http://example.com',

    )

)

```



1. Set up a clean virtual environment (`conda create -n responses-bug python=3.8 pip; conda activate responses-bug; pip install mypy responses`

2. `mypy --ignore-missing-imports --strict ~/sandbox/responses_bug.py`



### Expected Result



I expected mypy to exit successfully with no errors.



### Actual Result



```

.../responses_bug.py:3: error: Call to untyped function (unknown) in typed context

.../responses_bug.py:4: error: Call to untyped function "Response" in typed context

```



According to mypy's `reveal_type`, the revealed_type of `add` is:



```

.../responses_bug.py:3: note: Revealed type is 'def (method: Any =, url: Any =, body: Any =, adding_headers: Any =, *args: Any, **kwargs: Any) -> Any'

```



From what I can tell, mypy is looking at the code, not at the stubs.  Looking in my site-packages confirms that the `__init__.pyi` was not included in the distribution (but `py.typed` _was_ -- which means that `mypy` is looking at the responses _code_, not the responses stubs).  I believe that the fix here is to just update `setup.py` to also include `__init__.pyi` as `package_data` along-side `py.typed`.

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]