diff --git a/.pylintrc b/.pylintrc index da79485d94..a383e4bc5b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -19,7 +19,6 @@ disable = consider-using-f-string, dangerous-default-value, duplicate-code, - protected-access, [TYPECHECK] # pylint is unable to detect Namespace attributes and will throw a E1101 diff --git a/src/ansiblelint/rules/syntax_check.py b/src/ansiblelint/rules/syntax_check.py index 253a4dcbdf..cec0a85446 100644 --- a/src/ansiblelint/rules/syntax_check.py +++ b/src/ansiblelint/rules/syntax_check.py @@ -133,6 +133,7 @@ def test_get_ansible_syntax_check_matches() -> None: lintable = Lintable( "examples/playbooks/conflicting_action.yml", kind="playbook" ) + # pylint: disable=protected-access result = AnsibleSyntaxCheckRule._get_ansible_syntax_check_matches(lintable) assert result[0].linenumber == 4 assert result[0].column == 7 @@ -148,6 +149,7 @@ def test_get_ansible_syntax_check_matches() -> None: def test_empty_playbook() -> None: """Validate detection of empty-playbook.""" lintable = Lintable("examples/playbooks/empty_playbook.yml", kind="playbook") + # pylint: disable=protected-access result = AnsibleSyntaxCheckRule._get_ansible_syntax_check_matches(lintable) assert result[0].linenumber == 1 # We internally convert absolute paths returned by ansible into paths @@ -165,6 +167,7 @@ def test_extra_vars_passed_to_command(config_options: Any) -> None: } lintable = Lintable("examples/playbooks/extra_vars.yml", kind="playbook") + # pylint: disable=protected-access result = AnsibleSyntaxCheckRule._get_ansible_syntax_check_matches(lintable) assert not result diff --git a/src/ansiblelint/runner.py b/src/ansiblelint/runner.py index 1e6f53c26c..dcd441d9fd 100644 --- a/src/ansiblelint/runner.py +++ b/src/ansiblelint/runner.py @@ -112,6 +112,7 @@ def run(self) -> List[MatchError]: # -- phase 1 : syntax check in parallel -- def worker(lintable: Lintable) -> List[MatchError]: + # pylint: disable=protected-access return AnsibleSyntaxCheckRule._get_ansible_syntax_check_matches(lintable) # playbooks: List[Lintable] = [] diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index 9e742fe463..c34bda1a07 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -689,7 +689,9 @@ def construct_mapping( if hasattr(node, "__line__"): mapping[LINE_NUMBER_KEY] = node.__line__ else: - mapping[LINE_NUMBER_KEY] = mapping._line_number + mapping[ + LINE_NUMBER_KEY + ] = mapping._line_number # pylint: disable=protected-access mapping[FILENAME_KEY] = lintable.path return mapping diff --git a/src/ansiblelint/yaml_utils.py b/src/ansiblelint/yaml_utils.py index 9bcc8051dd..3534c63d0d 100644 --- a/src/ansiblelint/yaml_utils.py +++ b/src/ansiblelint/yaml_utils.py @@ -248,6 +248,7 @@ def represent_octal( v = format(data, "o") anchor = data.yaml_anchor(any=True) # noinspection PyProtectedMember + # pylint: disable=protected-access return representer.insert_underscore("0", v, data._underscore, anchor=anchor) diff --git a/test/test_formatter_base.py b/test/test_formatter_base.py index 53e77fb2a1..2d9aff70f6 100644 --- a/test/test_formatter_base.py +++ b/test/test_formatter_base.py @@ -25,10 +25,11 @@ def test_base_formatter_when_base_dir( base_formatter = BaseFormatter(base_dir, relative_path) # type: ignore # When - output_path = base_formatter._format_path(path) + output_path = base_formatter._format_path(path) # pylint: disable=protected-access # Then assert isinstance(output_path, str) + # pylint: disable=protected-access assert base_formatter._base_dir is None or isinstance(base_formatter._base_dir, str) assert output_path == str(path) @@ -49,10 +50,12 @@ def test_base_formatter_when_base_dir_is_given_and_relative_is_true( base_formatter = BaseFormatter(base_dir, True) # type: ignore # When + # pylint: disable=protected-access output_path = base_formatter._format_path(path) # Then assert isinstance(output_path, str) + # pylint: disable=protected-access assert isinstance(base_formatter._base_dir, str) assert output_path == Path(path).name diff --git a/test/test_yaml_utils.py b/test/test_yaml_utils.py index 5940796415..9f07c8ae88 100644 --- a/test/test_yaml_utils.py +++ b/test/test_yaml_utils.py @@ -20,7 +20,7 @@ def fixture_empty_lintable() -> Lintable: """Return a Lintable with no contents.""" lintable = Lintable("__empty_file__") - lintable._content = "" + lintable._content = "" # pylint: disable=protected-access return lintable