Python: py/import-deprecated-module handle backwards compatible code

This commit is contained in:
Rasmus Wriedt Larsen
2020-01-28 16:36:47 +01:00
parent e92d6c0459
commit 6c7cddf258
4 changed files with 13 additions and 4 deletions

View File

@@ -73,8 +73,13 @@ string replacement_message(string mod) {
)
}
from ImportExpr imp, string name
from ImportExpr imp, string name, string instead
where
name = imp.getName() and
deprecated_module(name, _, _, _)
deprecated_module(name, instead, _, _) and
not exists(Try try, ExceptStmt except | except = try.getAHandler()
|
except.getType().pointsTo(ClassValue::importError()) and
except.containsInScope(imp)
)
select imp, deprecation_message(name) + replacement_message(name)