fix: replace bare except with specific exception types#68842
Open
harshadkhetpal wants to merge 7 commits into
Open
fix: replace bare except with specific exception types#68842harshadkhetpal wants to merge 7 commits into
harshadkhetpal wants to merge 7 commits into
Conversation
bdrx312
reviewed
Mar 30, 2026
| try: | ||
| raw = self.beacons[fun_str](b_config[mod]) | ||
| except: # pylint: disable=bare-except | ||
| except Exception: # pylint: disable=bare-except |
Contributor
There was a problem hiding this comment.
Also remove # pylint: disable=bare-except if removing the bare except.
Contributor
There was a problem hiding this comment.
except Exception is essentially just a bare except
Contributor
There was a problem hiding this comment.
It isn't a bare expect it is a broad expect so I think the correct disable would be # pylint: disable=broad-except
Contributor
There was a problem hiding this comment.
Okay, I hadn't properly looked at this when I made my comment. I'm good with this change, provided we use broad-except for pylint.
d2c53ef to
1ec3866
Compare
Contributor
|
Lint failures need to be addressed. Also needs a changelog and tests |
613bbbe to
c07bfa7
Compare
twangboy
approved these changes
Jul 13, 2026
Per maintainer feedback: replace bare-except/W0702 pylint disable comments with broad-except at all modified sites; narrow x509.py strptime exception clauses from BaseException to ValueError.
Add changelog/68842.fixed.md per reviewer request and add unit tests for salt/matchers/ipcidr_match.py covering address match, CIDR match, invalid target error handling, and missing proto in grains.
c07bfa7 to
920c98e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Replace bare
except:clauses with specific exception types across 5 files (7 occurrences).Bare
except:catches all exceptions includingSystemExit,KeyboardInterrupt, andGeneratorExit, which should typically propagate. Per PEP 8 (E722) and flake8-bugbear (B001):except BaseException: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:(hasraise)salt/beacons/__init__.py— 1×except Exception:salt/states/saltmod.py— 1×except Exception:Testing
No behavior change — style/correctness fix only.