Python: Port ShouldBeContextManager.ql

Only trivial test changes.
This commit is contained in:
Taus
2026-02-20 16:54:49 +00:00
parent 025a7d0cca
commit 283231bdbc
2 changed files with 7 additions and 5 deletions

View File

@@ -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."