Skip to content

Commit

Permalink
Minor fixes after updating to mypy 1.11.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Jul 21, 2024
1 parent 6df7892 commit 42a8e9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/reader/_storage/_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_entries(
self.paginated_query,
partial(get_entries_query, filter, sort),
row_factory=entry_factory,
) # type: ignore[var-annotated]
)
if sort != 'random':
last = self.get_entry_last(sort, starting_after) if starting_after else None
return paginated_query(limit, last)
Expand Down
4 changes: 2 additions & 2 deletions src/reader/_storage/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def make_query() -> tuple[Query, dict[str, Any]]:
def pq(
limit: int | None, last: tuple[Any, ...] | None = None
) -> Iterable[EntrySearchResult]:
with wrap_exceptions(ENABLED_EXC | QUERY_EXC):
with wrap_exceptions(ENABLED_EXC | QUERY_EXC): # type: ignore[operator]
yield from paginated_query(
self.get_db(),
make_query,
Expand Down Expand Up @@ -455,7 +455,7 @@ def search_entry_last(self, query: str, entry: tuple[str, str]) -> tuple[Any, ..
lambda: EntryNotFoundError(feed_url, entry_id),
)

@wrap_exceptions(ENABLED_EXC | QUERY_EXC)
@wrap_exceptions(ENABLED_EXC | QUERY_EXC) # type: ignore[operator]
def search_entry_counts(
self,
query: str,
Expand Down
3 changes: 2 additions & 1 deletion src/reader/_storage/_sqlite_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import weakref
from collections.abc import Callable
from collections.abc import Iterator
from collections.abc import Mapping
from collections.abc import Sequence
from contextlib import closing
from contextlib import contextmanager
Expand Down Expand Up @@ -85,7 +86,7 @@ def ddl_transaction(db: sqlite3.Connection) -> Iterator[sqlite3.Connection]:
@contextmanager
def wrap_exceptions(
exc_type: Callable[[str], Exception],
op_exc_types: dict[str, Callable[[str], Exception]] = {}, # noqa: B006
op_exc_types: Mapping[str, Callable[[str], Exception]] = {}, # noqa: B006
message: str = "unexpected error",
) -> Iterator[None]:
"""Wrap sqlite3 exceptions in a custom exception.
Expand Down
4 changes: 3 additions & 1 deletion src/reader/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ def get_count() -> int:
MapFunction = Callable[[Callable[[_T], _U], Iterable[_T]], Iterator[_U]]
MapContextManager = AbstractContextManager[MapFunction[_T, _U]]

# type ignore because of https://github.com/python/mypy/issues/17551

@contextmanager

@contextmanager # type: ignore[arg-type]
def make_pool_map(workers: int) -> Iterator[MapFunction[_T, _U]]:
# We are using concurrent.futures instead of multiprocessing.dummy
# because the latter doesn't work on some environments (e.g. AWS Lambda).
Expand Down

0 comments on commit 42a8e9f

Please sign in to comment.