You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This report is similar to others which mention undetected use of undefined variables after if False or in the finally branch of a try/finally statement. I think use of undefined variables in except clauses is perhaps a higher priority fix. Consider this function:
It's clear that the variable resp is used while undefined. Missing it is more critical than in most other cases because it is generally going to be executed infrequently. If, as in this case, only one variable is assigned in the try clause and it wasn't defined beforehand, then an undefined-variable message should be emitted. If more than one variable is assigned in the try clause, then a possibly-undefined-variable message should go out over the wire. I'm not suggesting that pylint should be able to do any kind of sophisticated analysis. If it wasn't defined before the try clause, is assigned in the try clause, then referenced in the except clause, it should be flagged.
If the user assigns 37 different variables in the try clause and references fourteen of them in the except clause, the voluminous amount of output will also serve as a good clue that they need to tighten up their try clause (quoting from PEP 8: "Additionally, for all try/except clauses, limit the try clause to the absolute minimum amount of code necessary.") :-)
The text was updated successfully, but these errors were encountered:
This report is similar to others which mention undetected use of undefined variables after if False or in the finally branch of a try/finally statement. I think use of undefined variables in except clauses is perhaps a higher priority fix. Consider this function:
It's clear that the variable resp is used while undefined. Missing it is more critical than in most other cases because it is generally going to be executed infrequently. If, as in this case, only one variable is assigned in the try clause and it wasn't defined beforehand, then an undefined-variable message should be emitted. If more than one variable is assigned in the try clause, then a possibly-undefined-variable message should go out over the wire. I'm not suggesting that pylint should be able to do any kind of sophisticated analysis. If it wasn't defined before the try clause, is assigned in the try clause, then referenced in the except clause, it should be flagged.
If the user assigns 37 different variables in the try clause and references fourteen of them in the except clause, the voluminous amount of output will also serve as a good clue that they need to tighten up their try clause (quoting from PEP 8: "Additionally, for all try/except clauses, limit the try clause to the absolute minimum amount of code necessary.") :-)
The text was updated successfully, but these errors were encountered: