Add ruff flake8-blind-except rules #1326
Closed
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.
Note
This is not needed if #1325 is merged; merging both may cause two errors instead of one when blind exceptions are caught.
More info
https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble
Overly broad except clauses can lead to unexpected behavior, such as catching KeyboardInterrupt or SystemExit exceptions that prevent the user from exiting the program.
Since I don't know what the correct Exception class is for existing code, I added noqa declarations to the 9 places that currently violate this rule to get this to pass (so it will protect against this in future code).
Current lines:
parsons/aws/lambda_distribute.py: 257
parsons/aws/s3.py: 117
parsons/aws/s3.py: 440
parsons/databases/db_sync.py: 97
parsons/databases/db_sync.py: 360
parsons/nation_builder/nation_builder.py: 111
test/test_s3.py: 51
useful_resources/sample_code/mysql_to_googlesheets.py: 72
useful_resources/sample_code/s3_to_redshift.py: 60