getsentry / getsentry/responses

A little typing issue?

Open
#722 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
4.3k
Forks
378
Avg merge
4d 1h
Merged PRs (30d)
1

Description

### Describe the bug

Hello,

I think the definition here:

https://github.com/getsentry/responses/blob/f7a7945991efc7cb8133b9d6ec75761b459fe75c/responses/__init__.py#L237

could be:

```python
class CallList(Sequence[Call], Sized):
```

I'm using the latest Pyright static type checker in strict mode and it gives me the error below:

```
error: Return type, "Generator[filter[Unknown], Any, None]", is partially unknown (reportUnknownParameterType)
```

for the code in Steps to Reproduce.

### Additional context

See the discussion here: https://github.com/microsoft/pyright/discussions/8164

### Version of `responses`

0.25.3

### Steps to Reproduce

```python
import pytest
import responses

@pytest.fixture
def req_mock():
with responses.RequestsMock() as mock:
yield mock

@pytest.fixture
def foo_request(req_mock: responses.RequestsMock):
req_mock.add(responses.GET, url="https://foo.example.com/123")
yield filter(
lambda r: r.request.url.startswith("https://foo.example.com"), req_mock.calls
)
```

### Expected Result

Function `foo_request` returns `Generator[filter[Call], Any, None]`.

### Actual Result

Function `foo_request` returns `Generator[filter[Unknown], Any, None]`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.