From 657ce08ac85b49711464accebc07b230619d9f8a Mon Sep 17 00:00:00 2001 From: karlicoss Date: Fri, 10 Nov 2023 22:28:28 +0000 Subject: [PATCH] fix mypy issues after mypy/libraries updates --- my/core/_deprecated/kompress.py | 8 ++++---- my/core/cachew.py | 2 +- my/core/preinit.py | 2 +- my/core/query.py | 2 +- my/core/query_range.py | 2 +- my/instagram/common.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/my/core/_deprecated/kompress.py b/my/core/_deprecated/kompress.py index cd1bd9d..25b8a20 100644 --- a/my/core/_deprecated/kompress.py +++ b/my/core/_deprecated/kompress.py @@ -162,7 +162,7 @@ class ZipPath(zipfile_Path): # NOTE: is_dir/is_file might not behave as expected, the base class checks it only based on the slash in path # seems that root/at are not exposed in the docs, so might be an implementation detail - root: zipfile.ZipFile + root: zipfile.ZipFile # type: ignore[assignment] at: str @property @@ -191,14 +191,14 @@ class ZipPath(zipfile_Path): # note: seems that zip always uses forward slash, regardless OS? return zipfile_Path(self.root, self.at + '/') - def rglob(self, glob: str) -> Sequence[ZipPath]: + def rglob(self, glob: str) -> Iterator[ZipPath]: # note: not 100% sure about the correctness, but seem fine? # Path.match() matches from the right, so need to rpaths = [p for p in self.root.namelist() if p.startswith(self.at)] rpaths = [p for p in rpaths if Path(p).match(glob)] - return [ZipPath(self.root, p) for p in rpaths] + return (ZipPath(self.root, p) for p in rpaths) - def relative_to(self, other: ZipPath) -> Path: + def relative_to(self, other: ZipPath) -> Path: # type: ignore[override, unused-ignore] assert self.filepath == other.filepath, (self.filepath, other.filepath) return self.subpath.relative_to(other.subpath) diff --git a/my/core/cachew.py b/my/core/cachew.py index 7dd62d2..cc5a95b 100644 --- a/my/core/cachew.py +++ b/my/core/cachew.py @@ -7,7 +7,7 @@ import sys from typing import Optional, Iterator, cast, TYPE_CHECKING, TypeVar, Callable, overload, Union, Any, Type import warnings -import appdirs +import appdirs # type: ignore[import-untyped] PathIsh = Union[str, Path] # avoid circular import from .common diff --git a/my/core/preinit.py b/my/core/preinit.py index 88bcb27..8c0f6a4 100644 --- a/my/core/preinit.py +++ b/my/core/preinit.py @@ -4,7 +4,7 @@ from pathlib import Path # - it's imported from my.core.init (so we wan't to keep this file as small/reliable as possible, hence not common or something) # - we still need this function in __main__, so has to be separate from my/core/init.py def get_mycfg_dir() -> Path: - import appdirs + import appdirs # type: ignore[import-untyped] import os # not sure if that's necessary, i.e. could rely on PYTHONPATH instead # on the other hand, by using MY_CONFIG we are guaranteed to load it from the desired path? diff --git a/my/core/query.py b/my/core/query.py index 4e00569..7c22838 100644 --- a/my/core/query.py +++ b/my/core/query.py @@ -178,7 +178,7 @@ pass 'drop_exceptions' to ignore exceptions""") return lambda o: o.get(key, default) # type: ignore[union-attr] else: if hasattr(obj, key): - return lambda o: getattr(o, key, default) # type: ignore[arg-type] + return lambda o: getattr(o, key, default) # Note: if the attribute you're ordering by is an Optional type, # and on some objects it'll return None, the getattr(o, field_name, default) won't diff --git a/my/core/query_range.py b/my/core/query_range.py index a1cfaed..afde933 100644 --- a/my/core/query_range.py +++ b/my/core/query_range.py @@ -327,7 +327,7 @@ def select_range( # we should search for on each value in the iterator if order_value is None and order_by_value_type is not None: # search for that type on the iterator object - order_value = lambda o: isinstance(o, order_by_value_type) # type: ignore + order_value = lambda o: isinstance(o, order_by_value_type) # if the user supplied a order_key, and/or we've generated an order_value, create # the function that accesses that type on each value in the iterator diff --git a/my/instagram/common.py b/my/instagram/common.py index 36c6b83..4df07a1 100644 --- a/my/instagram/common.py +++ b/my/instagram/common.py @@ -68,6 +68,6 @@ def _merge_messages(*sources: Iterator[Res[Message]]) -> Iterator[Res[Message]]: if user is not None: repls['user'] = user if len(repls) > 0: - m = replace(m, **repls) # type: ignore[type-var, misc] # ugh mypy is confused because of Protocol? + m = replace(m, **repls) # type: ignore[type-var] # ugh mypy is confused because of Protocol? mmap[k] = m yield m