fix mypy issues after mypy/libraries updates
This commit is contained in:
parent
996169aa29
commit
657ce08ac8
6 changed files with 9 additions and 9 deletions
|
@ -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
|
# 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
|
# 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
|
at: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -191,14 +191,14 @@ class ZipPath(zipfile_Path):
|
||||||
# note: seems that zip always uses forward slash, regardless OS?
|
# note: seems that zip always uses forward slash, regardless OS?
|
||||||
return zipfile_Path(self.root, self.at + '/')
|
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?
|
# note: not 100% sure about the correctness, but seem fine?
|
||||||
# Path.match() matches from the right, so need to
|
# 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 self.root.namelist() if p.startswith(self.at)]
|
||||||
rpaths = [p for p in rpaths if Path(p).match(glob)]
|
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)
|
assert self.filepath == other.filepath, (self.filepath, other.filepath)
|
||||||
return self.subpath.relative_to(other.subpath)
|
return self.subpath.relative_to(other.subpath)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import sys
|
||||||
from typing import Optional, Iterator, cast, TYPE_CHECKING, TypeVar, Callable, overload, Union, Any, Type
|
from typing import Optional, Iterator, cast, TYPE_CHECKING, TypeVar, Callable, overload, Union, Any, Type
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import appdirs
|
import appdirs # type: ignore[import-untyped]
|
||||||
|
|
||||||
PathIsh = Union[str, Path] # avoid circular import from .common
|
PathIsh = Union[str, Path] # avoid circular import from .common
|
||||||
|
|
||||||
|
|
|
@ -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)
|
# - 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
|
# - we still need this function in __main__, so has to be separate from my/core/init.py
|
||||||
def get_mycfg_dir() -> Path:
|
def get_mycfg_dir() -> Path:
|
||||||
import appdirs
|
import appdirs # type: ignore[import-untyped]
|
||||||
import os
|
import os
|
||||||
# not sure if that's necessary, i.e. could rely on PYTHONPATH instead
|
# 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?
|
# on the other hand, by using MY_CONFIG we are guaranteed to load it from the desired path?
|
||||||
|
|
|
@ -178,7 +178,7 @@ pass 'drop_exceptions' to ignore exceptions""")
|
||||||
return lambda o: o.get(key, default) # type: ignore[union-attr]
|
return lambda o: o.get(key, default) # type: ignore[union-attr]
|
||||||
else:
|
else:
|
||||||
if hasattr(obj, key):
|
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,
|
# 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
|
# and on some objects it'll return None, the getattr(o, field_name, default) won't
|
||||||
|
|
|
@ -327,7 +327,7 @@ def select_range(
|
||||||
# we should search for on each value in the iterator
|
# we should search for on each value in the iterator
|
||||||
if order_value is None and order_by_value_type is not None:
|
if order_value is None and order_by_value_type is not None:
|
||||||
# search for that type on the iterator object
|
# 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
|
# 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
|
# the function that accesses that type on each value in the iterator
|
||||||
|
|
|
@ -68,6 +68,6 @@ def _merge_messages(*sources: Iterator[Res[Message]]) -> Iterator[Res[Message]]:
|
||||||
if user is not None:
|
if user is not None:
|
||||||
repls['user'] = user
|
repls['user'] = user
|
||||||
if len(repls) > 0:
|
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
|
mmap[k] = m
|
||||||
yield m
|
yield m
|
||||||
|
|
Loading…
Add table
Reference in a new issue