Skip to content

Type checking calls[] is insufficient #610

@evilensky

Description

@evilensky

Describe the bug

this bit of code

import requests
import responses

def get_something():
    return requests.get('http://example.com')


def test_get_something():
    with responses.RequestsMock() as rsps:
        rsps.add(responses.GET, 'http://example.com', body='foo')
        foo = get_something()
        assert rsps.calls[0].request.url == 'http://example.com/'

results in a type checking failure in mypy and pyright. The Pyright message is:

Cannot access member "request" for type "List[Call]"
  Member "request" is unknown

Additional context

No response

Version of responses

0.22.0

Steps to Reproduce

Example in bug description.

Expected Result

The example code should pass type checking. Members of List[Call] should have their attributes properly annotated.

Actual Result

Cannot access member "request" for type "List[Call]"   Member "request" is unknown

Metadata

Metadata

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions