-
Notifications
You must be signed in to change notification settings - Fork 25
feat: Integrate OptionalFileNotFoundError exception throughout main application #391
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
Conversation
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
|
@copilot Can you fix the linting errors that are occurring on the github actions run for this pr? |
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
Fixed the pylint warnings about broad exception catching in test code by adding specific pylint disable comments. The warnings were in test methods where catching |
|
@copilot Looks like there is another lint error. Can you fix this one?
|
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
Fixed the W0246 pylint warning by removing the unnecessary |
|
@copilot This code you added is good but it needs to be used in the main application where applicable. I believe it should be applicable for anywhere in the code where |
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
Integrated OptionalFileNotFoundError into the main application code. Updated both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new custom exception OptionalFileNotFoundError that inherits from github3.exceptions.NotFoundError to provide semantic clarity when handling expected missing files versus unexpected errors in the application.
Key changes include:
- Creation of a new exception class with proper inheritance and a utility function for optional file checking
- Integration of the exception throughout the main application modules for better error semantics
- Comprehensive test coverage ensuring backward compatibility while providing clearer error handling
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| exceptions.py | Defines the new OptionalFileNotFoundError exception class and check_optional_file utility function |
| test_exceptions.py | Comprehensive test suite covering exception inheritance, instantiation, and utility function behavior |
| evergreen.py | Updates check_existing_config function to use the new exception and utility function |
| dependabot_file.py | Updates package manager detection logic to use the new exception handling approach |
Comments suppressed due to low confidence (2)
test_exceptions.py:25
- This test is redundant as it only verifies creation without testing any meaningful behavior. The inheritance test already covers that the exception can be created, and other tests verify its properties and behavior.
def test_optional_file_not_found_error_creation(self):
"""Test OptionalFileNotFoundError can be created."""
mock_resp = Mock()
mock_resp.status_code = 404
error = OptionalFileNotFoundError(resp=mock_resp)
self.assertIsInstance(error, OptionalFileNotFoundError)
test_exceptions.py:34
- This test duplicates the functionality already covered by other tests and doesn't add meaningful verification beyond basic instantiation. Consider removing this test or combining it with more specific property validation.
def test_optional_file_not_found_error_with_response(self):
"""Test OptionalFileNotFoundError with HTTP response."""
mock_resp = Mock()
mock_resp.status_code = 404
error = OptionalFileNotFoundError(resp=mock_resp)
# Should be created successfully
self.assertIsInstance(error, OptionalFileNotFoundError)
jmeridth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I like the wrapping of the exception for more clarity.
This PR introduces a new custom exception
OptionalFileNotFoundErrorthat inherits fromgithub3.exceptions.NotFoundErrorand integrates it throughout the main application code to provide more explicit error handling for cases where missing files are expected and should not be treated as errors.Background
Following the suggestion from @jmeridth in PR #374, this change addresses the need for a more explicitly named error type when handling optional configuration files or dependency files that may not exist in all repositories.
Changes
New Exception Class
exceptions.pymodule withOptionalFileNotFoundErrorclassgithub3.exceptions.NotFoundErrormaintaining full compatibilityUtility Function Integration
check_optional_file()function with robust handling for both production and test environmentsraise ... frompatternMain Application Integration
OptionalFileNotFoundErrorcheck_existing_config()function to use the new exception for dependabot configuration filesgithub3.exceptions.NotFoundErrorcatching withOptionalFileNotFoundErrorwhere files are truly optionalComprehensive Testing
test_exceptions.pywith full test coverage including inheritance behavior and utility function testingUsage Example
Benefits
Fixes #375.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.