Skip to content

Commit

Permalink
Apply formatting from upgraded formatter version
Browse files Browse the repository at this point in the history
  • Loading branch information
pdietl committed Sep 19, 2022
1 parent 0fb04bf commit 03db7a9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
11 changes: 9 additions & 2 deletions test/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,16 @@ def test_config_flag(description, config, transient_args, qemu_args, expected):
create_test_create_config(
{"image": "example-image", "qemu_args": ["-smp", "2"]}
),
create_test_start_config({"qemu_args": ["-m", "1G"],}),
create_test_start_config(
{
"qemu_args": ["-m", "1G"],
}
),
create_test_run_config(
{"image": "example-image", "qemu_args": ["-smp", "2", "-m", "1G"],}
{
"image": "example-image",
"qemu_args": ["-smp", "2", "-m", "1G"],
}
),
),
(
Expand Down
3 changes: 2 additions & 1 deletion test/unit/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@


@pytest.mark.parametrize(
("test_input", "expected"), STORAGE_ENCODE_TESTS,
("test_input", "expected"),
STORAGE_ENCODE_TESTS,
)
def test_storage_safe_encode(test_input, expected):
assert s.storage_safe_encode(test_input) == expected
Expand Down
10 changes: 4 additions & 6 deletions transient/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class ConfigFileParsingError(Exception):
"""Raised when a parsing error is encountered while loading the
configuration file
configuration file
"""

inner: toml.TomlDecodeError
Expand All @@ -35,7 +35,7 @@ def __str__(self) -> str:

class ConfigFileOptionError(Exception):
"""Raised when an invalid configuration option value is encountered in the
configuration file
configuration file
"""

inner: ValidationError
Expand All @@ -46,8 +46,7 @@ def __init__(self, error: ValidationError, path: str) -> None:
self.path = path

def _line_number_of_option_in_config_file(self, option: str) -> Optional[int]:
"""Returns the line number where the option is found in the config file
"""
"""Returns the line number where the option is found in the config file"""
with open(self.path) as config_file:
for line_number, line in enumerate(config_file, start=1):
if option in line:
Expand All @@ -69,8 +68,7 @@ def __str__(self) -> str:


class CLIArgumentError(Exception):
"""Raised when an invalid command line argument is encountered
"""
"""Raised when an invalid command line argument is encountered"""

inner: ValidationError

Expand Down
14 changes: 7 additions & 7 deletions transient/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def find_transient_instances(
) -> List[TransientInstance]:
"""Find running transient instances matching the given parameters
If 'name' is specified, only instances started with a equivalent 'name'
argument will be returned. 'with_ssh' will filter for instances that
were started with '--ssh' (or other options that imply '--ssh'). If the
'timeout' option is passed, this function will block until at least one
instance matching the provided parameters is found, or a timeout occurs.
If 'vmstore' is passed, only VMs backed by the given store are considered.
Note that 'timeout' may not be passed by itself.
If 'name' is specified, only instances started with a equivalent 'name'
argument will be returned. 'with_ssh' will filter for instances that
were started with '--ssh' (or other options that imply '--ssh'). If the
'timeout' option is passed, this function will block until at least one
instance matching the provided parameters is found, or a timeout occurs.
If 'vmstore' is passed, only VMs backed by the given store are considered.
Note that 'timeout' may not be passed by itself.
"""
if name is None and with_ssh is False and timeout is not None:
raise RuntimeError(
Expand Down
4 changes: 2 additions & 2 deletions transient/transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __is_stateless(self) -> bool:

def __needs_to_copy_in_files_before_running(self) -> bool:
"""Checks if at least one file or directory on the host needs to be copied into the VM
before starting the VM
before starting the VM
"""
return len(self.config.copy_in_before) > 0

Expand Down Expand Up @@ -126,7 +126,7 @@ def __copy_in(self, path_mapping: str) -> None:

def __needs_to_copy_out_files_after_running(self) -> bool:
"""Checks if at least one directory on the VM needs to be copied out
to the host after stopping the VM
to the host after stopping the VM
"""
return len(self.config.copy_out_after) > 0

Expand Down
17 changes: 12 additions & 5 deletions transient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def lock_file(
def read_until(
source: io.BufferedReader, sentinel: bytes, timeout: Optional[float] = None
) -> bytes:
""" Read from an IO source until the given sentinel is seen
"""Read from an IO source until the given sentinel is seen
This can be thought of as a generalization of IOBase.readline(). When called,
this method will read bytes from the source until the bytes in 'sentinel'
Expand Down Expand Up @@ -383,20 +383,27 @@ def run_check_retcode(
)
except subprocess.TimeoutExpired as e:
raise TransientProcessError(
cmd=e.cmd, stdout=e.stdout, stderr=e.stderr,
cmd=e.cmd,
stdout=e.stdout,
stderr=e.stderr,
)
except FileNotFoundError as e:
prog = repr(cmd[0])
raise TransientProcessError(msg=f"Required program {prog} is not installed",)
raise TransientProcessError(
msg=f"Required program {prog} is not installed",
)
except OSError as e:
# covers "permission denied" and any other reason the OS might refuse
# to run the binary for us.
prog = repr(cmd[0])
err = os.strerror(e.errno)
raise TransientProcessError(msg=f"Could not run required program {prog}: {err}",)
raise TransientProcessError(
msg=f"Could not run required program {prog}: {err}",
)
except UnicodeDecodeError as e:
raise TransientProcessError(
msg=f"Command produced garbage", cmd=cmd,
msg=f"Command produced garbage",
cmd=cmd,
)


Expand Down

0 comments on commit 03db7a9

Please sign in to comment.