Python: Also capture alias with new name

This commit is contained in:
Rasmus Wriedt Larsen
2023-09-28 15:36:28 +02:00
parent e7d55736b0
commit f19b672656
3 changed files with 8 additions and 3 deletions

View File

@@ -190,11 +190,12 @@ module NotExposed {
string relevantName, Location loc string relevantName, Location loc
) { ) {
loc = mod.getLocation() and loc = mod.getLocation() and
exists(API::Node relevantClass, ClassExpr classExpr | exists(API::Node relevantClass, Expr value |
relevantClass = newOrExistingModeling(spec).getASubclass*() and relevantClass = newOrExistingModeling(spec).getASubclass*() and
ImportResolution::module_export(mod, relevantName, def) and ImportResolution::module_export(mod, relevantName, def) and
classExpr = relevantClass.asSource().asExpr() and value = relevantClass.getAValueReachableFromSource().asExpr() and
classExpr = def.asVar().getDefinition().(AssignmentDefinition).getValue().getNode() value = def.asVar().getDefinition().(AssignmentDefinition).getValue().getNode()
// value could be a ClassExpr if a new class is defined, or a Name if defining an alias
) and ) and
( (
mod.isPackageInit() and mod.isPackageInit() and

View File

@@ -1,3 +1,4 @@
| flask.View~Subclass | find_subclass_test | Member[A] | | flask.View~Subclass | find_subclass_test | Member[A] |
| flask.View~Subclass | find_subclass_test | Member[B] | | flask.View~Subclass | find_subclass_test | Member[B] |
| flask.View~Subclass | find_subclass_test | Member[ViewAlias] |
| flask.View~Subclass | find_subclass_test | Member[View] | | flask.View~Subclass | find_subclass_test | Member[View] |

View File

@@ -5,3 +5,6 @@ class A(View):
class B(A): class B(A):
pass pass
ViewAlias = View