Skip to content

Commit

Permalink
antlir: remove unused imports (python only)
Browse files Browse the repository at this point in the history
Summary:
antlir is pretty well-behaved (for python anyway) and should not have any
import-time side effects. Either way, test cases should catch any of these.
There are probably cases that there are unused buck dependencies, but this is a
step.

Reviewed By: snarkmaster

Differential Revision: D29468756

fbshipit-source-id: 615b92073253ed9eee2e6270f78f7ecc16a2bc34
  • Loading branch information
vmagro authored and facebook-github-bot committed Jun 30, 2021
1 parent 0a5a4e1 commit 962d503
Show file tree
Hide file tree
Showing 20 changed files with 7 additions and 37 deletions.
2 changes: 0 additions & 2 deletions antlir/btrfs_diff/coroutine_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class GeneratorExitWithResult(Exception):
your coroutine will automatically return None.
"""

pass


@contextmanager
def while_not_exited(coroutine) -> Iterator[CoroutineContext]:
Expand Down
2 changes: 1 addition & 1 deletion antlir/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from antlir.compiler.items.phases_provide import PhasesProvideItem
from antlir.compiler.items_for_features import gen_items_for_features
from antlir.find_built_subvol import find_built_subvol
from antlir.fs_utils import META_FLAVOR_FILE, Path
from antlir.fs_utils import Path
from antlir.rpm.yum_dnf_conf import YumDnf
from antlir.subvol_utils import Subvol

Expand Down
2 changes: 0 additions & 2 deletions antlir/compiler/items/tests/group_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from antlir.find_built_subvol import find_built_subvol
from antlir.fs_utils import Path
from antlir.subvol_utils import TempSubvolumes, with_temp_subvols
from antlir.tests.layer_resource import layer_resource_subvol

Expand Down
1 change: 0 additions & 1 deletion antlir/compiler/items/tests/test_ensure_dirs_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import subprocess
import sys
from itertools import zip_longest

Expand Down
1 change: 0 additions & 1 deletion antlir/compiler/items/tests/user_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from antlir.fs_utils import Path
from antlir.subvol_utils import TempSubvolumes
from antlir.tests.layer_resource import layer_resource_subvol

Expand Down
2 changes: 0 additions & 2 deletions antlir/compiler/tests/test_add_remove_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import os
import subprocess
import tempfile
import unittest

Expand Down
3 changes: 1 addition & 2 deletions antlir/compiler/tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# LICENSE file in the root directory of this source tree.

import io
import itertools
import json
import os
import subprocess
Expand All @@ -15,7 +14,7 @@
import unittest.mock
from contextlib import contextmanager

from antlir import fs_utils, subvol_utils
from antlir import subvol_utils
from antlir.compiler.items import (
ensure_dirs_exist,
rpm_action,
Expand Down
2 changes: 0 additions & 2 deletions antlir/compiler/tests/test_image_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import os
import unittest
from contextlib import contextmanager
from grp import getgrnam
from pwd import getpwnam

from antlir.artifacts_dir import find_repo_root
from antlir.btrfs_diff.tests.demo_sendstreams_expected import (
Expand Down
3 changes: 0 additions & 3 deletions antlir/nspawn_in_subvol/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
Converts structures from `args.py` into a `systemd-nspawn` command-line.
"""
import base64
import importlib.resources
import json
import os
import re
import subprocess
import uuid
from contextlib import contextmanager, nullcontext
from dataclasses import dataclass
from typing import AnyStr, Iterable, List, Mapping, NamedTuple, Optional, Tuple

from antlir.compiler import procfs_serde
Expand Down
2 changes: 1 addition & 1 deletion antlir/nspawn_in_subvol/plugin_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import functools
import subprocess
from contextlib import contextmanager
from typing import Callable, ContextManager, Iterable, Tuple, Union
from typing import Callable, ContextManager, Iterable, Tuple

from antlir.subvol_utils import Subvol

Expand Down
2 changes: 1 addition & 1 deletion antlir/nspawn_in_subvol/plugins/attach_antlir_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from contextlib import contextmanager

from antlir.fs_utils import ANTLIR_DIR, CP_CLONE_CMD
from antlir.nspawn_in_subvol.args import PopenArgs, _NspawnOpts
from antlir.nspawn_in_subvol.args import _NspawnOpts
from antlir.nspawn_in_subvol.plugin_hooks import (
_NspawnSetup,
_NspawnSetupCtxMgr,
Expand Down
1 change: 0 additions & 1 deletion antlir/rpm/allowed_versions/package_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(self):

async def snapshot(self, snapshot_dir: Path):
'"manual" package groups do not need to snapshot anything'
pass

@contextmanager
def load_config_fn(
Expand Down
1 change: 0 additions & 1 deletion antlir/rpm/allowed_versions/version_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def __init__(self):

async def snapshot(self, snapshot_dir: Path):
'"manual" version policies do not need to snapshot anything'
pass

@contextmanager
def load_config_fn(
Expand Down
1 change: 0 additions & 1 deletion antlir/rpm/replay/tests/test_fake_pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import subprocess
import unittest

from antlir.fs_utils import Path
from antlir.rpm.replay.fake_pty_wrapper import fake_pty_cmd, fake_pty_resource


Expand Down
1 change: 0 additions & 1 deletion antlir/rpm/tests/test_yum_dnf_from_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import subprocess
import tempfile
import unittest
import uuid
from contextlib import contextmanager
Expand Down
1 change: 0 additions & 1 deletion antlir/rpm/write_yum_dnf_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
into a directory.
"""
import argparse
import gzip
import os
import textwrap
from typing import Iterable, List, TextIO
Expand Down
3 changes: 1 addition & 2 deletions antlir/tests/test_package_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import subprocess
import tempfile
from contextlib import contextmanager
from typing import Iterator, Optional
from typing import Iterator

from antlir.btrfs_diff.tests.demo_sendstreams_expected import (
render_demo_as_corrupted_by_gnu_tar,
Expand All @@ -19,7 +19,6 @@
from antlir.nspawn_in_subvol.args import PopenArgs, new_nspawn_opts
from antlir.nspawn_in_subvol.nspawn import run_nspawn
from antlir.subvol_utils import with_temp_subvols, get_subvolumes_dir, MiB
from antlir.tests.flavor_helpers import render_flavor
from antlir.tests.image_package_testbase import ImagePackageTestCaseBase
from antlir.tests.layer_resource import layer_resource, layer_resource_subvol

Expand Down
5 changes: 1 addition & 4 deletions antlir/vm/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from abc import ABC, abstractmethod
from contextlib import contextmanager
from dataclasses import dataclass, field
from typing import ContextManager, Iterable, Optional, Tuple, Union
from typing import ContextManager, Iterable, Optional, Tuple

from antlir.fs_utils import Path

Expand Down Expand Up @@ -39,19 +39,16 @@ class Share(ABC):
@abstractmethod
def generator(self) -> bool: # pragma: no cover
"""Should this share have a systemd mount unit generated for it"""
pass

@property
@abstractmethod
def mount_unit(self) -> Tuple[str, str]: # pragma: no cover
"""Return the name of the mount unit file, and its contents"""
pass

@property
@abstractmethod
def qemu_args(self) -> Iterable[str]: # pragma: no cover
"""QEMU cmdline args to attach this share"""
pass

@staticmethod
def _systemd_escape_mount(path: str) -> str:
Expand Down
1 change: 0 additions & 1 deletion antlir/vm/tests/test_kernel_panic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import unittest

from antlir.fs_utils import Path
from antlir.nspawn_in_subvol.common import DEFAULT_PATH_ENV


class KernelPanicTest(unittest.TestCase):
Expand Down
8 changes: 1 addition & 7 deletions antlir/vm/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

import argparse
import asyncio
import importlib.resources
import os
import shlex
import socket
import subprocess
import sys
import tempfile
import time
import uuid
from contextlib import AsyncExitStack, asynccontextmanager, contextmanager
from contextlib import AsyncExitStack, asynccontextmanager
from enum import Enum
from itertools import chain
from typing import (
Expand All @@ -34,7 +31,6 @@
from antlir.find_built_subvol import find_built_subvol
from antlir.fs_utils import Path
from antlir.shape import Shape
from antlir.tests.layer_resource import layer_resource_subvol
from antlir.unshare import Namespace, Unshare
from antlir.vm.guest_ssh import GuestSSHConnection
from antlir.vm.share import BtrfsDisk, Plan9Export, Share
Expand All @@ -48,8 +44,6 @@
class VMBootError(Exception):
"""The VM failed to boot"""

pass


def _wait_for_boot(sockfile: Path, timeout_ms: int = 300 * 1000) -> int:
"""
Expand Down

0 comments on commit 962d503

Please sign in to comment.