Skip to content

Commit

Permalink
Replace deprecated strtobool method
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Sep 16, 2024
1 parent 8394716 commit 614abf0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion resolwe/flow/executors/startup_communication_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import threading
from concurrent.futures import ThreadPoolExecutor
from contextlib import suppress
from distutils.util import strtobool
from pathlib import Path
from typing import Any, Optional, Tuple

Expand All @@ -36,6 +35,24 @@
from executors.transfer import transfer_data
from executors.zeromq_utils import ZMQCommunicator


def strtobool(value: str) -> bool:
"""Convert string to boolean.
Replacement for a method from deprecated distutils.util module.
"""
_true_set = {"yes", "true", "t", "y", "1"}
_false_set = {"no", "false", "f", "n", "0"}

This comment has been minimized.

Copy link
@acopar

acopar Sep 16, 2024

Contributor

If you want to keep one-to-one feature parity with the replaced strtobool function, you also need to include on and off in the term sets. Also, See this:
https://docs.python.org/3.11/distutils/apiref.html#distutils.util.strtobool


if isinstance(value, str):
value = value.lower()
if value in _true_set:
return True
if value in _false_set:
return False
raise ValueError('Expected "%s"' % '", "'.join(_true_set | _false_set))


# Socket used to connect with the processing container.
PROCESSING_SOCKET = constants.SOCKETS_VOLUME / constants.COMMUNICATION_PROCESSING_SOCKET
UPLOAD_FILE_SOCKET = constants.SOCKETS_VOLUME / constants.UPLOAD_FILE_SOCKET
Expand Down

0 comments on commit 614abf0

Please sign in to comment.