Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix print leak with meta-unsupported-ansible #2913

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ repos:
- flake8-2020>=1.6.0
# - flake8-black>=0.1.1
- flake8-docstrings>=1.5.0
- flake8-print>=5.0
- flake8-pytest-style>=1.2.2
- flake8-future-annotations>=0.0.3
- repo: https://github.com/asottile/pyupgrade
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
# Fail safe protection to detect conflicting packages
try:
pkg_resources.get_distribution("sphinxcontrib-programoutput")
# flake8: noqa: T201
print(
"FATAL: We detected presence of sphinxcontrib-programoutput package instead of sphinxcontrib-programoutput2 one. You must be sure the first is not installed.",
file=sys.stderr,
Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def path_inject() -> None:
paths[idx] = os.path.expanduser(path)
expanded = True
if expanded: # pragma: no cover
# flake8: noqa: T201
print(
"WARNING: PATH altered to expand ~ in it. Read https://stackoverflow.com/a/44704799/99834 and correct your system configuration.",
file=sys.stderr,
Expand All @@ -387,6 +388,7 @@ def path_inject() -> None:
inject_paths.append(py_path)

if inject_paths:
# flake8: noqa: T201
print(
f"WARNING: PATH altered to include {', '.join(inject_paths)} :: This is usually a sign of broken local setup, which can cause unexpected behaviors.",
file=sys.stderr,
Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/rules/ignore_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def test_ignore_errors_false(rule_runner: RunFromText) -> None:
def test_ignore_errors_check_mode(rule_runner: RunFromText) -> None:
"""The task uses ignore_errors: "{{ ansible_check_mode }}"."""
results = rule_runner.run_playbook(IGNORE_ERRORS_CHECK_MODE)
print(results)
assert len(results) == 0

@pytest.mark.parametrize(
Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/meta_unsupported_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:

version_required = file.data.get("requires_ansible", None)

print(version_required)

if version_required:
if not any(
version in version_required for version in self.supported_ansible
Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/rules/yaml_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def test_yamllint_has_help(default_rules_collection: RulesCollection) -> None:
"""Asserts that we loaded markdown documentation in help property."""
for collection in default_rules_collection:
if collection.id == "yaml":
print(collection.id)
assert collection.help is not None
assert len(collection.help) > 100
break
Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/schemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
if __name__ == "__main__":

if refresh_schemas():
# flake8: noqa: T201
print("Schemas were updated.")
sys.exit(1)
else:
# flake8: noqa: T201
print("Schemas not updated", 0)
2 changes: 2 additions & 0 deletions src/ansiblelint/schemas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
if __name__ == "__main__":

if refresh_schemas():
# flake8: noqa: T201
print("Schemas were updated.")
sys.exit(1)
else:
# flake8: noqa: T201
print("Schemas not updated", 0)
10 changes: 4 additions & 6 deletions test/fixtures/test_regenerate_formatting_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def test_regenerate_formatting_fixtures() -> None:
we run prettier again to make sure it does not change files formatted
with our internal formatting code.
"""
print("Looking for prettier on PATH...")
subprocess.check_call(["which", "prettier"])

yaml = FormattedYAML()
Expand All @@ -30,21 +29,20 @@ def test_regenerate_formatting_fixtures() -> None:
fixtures_dir_prettier.mkdir(exist_ok=True)
fixtures_dir_after.mkdir(exist_ok=True)

print("\nCopying before fixtures...")
# Copying before fixtures...
for fixture in fixtures_dir_before.glob("fmt-[0-9].yml"):
shutil.copy(str(fixture), str(fixtures_dir_prettier / fixture.name))
shutil.copy(str(fixture), str(fixtures_dir_after / fixture.name))

print("\nWriting fixtures with prettier...")
# Writing fixtures with prettier...
subprocess.check_call(["prettier", "-w", str(fixtures_dir_prettier)])
# NB: pre-commit end-of-file-fixer can also modify files.

print("\nWriting fixtures with ansiblelint.yaml_utils.FormattedYAML()...")
# Writing fixtures with ansiblelint.yaml_utils.FormattedYAML()
for fixture in fixtures_dir_after.glob("fmt-[0-9].yml"):
data = yaml.loads(fixture.read_text())
output = yaml.dumps(data)
print(fixture)
fixture.write_text(output)

print(f"\nMake sure prettier won't make changes in {fixtures_dir_after}...")
# Make sure prettier won't make changes in {fixtures_dir_after}
subprocess.check_call(["prettier", "-c", str(fixtures_dir_after)])
2 changes: 2 additions & 0 deletions test/schemas/src/rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def is_ref_used(obj: Any, ref: str) -> bool:
invalid_var_names = sorted(list(keyword.kwlist) + play_keywords)
if "__peg_parser__" in invalid_var_names:
invalid_var_names.remove("__peg_parser__")
# flake8: noqa: T201
print("Updating invalid var names")

with open("f/vars.json", "r+", encoding="utf-8") as f:
Expand All @@ -90,6 +91,7 @@ def is_ref_used(obj: Any, ref: str) -> bool:
f.write("\n")
f.truncate()

# flake8: noqa: T201
print("Compiling subschemas...")
with open("f/ansible.json", encoding="utf-8") as f:
combined_json = json.load(f)
Expand Down
1 change: 0 additions & 1 deletion test/test_list_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_list_rules_with_format_option(
fakerole = os.path.join("test", "fixtures", "list-rules-tests")

result_list_rules = run_ansible_lint("-f", format_string, "-L", fakerole, cwd=cwd)
print(result_list_rules.stdout)

assert (f"invalid choice: '{format_string}'" in result_list_rules.stderr) is result
assert ("syntax-check" in result_list_rules.stdout) is not result
Expand Down