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
7 changes: 1 addition & 6 deletions kiwi/bootloader/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
import sys
from typing import TYPE_CHECKING, Dict, Union, overload
from typing import TYPE_CHECKING, Dict, Literal, Union, overload

if sys.version_info >= (3, 8):
from typing import Literal # pragma: no cover
else: # pragma: no cover
from typing_extensions import Literal # pragma: no cover

from kiwi.exceptions import (
KiwiBootLoaderConfigSetupError
Expand Down
9 changes: 1 addition & 8 deletions kiwi/builder/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
#
from contextlib import ExitStack
import os
import sys
import logging
from typing import (
Dict, List, Optional, Tuple, Union
)
if sys.version_info >= (3, 8):
from typing import TypedDict # pragma: no cover
else: # pragma: no cover
from typing_extensions import TypedDict # pragma: no cover
from typing import Dict, List, Optional, Tuple, TypedDict, Union

# project
import kiwi.defaults as defaults
Expand Down
8 changes: 1 addition & 7 deletions kiwi/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
from typing import IO, Callable, List, MutableMapping, NamedTuple, Optional, overload
from typing import IO, Callable, Literal, List, MutableMapping, NamedTuple, Optional, overload
import logging
import os
import select
import subprocess
import sys

if sys.version_info >= (3, 8):
from typing import Literal # pragma: no cover
else: # pragma: no cover
from typing_extensions import Literal # pragma: no cover

# project
from kiwi.utils.codec import Codec
Expand Down
7 changes: 1 addition & 6 deletions kiwi/container/oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
#
import os
import logging
import sys
from typing import Dict, List, Optional
if sys.version_info >= (3, 8):
from typing import TypedDict # pragma: no cover
else: # pragma: no cover
from typing_extensions import TypedDict # pragma: no cover
from typing import Dict, List, Optional, TypedDict

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to remove use of typing_extensions can you do it also at the other places:

  • bootloader/config/init.py
  • builder/disk.py
  • command.py

Thanks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


# project
from kiwi.utils.compress import Compress
Expand Down
6 changes: 1 addition & 5 deletions kiwi/system/root_import/oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ def _get_image_urls(self) -> List[str]:
uncompressed_image = compressor.uncompressed_filename
else:
uncompressed_image = image_file
image_urls.append(
'{0}:{1}'.format(
self.archive_transport, uncompressed_image
)
)
image_urls.append(f"{self.archive_transport}:{uncompressed_image}")
return image_urls
else:
log.warning('Bypassing base image URI to OCI tools')
Expand Down
24 changes: 24 additions & 0 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest


@pytest.fixture(autouse=True)
def dont_use_kiwi_yml_from_host(
request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch
) -> None:
"""kiwi will by default read runtime config files, which influence which
utilities get chosen. The users config file leaks into the test environment,
which is undesirable as certain tests assume that the default tool is XYZ
and assert that. This fixture prevents the loading of the runtime config
files by setting all paths to falsy values that hence are ignored.

This behavior can be turned off by adding the ``no_kiwi_yml_mock`` marker.

"""
if request.node.get_closest_marker("no_kiwi_yml_mock"):
return

monkeypatch.setattr("kiwi.defaults.ETC_RUNTIME_CONFIG_DIR", "")
monkeypatch.setattr("kiwi.defaults.ETC_RUNTIME_CONFIG_FILE", "")
monkeypatch.setattr("kiwi.defaults.USR_RUNTIME_CONFIG_DIR", "")
monkeypatch.setattr("kiwi.defaults.USR_RUNTIME_CONFIG_FILE", "")
monkeypatch.setattr("kiwi.defaults.CUSTOM_RUNTIME_CONFIG_FILE", None)
3 changes: 3 additions & 0 deletions test/unit/runtime_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pytest import (
raises, fixture
)
import pytest

from kiwi.runtime_config import RuntimeConfig
from kiwi.defaults import Defaults
Expand Down Expand Up @@ -50,6 +51,7 @@ def test_reading_custom_config_file(self, mock_yaml):
]
)

@pytest.mark.no_kiwi_yml_mock
@patch('os.path.exists')
@patch('yaml.safe_load')
@patch('os.path.isdir')
Expand Down Expand Up @@ -82,6 +84,7 @@ def os_path_isdir(config):
call('/etc/kiwi.yml.d/some.yml', 'r')
]

@pytest.mark.no_kiwi_yml_mock
@patch('os.path.exists')
@patch('yaml.safe_load')
@patch('os.path.isdir')
Expand Down
Loading