Skip to content

Commit

Permalink
refactor: move default imports to a constant (#152)
Browse files Browse the repository at this point in the history
Preparatory commit for testing of exported code being able to execute
(#8).
  • Loading branch information
mbelak-dtml authored Oct 1, 2023
1 parent 4618718 commit 490ad2e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions edvart/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import pickle
from abc import ABC
from copy import copy
from typing import List, Optional, Tuple, Union

import isort
Expand Down Expand Up @@ -37,6 +38,14 @@ class ReportBase(ABC):
The default verbosity for the exported code of the entire report, by default Verbosity.LOW.
"""

_DEFAULT_IMPORTS = {
"import pandas as pd",
"import os",
"from typing import Any, Callable, Dict, List, Optional, Tuple, Union",
"import plotly.offline as py",
"import plotly.io as pio",
}

def __init__(
self,
dataframe: pd.DataFrame,
Expand Down Expand Up @@ -119,13 +128,7 @@ def _generate_notebook(
)

# Add imports cell
imports_set = {
"import pandas as pd",
"import os",
"from typing import Any, Callable, Dict, List, Optional, Tuple, Union",
"import plotly.offline as py",
"import plotly.io as pio",
}
imports_set = copy(self._DEFAULT_IMPORTS)
if extra_imports is not None:
imports_set.update(extra_imports)
for section in self.sections:
Expand Down

0 comments on commit 490ad2e

Please sign in to comment.