Skip to content

Commit e0419ba

Browse files
authored
More ruff fixes (#3887)
1 parent 09afe55 commit e0419ba

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ repos:
2424
rev: v2.2.4
2525
hooks:
2626
- id: codespell
27-
- repo: https://github.com/PyCQA/isort
28-
rev: 5.12.0
29-
hooks:
30-
- id: isort
3127
- repo: https://github.com/psf/black
3228
rev: 23.3.0
3329
hooks:

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ filterwarnings = [
156156

157157
[tool.ruff]
158158
ignore = [
159+
# Disabled on purpose:
159160
"E501", # we use black
160-
# temporary disabled until we fix them:
161+
"FBT", # Boolean positional value in function call
162+
# Temporary disabled until we fix them:
161163
"A",
162164
"ANN",
163165
"ARG",
@@ -168,18 +170,15 @@ ignore = [
168170
"E741",
169171
"EM",
170172
"EXE",
171-
"FBT",
172173
"INP",
173174
"ISC",
174175
"N",
175176
"PGH",
176-
"PLC",
177177
"PLR",
178178
"PLW",
179179
"PT",
180180
"PTH",
181181
"RET",
182-
"S",
183182
"SIM",
184183
"SLF",
185184
"T",
@@ -196,6 +195,10 @@ parametrize-values-type = "tuple"
196195
[tool.ruff.isort]
197196
known-first-party = ["molecule"]
198197

198+
[tool.ruff.per-file-ignores]
199+
"src/molecule/test/**.py" = ["S"]
200+
"src/molecule/*/\\{\\{*/**.py" = ["S"]
201+
199202
[tool.setuptools.dynamic]
200203
optional-dependencies.docs = { file = [".config/requirements-docs.txt"] }
201204
optional-dependencies.test = { file = [".config/requirements-test.txt"] }

src/molecule/command/login.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ def _get_hostname(self, hosts):
9191
return match[0]
9292

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

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

103105

src/molecule/provisioner/ansible_playbooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def _get_playbook(self, section):
8585
if driver_dict:
8686
try:
8787
playbook = driver_dict[section]
88-
except Exception:
89-
pass
88+
except Exception as exc:
89+
LOG.exception(exc)
9090
if playbook is not None:
9191
playbook = self._config.provisioner.abs_path(playbook)
9292
playbook = self._normalize_playbook(playbook)

src/molecule/test/functional/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _env_vars_exposed(env_vars, env=os.environ):
5858
for env_var in env_vars:
5959
if env_var not in os.environ:
6060
return False
61-
return os.environ[env_var] != ""
61+
return bool(os.environ[env_var])
6262
return None
6363

6464

src/molecule/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def os_walk(directory, pattern, excludes=[], followlinks=False):
175175

176176
def render_template(template, **kwargs):
177177
"""Render a jinaj2 template."""
178-
t = jinja2.Environment()
178+
t = jinja2.Environment(autoescape=True)
179179
t = t.from_string(template)
180180

181181
return t.render(kwargs)

0 commit comments

Comments
 (0)