diff --git a/mkosi/config.py b/mkosi/config.py index f10f64d213..ed0f9d25cd 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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, @@ -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 @@ -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): @@ -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): @@ -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, @@ -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, @@ -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 @@ -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]: diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 93b1ab9c9a..bdaa7c3edd 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -2931,7 +2931,7 @@ 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 @@ -2939,7 +2939,7 @@ re-building of images. Specifically: 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 @@ -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 diff --git a/mkosi/run.py b/mkosi/run.py index 6a1f664f76..786b0ad10e 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -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: