Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ def package_sort_key(package: str) -> tuple[int, str]:
def config_make_list_parser(
*,
delimiter: Optional[str] = None,
parse: Callable[[str], T] = str, # type: ignore # see mypy#3737
parse: Callable[[str], T] = str, # type: ignore # needed by mypy, see mypy#3737
unescape: bool = False,
reset: bool = True,
key: Optional[Callable[[T], Any]] = None,
Expand Down Expand Up @@ -1722,7 +1722,7 @@ def removeprefix(self, setting: str) -> str:
class ConfigSetting(Generic[T]):
dest: str
section: str
parse: ConfigParseCallback[T] = config_parse_string # type: ignore # see mypy#3737
parse: ConfigParseCallback[T] = config_parse_string # type: ignore # needed by mypy, see mypy#3737
match: Optional[ConfigMatchCallback[T]] = None
name: str = ""
default: Optional[T] = None
Expand Down Expand Up @@ -1903,6 +1903,7 @@ def to_dict(self) -> dict[str, Any]:
def from_json(cls, s: Union[str, dict[str, Any], SupportsRead[str], SupportsRead[bytes]]) -> "Args":
"""Instantiate a Args object from a (partial) JSON dump."""

j: dict[str, Any]
if isinstance(s, str):
j = json.loads(s)
elif isinstance(s, dict):
Expand Down Expand Up @@ -2477,6 +2478,8 @@ def from_partial_json(
s: Union[str, dict[str, Any], SupportsRead[str], SupportsRead[bytes]],
) -> dict[str, Any]:
"""Instantiate a Config object from a (partial) JSON dump."""

j: dict[str, Any]
if isinstance(s, str):
j = json.loads(s)
elif isinstance(s, dict):
Expand Down Expand Up @@ -4608,7 +4611,7 @@ def create_argument_parser(chdir: bool = True) -> argparse.ArgumentParser:
last_section = s.section

if s.short and s.const is not None:
group.add_argument( # type: ignore
group.add_argument( # type: ignore # needed by pyright
s.short,
metavar="",
dest=s.dest,
Expand All @@ -4621,7 +4624,7 @@ def create_argument_parser(chdir: bool = True) -> argparse.ArgumentParser:
for long in [s.long, *s.compat_longs]:
opts = [s.short, long] if s.short and long == s.long and s.const is None else [long]

group.add_argument( # type: ignore
group.add_argument( # type: ignore # needed by pyright
*opts,
dest=s.dest,
choices=s.choices,
Expand Down Expand Up @@ -4820,13 +4823,13 @@ def finalize_value(self, setting: ConfigSetting[T]) -> Optional[T]:
# so we ignore the return-value error for it.
if isinstance(v, list):
assert isinstance(cfg_value, type(v))
return cfg_value + v # type: ignore[return-value]
return cfg_value + v # type: ignore[return-value] # needed by mypy
elif isinstance(v, dict):
assert isinstance(cfg_value, type(v))
return cfg_value | v # type: ignore[return-value]
return cfg_value | v # type: ignore[return-value] # needed by mypy
elif isinstance(v, set):
assert isinstance(cfg_value, type(v))
return cfg_value | v # type: ignore[return-value]
return cfg_value | v # type: ignore[return-value] # needed by mypy
else:
return v

Expand Down Expand Up @@ -5950,7 +5953,7 @@ def optional_enum_transformer(enumval: Optional[str], fieldtype: type[Optional[E
return typing.get_args(fieldtype)[0](enumval) if enumval is not None else None

def enum_list_transformer(enumlist: list[str], fieldtype: type[list[E]]) -> list[E]:
enumtype = fieldtype.__args__[0] # type: ignore
enumtype = typing.get_args(fieldtype)[0]
return [enumtype(e) for e in enumlist]

def config_drive_transformer(drives: list[dict[str, Any]], fieldtype: type[Drive]) -> list[Drive]:
Expand Down
6 changes: 3 additions & 3 deletions mkosi/resources/man/mkosi.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2931,15 +2931,15 @@ re-building of images. Specifically:
and caches distribution packages (RPM, deb, …) after they are downloaded,
but before they are unpacked.

2. The repository metadata of the distribution is cached if a cache
1. The repository metadata of the distribution is cached if a cache
directory is configured with `CacheDirectory=` or the `mkosi.cache/`
directory. When the repository metadata is resynced is controlled with
the `CacheOnly=` option, which by default will always resync the repository
metadata unless every image is cached (see the `Incremental=` option).
Whenever the repository metadata is resynced, all cached images are
invalidated.

2. If the incremental build mode is enabled with `Incremental=yes`, cached
1. If the incremental build mode is enabled with `Incremental=yes`, cached
copies of the final image and build overlay are made immediately
before the build sources are copied in (for the build overlay) or the
artifacts generated by `mkosi.build` are copied in (in case of the
Expand All @@ -2948,7 +2948,7 @@ re-building of images. Specifically:
effective if the list of packages to use remains stable, but the build
sources and its scripts change regularly.

3. Finally, between multiple builds the build artifact directory may
1. Finally, between multiple builds the build artifact directory may
be shared, using the `BuildDirectory=` option or the `mkosi.builddir/`
directory. This directory allows build systems such as Meson to reuse
already compiled sources from a previous build, thus speeding up the build
Expand Down
2 changes: 1 addition & 1 deletion mkosi/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def excepthook(frames: Sequence[FrameType]) -> None:
# inaccessible. Temporarily disable it to preserve our primed linecache entries for which we might not
# be able to access the files anymore (because we're sandboxed).
checkcache = linecache.checkcache
linecache.checkcache = lambda filename=None: None # type: ignore[assignment]
linecache.checkcache = lambda filename=None: None
try:
sys.excepthook(exctype, exc, tb)
finally:
Expand Down
Loading