Skip to content

Commit

Permalink
More ruff fixes (#3887)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Apr 21, 2023
1 parent 09afe55 commit e0419ba
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ repos:
rev: v2.2.4
hooks:
- id: codespell
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ filterwarnings = [

[tool.ruff]
ignore = [
# Disabled on purpose:
"E501", # we use black
# temporary disabled until we fix them:
"FBT", # Boolean positional value in function call
# Temporary disabled until we fix them:
"A",
"ANN",
"ARG",
Expand All @@ -168,18 +170,15 @@ ignore = [
"E741",
"EM",
"EXE",
"FBT",
"INP",
"ISC",
"N",
"PGH",
"PLC",
"PLR",
"PLW",
"PT",
"PTH",
"RET",
"S",
"SIM",
"SLF",
"T",
Expand All @@ -196,6 +195,10 @@ parametrize-values-type = "tuple"
[tool.ruff.isort]
known-first-party = ["molecule"]

[tool.ruff.per-file-ignores]
"src/molecule/test/**.py" = ["S"]
"src/molecule/*/\\{\\{*/**.py" = ["S"]

[tool.setuptools.dynamic]
optional-dependencies.docs = { file = [".config/requirements-docs.txt"] }
optional-dependencies.test = { file = [".config/requirements-test.txt"] }
Expand Down
2 changes: 2 additions & 0 deletions src/molecule/command/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ def _get_hostname(self, hosts):
return match[0]

def _get_login(self, hostname): # pragma: no cover
# ruff: noqa: S605,S607
lines, columns = os.popen("stty size", "r").read().split()
login_options = self._config.driver.login_options(hostname)
login_options["columns"] = columns
login_options["lines"] = lines
login_cmd = self._config.driver.login_cmd_template.format(**login_options)

cmd = shlex.split(f"/usr/bin/env {login_cmd}")
# ruff: noqa: S603
subprocess.run(cmd)


Expand Down
4 changes: 2 additions & 2 deletions src/molecule/provisioner/ansible_playbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def _get_playbook(self, section):
if driver_dict:
try:
playbook = driver_dict[section]
except Exception:
pass
except Exception as exc:
LOG.exception(exc)
if playbook is not None:
playbook = self._config.provisioner.abs_path(playbook)
playbook = self._normalize_playbook(playbook)
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _env_vars_exposed(env_vars, env=os.environ):
for env_var in env_vars:
if env_var not in os.environ:
return False
return os.environ[env_var] != ""
return bool(os.environ[env_var])
return None


Expand Down
2 changes: 1 addition & 1 deletion src/molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def os_walk(directory, pattern, excludes=[], followlinks=False):

def render_template(template, **kwargs):
"""Render a jinaj2 template."""
t = jinja2.Environment()
t = jinja2.Environment(autoescape=True)
t = t.from_string(template)

return t.render(kwargs)
Expand Down

0 comments on commit e0419ba

Please sign in to comment.