diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index f470b4428c..fd8d91a380 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -139,16 +139,15 @@ jobs: # * On 3.9 pylint crashes when parsing azurelinuxagent/daemon/main.py (see https://github.com/pylint-dev/pylint/issues/9473), so we ignore it. # * 'no-self-use' ("R0201: Method could be a function") was moved to an optional extension on 3.8 and is no longer used by default. It needs # to be suppressed for previous versions (3.0-3.7), though. - # + # * 'contextmanager-generator-missing-cleanup' are false positives if yield is used inside an if-else block for contextmanager generator functions. + # (https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/contextmanager-generator-missing-cleanup.html). + # This is not implemented on versions (3.0-3.7) Bad option value 'contextmanager-generator-missing-cleanup' (bad-option-value) PYLINT_OPTIONS="--rcfile=ci/pylintrc --jobs=0" - if [[ "${{ matrix.python-version }}" == "3.5" ]]; then - PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=bad-option-value" - fi if [[ "${{ matrix.python-version }}" == "3.9" ]]; then PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-member --ignore=main.py" fi if [[ "${{ matrix.python-version }}" =~ ^3\.[0-7]$ ]]; then - PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-self-use" + PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-self-use,bad-option-value" fi echo "PYLINT_OPTIONS: $PYLINT_OPTIONS" diff --git a/tests/ga/test_multi_config_extension.py b/tests/ga/test_multi_config_extension.py index 127535a54a..450ca071dc 100644 --- a/tests/ga/test_multi_config_extension.py +++ b/tests/ga/test_multi_config_extension.py @@ -284,7 +284,8 @@ def __setup_generic_test_env(self): third_ext = extension_emulator(name="OSTCExtensions.ExampleHandlerLinux.thirdExtension") fourth_ext = extension_emulator(name="Microsoft.Powershell.ExampleExtension") - with self._setup_test_env(mock_manifest=True) as (exthandlers_handler, protocol, no_of_extensions): + # In _setup_test_env() contextmanager, yield is used inside an if-else block and that's creating a false positive pylint warning + with self._setup_test_env(mock_manifest=True) as (exthandlers_handler, protocol, no_of_extensions): # pylint: disable=contextmanager-generator-missing-cleanup with enable_invocations(first_ext, second_ext, third_ext, fourth_ext) as invocation_record: exthandlers_handler.run() exthandlers_handler.report_ext_handlers_status() @@ -1070,7 +1071,8 @@ def __setup_test_and_get_exts(self): dependent_sc_ext = extension_emulator(name="Microsoft.Powershell.ExampleExtension") independent_sc_ext = extension_emulator(name="Microsoft.Azure.Geneva.GenevaMonitoring", version="1.1.0") - with self._setup_test_env() as (exthandlers_handler, protocol, no_of_extensions): + # In _setup_test_env() contextmanager, yield is used inside an if-else block and that's creating a false positive pylint warning + with self._setup_test_env() as (exthandlers_handler, protocol, no_of_extensions): # pylint: disable=contextmanager-generator-missing-cleanup yield exthandlers_handler, protocol, no_of_extensions, first_ext, second_ext, third_ext, dependent_sc_ext, independent_sc_ext def test_it_should_process_dependency_chain_extensions_properly(self): diff --git a/tests/ga/test_update.py b/tests/ga/test_update.py index 58d58505bd..f06e64a902 100644 --- a/tests/ga/test_update.py +++ b/tests/ga/test_update.py @@ -1200,7 +1200,8 @@ def test_it_should_not_set_dns_tcp_iptable_if_drop_and_accept_available(self): @contextlib.contextmanager def _setup_test_for_ext_event_dirs_retention(self): try: - with _get_update_handler(test_data=DATA_FILE_MULTIPLE_EXT, autoupdate_enabled=False) as (update_handler, protocol): + # In _get_update_handler() contextmanager, yield is used inside an if-else block and that's creating a false positive pylint warning + with _get_update_handler(test_data=DATA_FILE_MULTIPLE_EXT, autoupdate_enabled=False) as (update_handler, protocol): # pylint: disable=contextmanager-generator-missing-cleanup with patch("azurelinuxagent.common.agent_supported_feature._ETPFeature.is_supported", True): update_handler.run(debug=True) expected_events_dirs = glob.glob(os.path.join(conf.get_ext_log_dir(), "*", EVENTS_DIRECTORY)) @@ -1483,8 +1484,8 @@ def __get_update_handler(self, iterations=1, test_data=None, reload_conf=None, autoupdate_frequency=0.001, hotfix_frequency=1.0, normal_frequency=2.0): test_data = DATA_FILE if test_data is None else test_data - - with _get_update_handler(iterations, test_data) as (update_handler, protocol): + # In _get_update_handler() contextmanager, yield is used inside an if-else block and that's creating a false positive pylint warning + with _get_update_handler(iterations, test_data) as (update_handler, protocol): # pylint: disable=contextmanager-generator-missing-cleanup protocol.aggregate_status = None