Python: Make isNewType more precise

For module-level metaclass declarations, we now also check that the
right hand side in a `__metaclass__ = type` assignment is in fact the
built-in `type`.
This commit is contained in:
Taus
2026-03-23 15:22:24 +00:00
parent a276f721f7
commit 93e35661e6

View File

@@ -2108,7 +2108,8 @@ module DuckTyping {
// Module-level __metaclass__ = type makes all classes in the module new-style
exists(Assign a |
a.getScope() = cls.getEnclosingModule() and
a.getATarget().(Name).getId() = "__metaclass__"
a.getATarget().(Name).getId() = "__metaclass__" and
a.getValue() = API::builtin("type").getAValueReachableFromSource().asExpr()
)
)
}