Skip to content

Commit

Permalink
Fix type and format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gouline committed Mar 4, 2024
1 parent 83bb85f commit fcf91cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions dbtmetabase/_exposures.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ def extract_exposures(

entity: Mapping
if item["model"] == "card":
entity = self.metabase.find_card(uid=item["id"])
if entity is None:
card_entity = self.metabase.find_card(uid=item["id"])
if card_entity is None:
_logger.info("Card '%s' not found, skipping", item["id"])
continue

entity = card_entity
header = (
f"Visualization: {entity.get('display', 'Unknown').title()}"
)
Expand All @@ -109,11 +110,12 @@ def extract_exposures(
native_query = result["native_query"]

elif item["model"] == "dashboard":
entity = self.metabase.find_dashboard(uid=item["id"])
if entity is None:
dashboard_entity = self.metabase.find_dashboard(uid=item["id"])
if dashboard_entity is None:
_logger.info("Dashboard '%s' not found, skipping", item["id"])
continue

entity = dashboard_entity
cards = entity.get("ordered_cards", [])
if not cards:
continue
Expand Down Expand Up @@ -185,7 +187,7 @@ def extract_exposures(
def __extract_card_exposures(
self,
ctx: __Context,
card: Mapping,
card: Optional[Mapping],
) -> Mapping:
"""Extracts exposures from Metabase questions."""

Expand Down
8 changes: 4 additions & 4 deletions dbtmetabase/metabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ def find_dashboard(self, uid: str) -> Optional[Mapping]:
return None
raise

def format_dashboard_url(self, uid: str) -> str:
"""Formats URL link to a dashboard."""
return f"{self.url}/dashboard/{uid}"

def find_user(self, uid: str) -> Optional[Mapping]:
"""Finds user by ID or returns none."""
try:
Expand All @@ -181,6 +177,10 @@ def find_user(self, uid: str) -> Optional[Mapping]:
return None
raise

def format_dashboard_url(self, uid: str) -> str:
"""Formats URL link to a dashboard."""
return f"{self.url}/dashboard/{uid}"

def update_table(self, uid: str, body: Mapping) -> Mapping:
"""Posts update to an existing table."""
return dict(self._api("put", f"/api/table/{uid}", json=body))
Expand Down

0 comments on commit fcf91cf

Please sign in to comment.