Skip to content

Commit 2823344

Browse files
committed
chore: compliance with python nomenclature
1 parent 48dacc8 commit 2823344

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

app/pages/company/company.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Union
2+
13
import numpy as np
24
import pandas as pd
35
from taipy.gui import Markdown, State, get_state_id
@@ -13,19 +15,19 @@
1315
# Init bindings (used in md file)
1416
selected_company = DEFAULT_COMPANY
1517
selector_company: list[str] = []
16-
selected_year: str = None
18+
selected_year: Union[str, None] = None
1719
selector_year: list[str] = []
18-
company_sector: str = None
20+
company_sector: Union[str, None] = None
1921
company_upe_name: str = ""
2022

21-
df_selected_company: pd.DataFrame = None
22-
df_count_company: pd.DataFrame = None
23+
df_selected_company: Union[pd.DataFrame, None] = None
24+
df_count_company: Union[pd.DataFrame, None] = None
2325

2426
# Viz store map[viz_id,viz_dict]
2527
# Important for taipy bindings
2628
# Use Viz.init on each page with set of viz_id
2729
viz: dict[str, dict] = Viz.init(
28-
(
30+
{
2931
"company_sector",
3032
"company_upe_name",
3133
"company_nb_reports",
@@ -36,7 +38,7 @@
3638
"fin_jurisdictions_top_revenue",
3739
"fin_pretax_profit_and_employees_rank",
3840
"fin_pretax_profit_and_profit_per_employee",
39-
)
41+
}
4042
)
4143

4244

app/viz.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
from typing import Any, Optional, Union
23

34
import pandas as pd
45
import plotly.graph_objects as go
@@ -10,10 +11,10 @@ def __init__(
1011
self,
1112
id: str,
1213
state: State,
13-
data: pd.DataFrame = None,
14-
fig: go.Figure = None,
15-
title: str = None,
16-
sub_title: str = None,
14+
data: Union[pd.DataFrame, Any] = None,
15+
fig: Optional[go.Figure] = None,
16+
title: Optional[str] = None,
17+
sub_title: Optional[str] = None,
1718
):
1819
self.id = id
1920
self.state = state
@@ -36,21 +37,29 @@ def _on_download(self):
3637
buffer.write(self.sub_title + "\n" + str(data))
3738
download(self.state, content=bytes(buffer.getvalue(), "UTF-8"), name="data.csv")
3839

39-
def _to_state(self) -> dict[str]:
40+
def _to_state(self) -> dict[str, Any]:
4041
return {
41-
"data": None if self is None else self.data,
42-
"fig": None if self is None else self.fig,
43-
"title": None if self is None else self.title,
44-
"sub_title": None if self is None else self.sub_title,
45-
"on_action": None if self is None else self.on_action,
42+
"data": self.data,
43+
"fig": self.fig,
44+
"title": self.title,
45+
"sub_title": self.sub_title,
46+
"on_action": self.on_action,
4647
}
4748

48-
def to_state(self) -> dict[str]:
49+
def to_state(self) -> dict[str, Any]:
4950
return self._to_state()
5051

51-
def _to_empty() -> dict[str,]:
52-
return Viz._to_state(None)
52+
@staticmethod
53+
def _to_empty() -> dict[str, None]:
54+
return {
55+
"data": None,
56+
"fig": None,
57+
"title": None,
58+
"sub_title": None,
59+
"on_action": None,
60+
}
5361

62+
@staticmethod
5463
def init(viz_set: set[str]) -> dict[str, dict]:
5564
viz: dict[str, dict] = {}
5665
for viz_id in viz_set:

0 commit comments

Comments
 (0)