-
Notifications
You must be signed in to change notification settings - Fork 221
Pylint Exception logging #9077
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
Merged
Merged
Pylint Exception logging #9077
Changes from 17 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
9f84ad7
add placeholders
MJoshuaB c81ff56
add new placeholder comments
MJoshuaB 18762be
exploring AST unfinished - minor emergency had to leave
2238161
identifying some mismatched functions
95fe015
refactor checker and tests
MJoshuaB e2e664f
fix error with non-builtins decorators
MJoshuaB 46053e6
fine tuning and testing required
b402a5d
add pylint report
MJoshuaB 3d051d7
add ranked listing of reports
MJoshuaB fdf6db7
format report as table
MJoshuaB fb160d5
add new verbs
MJoshuaB f06c915
update report
MJoshuaB db697b2
update reportcounts.md
MJoshuaB ae66d2c
fix formatting for reportcounts.md
MJoshuaB 233f536
update reportcounts.md
MJoshuaB 27edb80
minimal tests added
112173d
Merge pull request #2 from Azure/main
JessicaBell00 c5ffb91
Merge branch 'Azure:main' into main
JessicaBell00 7dc03ca
Merge branch 'working-main' into main
JessicaBell00 18f09e9
Merge pull request #5 from MJoshuaB/main
JessicaBell00 af098f7
Merge branch 'Azure:main' into working-main
JessicaBell00 cfba33d
Base code and unit tests
JessicaBell00 f7af031
Refactored class to be more specific
JessicaBell00 013a408
Added to README
JessicaBell00 fee5009
Merge branch 'main' of https://github.com/Azure/azure-sdk-tools into …
JessicaBell00 bec9467
Update README / fix merging
JessicaBell00 6e53b16
Final Refactor
687f542
Fixed false positives
JessicaBell00 80657b4
not running multiple times picking up on different function types
5b69e7e
Merge branch 'main' into invalid-use-of-@overload
16234397 b10a3cd
add TODOs
MJoshuaB a0e5c18
removed code not reached
bf6936c
Merge remote-tracking branch 'origin/invalid-use-of-@overload' into i…
3ed8120
Checks at a class level
ac9921a
Merge branch 'main' into invalid-use-of-@overload
16234397 4c638df
Looking into different connection_verify assignments
ab62179
Placeholders added back
16234397 795c861
Checker base done
35094ba
exclue private namespaces and classes
MJoshuaB ed5e211
update reports
MJoshuaB a835da4
Checker, Tests, & Readme done
693ea14
Update pylint_guidelines_checker.py
JessicaBell00 141da43
Fix another false positive
JessicaBell00 202faa2
Check either sides of indices
JessicaBell00 3abf67a
Merge branch 'main' of https://github.com/Azure/azure-sdk-tools into …
JessicaBell00 ae88cee
add new prefixes
MJoshuaB efe6ddc
Merge branch 'main' into working-main
MJoshuaB 0bf7340
Merge branch 'working-main' into approved_prefix
MJoshuaB cfaa891
update unit tests
MJoshuaB a6f341a
remove reports
MJoshuaB 5947f31
remove commented code
MJoshuaB 65e431f
add checker to README
MJoshuaB c50a082
Merge branch 'working-main' into do-not-hardcode-boolean-connection_v…
16234397 24e9647
Merge pull request #10 from MJoshuaB/do-not-hardcode-boolean-connecti…
16234397 1f78550
Merge branch 'working-main' into invalid-use-of-@overload
16234397 56176ca
Merge pull request #11 from MJoshuaB/invalid-use-of-@overload
16234397 8cdce20
Tidy Up
6a319b7
Add TODO comment re other cases to investigate
JessicaBell00 7e7256b
Merge pull request #13 from Azure/main
JessicaBell00 6d262e3
Merge branch 'working-main' into approved_prefix
MJoshuaB 18ea2fa
Merge pull request #12 from MJoshuaB/approved_prefix
MJoshuaB e2dcbb9
Merge branch 'working-main' into exception-logging
JessicaBell00 9027a8b
Revert "Merge branch 'working-main' into exception-logging"
JessicaBell00 9a32416
Make checker more explicit
JessicaBell00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...lint-extensions/azure-pylint-guidelines-checker/tests/test_files/do_not_log_exceptions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| from plugin import logger | ||
|
|
||
|
|
||
| # test_logging_levels_logged_str_exception | ||
| def test_logging_levels_logged_str_exception(): | ||
| try: # @ | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| logger.error("Error" + str(ex)) # @ | ||
| logger.warning(str(ex)) | ||
| logger.info(str(ex)) | ||
| logger.debug(str(ex)) | ||
|
|
||
JessicaBell00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # test_logging_levels_logged_repr_exception | ||
| def test_logging_levels_logged_repr_exception(): | ||
| try: # @ | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| logger.error(repr(ex)) # @ | ||
| logger.warning(repr(ex)) | ||
| logger.info(repr(ex)) | ||
| logger.debug(repr(ex)) | ||
|
|
||
|
|
||
| # test_regular_logging_ok | ||
| def test_regular_logging_ok(): | ||
| try: # @ | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| logger.error("Example 1") # @ | ||
| logger.warning("This is another example") | ||
| logger.info("Random logging") | ||
| logger.debug("Logging") | ||
|
|
||
|
|
||
| # test_logging_str_exception_branches | ||
| def test_logging_str_exception_branches(): | ||
| try: # @ | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| if ex.code == "Retryable": | ||
| logger.error(str(ex)) | ||
| return True | ||
| elif Exception != BaseException: | ||
| logger.warning(repr(ex)) | ||
| return False | ||
| else: | ||
| logger.info(str(ex)) # @ | ||
|
|
||
|
|
||
| # test_other_logging_fails | ||
| def test_other_logging_fails(): | ||
| try: # @ | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| if ex.code == "Retryable": | ||
| logger.error("Something went wrong: {ex}. Try again") | ||
| return True | ||
| else: | ||
| logger.warning(ex) | ||
| return False | ||
|
|
||
|
|
||
| # test_no_logging_and_no_exception_name_ok | ||
| def test_no_logging_and_no_exception_name_ok(): | ||
| try: | ||
| add = 1 + 2 | ||
| except Exception as ex: | ||
| self.errors.appendleft(ex) | ||
| except Exception as ex: # pylint: disable=broad-except | ||
| _logger.warning( | ||
| "Exception occurred when instrumenting: %s.", | ||
| lib_name, | ||
| exc_info=ex, | ||
| ) | ||
| except (OSError, PermissionError) as e: | ||
| logger.warning( | ||
| "Failed to read on-disk cache for component due to %s. " | ||
| "Please check if the file %s is in use or current user doesn't have the permission.", | ||
| type(e).__name__, | ||
| on_disk_cache_path.as_posix(), | ||
| ) | ||
|
|
||
|
|
||
| # test_logging_without_exception_name | ||
| def test_logging_without_exception_name(): | ||
| try: | ||
| add = 1 + 2 | ||
| except Exception as exception: | ||
| if exception.code == "Retryable": | ||
| _LOGGER.info( | ||
| "%r returns an exception %r", self._container_id, last_exception | ||
| ) | ||
| else: | ||
| module_logger.debug("Skipping file upload, reason: %s", str(e.reason)) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.