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

suppress pylint warn contextmanager-generator-missing-cleanup #3138

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

nagworld9
Copy link
Contributor

Description

Fix for new warning from latest pylint.
_tests/ga/test_update.py:1203:12: W0135: The context used in function '_setup_test_for_ext_event_dirs_retention' will not be exited. (contextmanager-generator-missing-cleanup)_

It looks like false positive according to documentation https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/contextmanager-generator-missing-cleanup.html

The check can create false positives if yield is used inside an if-else block without custom cleanup. Use pylint: disable for these.

This warning not implemented in earlier versions of python (3.0 -3.7) So I disabled the warning with (bad-option-value) in GitHub workflow

Issue #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made

Quality of Code and Contribution Guidelines

@@ -284,6 +284,7 @@ def __setup_generic_test_env(self):
third_ext = extension_emulator(name="OSTCExtensions.ExampleHandlerLinux.thirdExtension")
fourth_ext = extension_emulator(name="Microsoft.Powershell.ExampleExtension")

# pylint: disable=contextmanager-generator-missing-cleanup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be inline, on the line producing the warning

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, if you can add a comment to each suppression pointing out what generator is triggering the warning, it'd be great

@nagworld9 nagworld9 merged commit f47718e into Azure:develop Jun 7, 2024
10 of 11 checks passed
@nagworld9 nagworld9 deleted the pylint-warn branch June 7, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants