Skip to content

Commit

Permalink
chore(mypy): Fixing can_access_database types (apache#10119)
Browse files Browse the repository at this point in the history
Co-authored-by: John Bodley <john.bodley@airbnb.com>
  • Loading branch information
2 people authored and auxten committed Nov 20, 2020
1 parent 614352d commit 6c544d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion superset/security/manager.py
Expand Up @@ -50,6 +50,7 @@
if TYPE_CHECKING:
from superset.common.query_context import QueryContext
from superset.connectors.base.models import BaseDatasource
from superset.connectors.druid.models import DruidCluster
from superset.models.core import Database
from superset.sql_parse import Table
from superset.viz import BaseViz
Expand Down Expand Up @@ -230,13 +231,16 @@ def can_access_all_databases(self) -> bool:

return self.can_access("all_database_access", "all_database_access")

def can_access_database(self, database: "Database") -> bool:
def can_access_database(self, database: Union["Database", "DruidCluster"]) -> bool:
"""
Return True if the user can access the Superset database, False otherwise.
Note for Druid the database is akin to the Druid cluster.
:param database: The Superset database
:returns: Whether the user can access the Superset database
"""

return (
self.can_access_all_datasources()
or self.can_access_all_databases()
Expand Down

0 comments on commit 6c544d2

Please sign in to comment.