Skip to content

Add ruff flake8-blind-except rules #1326

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

Closed
wants to merge 12 commits into from
Closed

Conversation

bmos
Copy link
Contributor

@bmos bmos commented Mar 3, 2025

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

Copy link

github-actions bot commented Mar 3, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  parsons/aws
  lambda_distribute.py
  s3.py 117, 440
  parsons/databases
  db_sync.py 97, 360
  parsons/nation_builder
  nation_builder.py 111
Project Total  

This report was generated by python-coverage-comment-action

@bmos bmos marked this pull request as draft March 8, 2025 14:44
@bmos bmos changed the title Add ruff rule for flake8-blind-except Add ruff flake8-blind-except rules Mar 20, 2025
@bmos bmos closed this Mar 23, 2025
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.

1 participant