Skip to content

Commit

Permalink
Remove 3.9 uncompatible or typehint with None
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jsummer committed Oct 22, 2024
1 parent 2706531 commit 01bf6ff
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions app_utils/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from enum import Enum
from io import StringIO
from typing import Any, Optional, List
from typing import Any, Optional, List, Union

import pandas as pd
import streamlit as st
Expand Down Expand Up @@ -200,7 +200,7 @@ def get_available_stages(schema: str) -> List[str]:
return fetch_stages_in_schema(get_snowflake_connection(), schema)


def stage_selector_container() -> None | List[str]:
def stage_selector_container() -> Optional[List[str]]:
"""
Common component that encapsulates db/schema/stage selection for the admin app.
When a db/schema/stage is selected, it is saved to the session state for reading elsewhere.
Expand Down Expand Up @@ -1247,23 +1247,23 @@ class AppMetadata:
"""

@property
def user(self) -> str | None:
def user(self) -> Optional[str]:
return os.getenv("SNOWFLAKE_USER")

@property
def stage(self) -> str | None:
def stage(self) -> Optional[str]:
if stage_exists():
stage = st.session_state.snowflake_stage
return f"{stage.stage_database}.{stage.stage_schema}.{stage.stage_name}"
return None

@property
def model(self) -> str | None:
def model(self) -> Optional[str]:
if semantic_model_exists():
return st.session_state.semantic_model.name # type: ignore
return None

def to_dict(self) -> dict[str, str | None]:
def to_dict(self) -> dict[str, Union[str,None]]:
return {
"User": self.user,
"Stage": self.stage,
Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: sf_env
channels:
- snowflake
dependencies:
- python=3.10.*
- pandas=2.2.2
- python=3.8.*
- pandas=2.0.3
- tqdm=4.66.5
- streamlit=1.35.0
- loguru=0.5.3
Expand All @@ -13,7 +13,7 @@ dependencies:
- ruamel.yaml=0.17.21
- pyarrow=14.0.2
- sqlglot=25.10.0
- numpy=1.26.4
- numpy=1.24.3
- python-dotenv=0.21.0
- urllib3=2.2.2
- requests=2.32.3
Expand Down
14 changes: 7 additions & 7 deletions partner/cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def __init__(self, data: dict[str, Any]):

self.data: dict[str, Any] = data
self.name: str = data["name"]
self.synonyms: None | list[str] = data.get("synonyms", None)
self.synonyms: Optional[list[str]] = data.get("synonyms", None)
self.data_type: str = data.get("data_type", "TEXT")
self.expr: str = data["expr"]
self.description: None | str = data.get("description", None)
self.sample_values: None | list[str] = data.get("sample_values", None)
self.description: Optional[str] = data.get("description", None)
self.sample_values: Optional[list[str]] = data.get("sample_values", None)
self.unique: bool = data.get("unique", False)

def get_name(self) -> str:
Expand Down Expand Up @@ -90,13 +90,13 @@ class CortexSemanticTable:
def __init__(self, data: dict[str, Any]):
self.data: dict[str, Any] = data
self.name: str = data["name"]
self.description: None | str = data["description"]
self.description: Optional[str] = data["description"]
self.base_table_db: str = data["base_table"]["database"]
self.base_table_schema: str = data["base_table"]["schema"]
self.base_table_table: str = data["base_table"]["table"]
self.dimensions: None | list[dict[str, Any]] = data["dimensions"]
self.time_dimensions: None | list[dict[str, Any]] = data["time_dimensions"]
self.measures: None | list[dict[str, Any]] = data["measures"]
self.dimensions: Optional[list[dict[str, Any]]] = data["dimensions"]
self.time_dimensions: Optional[list[dict[str, Any]]] = data["time_dimensions"]
self.measures: Optional[list[dict[str, Any]]] = data["measures"]

def get_data(self) -> dict[str, Any]:
return self.data
Expand Down
16 changes: 8 additions & 8 deletions partner/dbt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any, Optional, Union

import pandas as pd
import streamlit as st
Expand Down Expand Up @@ -80,7 +80,7 @@ def upload_dbt_semantic() -> None:
key="dbt_files",
)
if uploaded_files:
partner_semantic: list[None | DBTSemanticModel] = []
partner_semantic: list[Union[None,DBTSemanticModel]] = []
for file in uploaded_files:
partner_semantic.extend(read_dbt_yaml(file)) # type: ignore

Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(self, entity: dict[str, Any]):
self.name: str = entity["name"]
self.type: str = entity.get("type", None)
self.expr: str = entity.get("expr", self.name)
self.description: None | str = entity.get("description", None)
self.description: Optional[str] = entity.get("description", None)
self.cortex_map = {
"name": self.name,
"description": self.description,
Expand Down Expand Up @@ -153,7 +153,7 @@ class DBTMeasure(DBTEntity):

def __init__(self, entity: dict[str, Any]):
super().__init__(entity)
self.agg: None | str = entity.get("agg", None)
self.agg: Optional[str] = entity.get("agg", None)
self.cortex_map = {
"name": self.name,
"description": self.description,
Expand Down Expand Up @@ -195,10 +195,10 @@ class DBTSemanticModel:
def __init__(self, data: dict[str, Any]):
self.data: dict[str, Any] = data
self.name: str = data["name"]
self.description: None | str = data.get("description", None)
self.entities: None | list[dict[str, Any]] = data["entities"]
self.dimensions: None | list[dict[str, Any]] = data["dimensions"]
self.measures: None | list[dict[str, Any]] = data["measures"]
self.description: Optional[str] = data.get("description", None)
self.entities: Optional[list[dict[str, Any]]] = data["entities"]
self.dimensions: Optional[list[dict[str, Any]]] = data["dimensions"]
self.measures: Optional[list[dict[str, Any]]] = data["measures"]

def get_data(self) -> dict[str, Any]:
return self.data
Expand Down
4 changes: 2 additions & 2 deletions partner/looker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Any, Optional
from typing import Any, Optional, Union

import pandas as pd
import streamlit as st
Expand Down Expand Up @@ -523,7 +523,7 @@ def render_looker_explore_as_table(
target_lag: Optional[int] = 20,
target_lag_unit: Optional[str] = "minutes",
warehouse: Optional[str] = None,
) -> None | dict[str, dict[str, str]]:
) -> Union[None,dict[str, dict[str, str]]]:
"""
Creates materialized table corresponding to Looker Explore.
Args:
Expand Down
2 changes: 1 addition & 1 deletion partner/partner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, row_data: pd.Series) -> None: # type: ignore
else {}
)

def render_row(self) -> None | dict[str, Any]: # type: ignore
def render_row(self) -> Union[None, dict[str, Any]]: # type: ignore
toggle_options = ["merged", "cortex", "partner", "remove"]
metadata = {}

Expand Down

0 comments on commit 01bf6ff

Please sign in to comment.