villebro commented on a change in pull request #8138: [typing] add typing for 
superset/connectors and superset/common
URL: 
https://github.com/apache/incubator-superset/pull/8138#discussion_r321412898
 
 

 ##########
 File path: superset/connectors/base/models.py
 ##########
 @@ -239,47 +239,47 @@ def external_metadata(self):
         """Returns column information from the external system"""
         raise NotImplementedError()
 
-    def get_query_str(self, query_obj):
+    def get_query_str(self, query_obj) -> str:
         """Returns a query as a string
 
         This is used to be displayed to the user so that she/he can
         understand what is taking place behind the scene"""
         raise NotImplementedError()
 
-    def query(self, query_obj):
+    def query(self, query_obj) -> QueryResult:
         """Executes the query and returns a dataframe
 
         query_obj is a dictionary representing Superset's query interface.
         Should return a ``superset.models.helpers.QueryResult``
         """
         raise NotImplementedError()
 
-    def values_for_column(self, column_name, limit=10000):
+    def values_for_column(self, column_name: str, limit: int = 10000) -> List:
         """Given a column, returns an iterable of distinct values
 
         This is used to populate the dropdown showing a list of
         values in filters in the explore view"""
         raise NotImplementedError()
 
     @staticmethod
-    def default_query(qry):
+    def default_query(qry) -> Query:
         return qry
 
-    def get_column(self, column_name):
+    def get_column(self, column_name: str) -> Optional["BaseColumn"]:
         for col in self.columns:
             if col.column_name == column_name:
                 return col
+        return None
 
     def get_fk_many_from_list(self, object_list, fkmany, fkmany_class, 
key_attr):
         """Update ORM one-to-many list from object list
 
         Used for syncing metrics and columns using the same code"""
 
         object_dict = {o.get(key_attr): o for o in object_list}
-        object_keys = [o.get(key_attr) for o in object_list]
 
         # delete fks that have been removed
-        fkmany = [o for o in fkmany if getattr(o, key_attr) in object_keys]
+        fkmany = [o for o in fkmany if getattr(o, key_attr) in object_dict]
 
 Review comment:
   👍 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to