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

Delay app initialization #2642

Merged
merged 1 commit into from
Oct 31, 2022
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
2 changes: 1 addition & 1 deletion src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def main(argv: list[str] | None = None) -> int: # noqa: C901
_logger.debug("Options: %s", options)
_logger.debug(os.getcwd())

app = get_app(offline=options.offline)
# pylint: disable=import-outside-toplevel
from ansiblelint.rules import RulesCollection
from ansiblelint.runner import _get_matches
Expand All @@ -212,6 +211,7 @@ def main(argv: list[str] | None = None) -> int: # noqa: C901
if options.listrules or options.listtags:
return _do_list(rules)

app = get_app(offline=options.offline)
if isinstance(options.tags, str):
options.tags = options.tags.split(",")
result = _get_matches(rules, options)
Expand Down
2 changes: 2 additions & 0 deletions test/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from _pytest.fixtures import FixtureRequest

from ansiblelint.app import get_app
from ansiblelint.rules import RulesCollection
from ansiblelint.runner import Runner
from ansiblelint.testing import run_ansible_lint
Expand Down Expand Up @@ -49,6 +50,7 @@ def test_example_syntax_error(

def test_example_custom_module(default_rules_collection: RulesCollection) -> None:
"""custom_module.yml is expected to pass."""
get_app(offline=True)
result = Runner(
"examples/playbooks/custom_module.yml", rules=default_rules_collection
).run()
Expand Down