Skip to content

Commit

Permalink
fix mypy namespace package issue (#560)
Browse files Browse the repository at this point in the history
* fix #556
mypy patcher complaints on namespace packages

* update pipeline
exclude mock package data from reqs
  • Loading branch information
beliaev-maksim authored Jun 28, 2022
1 parent 72c67ba commit c15aa4e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
run: |
mypy --config-file=./mypy.ini -p responses
- name: Run mypy (namespace packages)
run: |
# see https://github.com/getsentry/responses/issues/556
mypy --config-file=./mypy.ini --namespace-packages -p responses
tests:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.22.0
------

* Fix type for the `mock`'s patcher object. See #556
* Add `passthrough` argument to `BaseResponse` object. See #557
* Fix `registries` leak. See #563

Expand Down
5 changes: 3 additions & 2 deletions responses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@

if TYPE_CHECKING: # pragma: no cover
# import only for linter run
from mypy.typeshed.stdlib.unittest.mock import _patcher as _mock_patcher
from unittest.mock import _patch as _mock_patcher

from requests import PreparedRequest
from requests import models
from urllib3 import Retry as _Retry
Expand Down Expand Up @@ -655,7 +656,7 @@ def __init__(
self.response_callback: Optional[Callable[[Any], Response]] = response_callback
self.passthru_prefixes: Tuple[_URLPatternType, ...] = tuple(passthru_prefixes)
self.target: str = target
self._patcher: Optional["_mock_patcher"] = None
self._patcher: Optional["_mock_patcher[Any]"] = None
self._thread_lock = _ThreadingLock()

def get_registry(self) -> FirstMatchRegistry:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"pytest-asyncio",
"pytest-localserver",
"flake8",
"types-mock",
"types-requests",
"mypy",
]
Expand Down

0 comments on commit c15aa4e

Please sign in to comment.