mirror of
https://github.com/github/codeql.git
synced 2026-03-31 20:58:16 +02:00
Python: Port ShouldBeContextManager.ql
Only trivial test changes.
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
import python
|
||||
private import LegacyPointsTo
|
||||
private import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||
|
||||
from ClassValue c
|
||||
where not c.isBuiltin() and not c.isContextManager() and exists(c.declaredAttribute("__del__"))
|
||||
from Class c
|
||||
where
|
||||
not DuckTyping::isContextManager(c) and
|
||||
DuckTyping::hasMethod(c, "__del__")
|
||||
select c,
|
||||
"Class " + c.getName() +
|
||||
" implements __del__ (presumably to release some resource). Consider making it a context manager."
|
||||
|
||||
Reference in New Issue
Block a user