Skip to content

Commit

Permalink
Fix for 2.6.9 install issues and removal of str2bool external library (
Browse files Browse the repository at this point in the history
…#2011)

* Fix for 2.6.9 install issues and removal of str2bool external library

* Adding Sam's last name to spellcheck dictionary
  • Loading branch information
jake-skipper authored Oct 18, 2023
1 parent 61f6fdd commit b0795ad
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"filedes",
"autodetected",
"addoption",
"domparator"
"domparator",
"Fakhreddine"
]
}
2 changes: 1 addition & 1 deletion .vscode/dictionaries/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ somepath
sourcer
sphinxcontrib
sssz
strtobool
str2bool
stubber
stubbers
subcmd
Expand Down
11 changes: 0 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.8, <3.12"
python = ">=3.8, <4"

# dependencies needed for building docs are included here.
# they are marked as "optional" and are installed as the extra "docs".
Expand Down Expand Up @@ -73,7 +73,6 @@ yamllint = "*"
pipenv = "2022.1.8"
moto = "3.0.5"
testfixtures = "^7.0.3"
str2bool3 = "*"

[tool.poetry.dev-dependencies]
black = ">=22.1"
Expand Down
4 changes: 2 additions & 2 deletions runway/cfngin/hooks/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def should_use_docker(dockerize_pip: DockerizePipArgTypeDef = None) -> bool:
return False


def str2bool(v): # type: ignore
def str2bool(v: str):
"""Return boolean value of string."""
return v.lower() in ("yes", "true", "t", "1", "on")
return v.lower() in ("yes", "true", "t", "1", "on", "y")


def _zip_files(files: Iterable[str], root: str) -> Tuple[bytes, str]:
Expand Down
9 changes: 6 additions & 3 deletions runway/context/_runway.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import sys
from typing import TYPE_CHECKING, Any, Optional, Union, cast

from str2bool3 import str2bool as strtobool # type: ignore

from ..compat import cached_property
from ..core.components import DeployEnvironment
from ._base import BaseContext
Expand All @@ -20,6 +18,11 @@
LOGGER = cast("RunwayLogger", logging.getLogger(__name__))


def str2bool(v: str):
"""Return boolean value of string."""
return v.lower() in ("yes", "true", "t", "1", "on", "y")


class RunwayContext(BaseContext):
"""Runway context object."""

Expand Down Expand Up @@ -65,7 +68,7 @@ def no_color(self) -> bool:
# catch False
return not colorize
if colorize and isinstance(colorize, str): # type: ignore
return not strtobool(colorize)
return not str2bool(colorize)
except ValueError:
pass # likely invalid RUNWAY_COLORIZE value
return not sys.stdout.isatty()
Expand Down
4 changes: 2 additions & 2 deletions runway/lookups/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
TransformToTypeLiteral = Literal["bool", "str"]


def str2bool(v): # type: ignore
def str2bool(v: str):
"""Return boolean value of string."""
return v.lower() in ("yes", "true", "t", "1", "on")
return v.lower() in ("yes", "true", "t", "1", "on", "y")


class LookupHandler:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lookups/handlers/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_transform_no_type(self) -> None:
assert isinstance(LookupHandler.transform("something", to_type=None), str)

def test_transform_str_to_bool(self) -> None:
"""String should be transformed using strtobool."""
"""String should be transformed using str2bool."""
result_true = LookupHandler.transform("true", to_type="bool")
result_false = LookupHandler.transform("false", to_type="bool")

Expand Down

0 comments on commit b0795ad

Please sign in to comment.