-
Notifications
You must be signed in to change notification settings - Fork 109
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
Support exception aliases properly in B014 #129
Conversation
A good example is OSError. Since Python 3.3, IOError, EnvironmentError, select.error, etc merged into OSError and became aliases. Before this change, both the aliases and the primary exceptions were removed from the message.
# Find and remove aliases exceptions and only leave the primary alone | ||
primaries = filter( | ||
lambda primary: primary in good, B014.exception_aliases.keys() | ||
) | ||
for primary in primaries: | ||
aliases = B014.exception_aliases[primary] | ||
good = list(filter(lambda e: e not in aliases, good)) |
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.
Perhaps this is a bit over-engineered. I could just define an edge-case for OSError.
Thoughts?
Copy of original review because I modified this code afterwards to be more functional with filter
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.
Na seems fine to me and makes sense.
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.
Looks good to me, maybe I'll give it a few days for @Zac-HD to agrees too ...
# Find and remove aliases exceptions and only leave the primary alone | ||
primaries = filter( | ||
lambda primary: primary in good, B014.exception_aliases.keys() | ||
) | ||
for primary in primaries: | ||
aliases = B014.exception_aliases[primary] | ||
good = list(filter(lambda e: e not in aliases, good)) |
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.
Na seems fine to me and makes sense.
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.
Looks good to me!
Resolves #110
Resolves #126