Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move default imports to a constant #152

Merged
merged 2 commits into from
Oct 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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