Skip to content

fix: replace bare except with specific exception types#68842

Open
harshadkhetpal wants to merge 5 commits intosaltstack:masterfrom
harshadkhetpal:fix/bare-except-exception
Open

fix: replace bare except with specific exception types#68842
harshadkhetpal wants to merge 5 commits intosaltstack:masterfrom
harshadkhetpal:fix/bare-except-exception

Conversation

@harshadkhetpal
Copy link
Copy Markdown

Summary

Replace bare except: clauses with specific exception types across 5 files (7 occurrences).

Bare except: catches all exceptions including SystemExit, KeyboardInterrupt, and GeneratorExit, which should typically propagate. Per PEP 8 (E722) and flake8-bugbear (B001):

  • Sites that re-raise → except BaseException:
  • Sites that swallow errors → except Exception:

Files changed:

  • salt/matchers/ipcidr_match.py — 2× except Exception:
  • salt/roster/dir.py — 1× except Exception:
  • salt/modules/x509.py — 2× except BaseException: (has raise)
  • salt/beacons/__init__.py — 1× except Exception:
  • salt/states/saltmod.py — 1× except Exception:
# Before
except:

# After (no re-raise)
except Exception:

# After (with re-raise)
except BaseException:

Testing

No behavior change — style/correctness fix only.

@harshadkhetpal harshadkhetpal requested a review from a team as a code owner March 25, 2026 03:51
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