From a956e1f61326bb4efc3956bf027efcf48ac128aa Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Fri, 20 Oct 2023 11:01:15 +0200 Subject: [PATCH] Python: Use django View instead of MethodView Due to the 'only model most specific spec' logic highlighted in previous commit, I'm changing away from MethodView/View, and use Django view instead. In practice this shouldn't matter at all, but for writing tests it would have been a nice fix to only have the "same name but more specific" logic apply when it's the same _definition_ location. We used to have this information available, but right now we don't... so instead of spending a lot of time rewriting the core library, I simply used a different class :D :O :( --- .../experimental/library-tests/FindSubclass/Find.expected | 5 +++-- .../library-tests/FindSubclass/find_subclass_test.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/python/ql/test/experimental/library-tests/FindSubclass/Find.expected b/python/ql/test/experimental/library-tests/FindSubclass/Find.expected index 1d12a2e2d9d..d3dd48ea333 100644 --- a/python/ql/test/experimental/library-tests/FindSubclass/Find.expected +++ b/python/ql/test/experimental/library-tests/FindSubclass/Find.expected @@ -1,6 +1,6 @@ +| Django.Views.View~Subclass | find_subclass_test | Member[View] | +| Django.Views.View~Subclass | find_subclass_test | Member[clash] | | flask.MethodView~Subclass | find_subclass_test | Member[C] | -| flask.MethodView~Subclass | find_subclass_test | Member[MethodView] | -| flask.MethodView~Subclass | find_subclass_test | Member[clash] | | flask.View~Subclass | find_subclass_test | Member[A] | | flask.View~Subclass | find_subclass_test | Member[B] | | flask.View~Subclass | find_subclass_test | Member[ViewAliasInExcept] | @@ -8,4 +8,5 @@ | flask.View~Subclass | find_subclass_test | Member[ViewAlias] | | flask.View~Subclass | find_subclass_test | Member[View] | | flask.View~Subclass | find_subclass_test | Member[clash3] | +| flask.View~Subclass | find_subclass_test | Member[clash] | | flask.View~Subclass | find_subclass_test | Member[complete_module_alias] | diff --git a/python/ql/test/experimental/library-tests/FindSubclass/find_subclass_test.py b/python/ql/test/experimental/library-tests/FindSubclass/find_subclass_test.py index d0f0048338f..0e63accd209 100644 --- a/python/ql/test/experimental/library-tests/FindSubclass/find_subclass_test.py +++ b/python/ql/test/experimental/library-tests/FindSubclass/find_subclass_test.py @@ -19,20 +19,20 @@ except: if cond: - from flask.views import View as clash # $ MISSING + from flask.views import View as clash else: - from flask.views import MethodView as clash # $ SPURIOUS: MethodView + from django.views.generic import View as clash # $ SPURIOUS: View=Django.Views.View~Subclass if cond: from flask.views import View as clash2 # $ MISSING else: - from flask.views import MethodView as clash2 # $ MISSING + from django.views.generic import View as clash2 # $ MISSING print(clash2) if cond: from flask.views import View as clash3 else: - from flask.views import MethodView as clash3 # $ MISSING + from django.views.generic import View as clash3 # $ MISSING print(clash3) import flask.views as containing_module_alias # $ MISSING