Skip to content

Commit

Permalink
Workaround astroid/pylint bug (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Dec 23, 2021
1 parent 91cdd14 commit 32b7352
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[MASTER]

# As a temporary workaround for https://github.com/PyCQA/pylint/issues/4577
init-hook = "import astroid; astroid.context.InferenceContext.max_inferred = 500"

[MESSAGES CONTROL]

disable = bad-continuation, missing-docstring, duplicate-code, logging-fstring-interpolation, unspecified-encoding
Expand Down
17 changes: 11 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from webviz_config.common_cache import CACHE
from webviz_config.themes import default_theme
from webviz_config.webviz_factory_registry import WEBVIZ_FACTORY_REGISTRY
from webviz_config.webviz_instance_info import WebvizInstanceInfo, WebvizRunMode
from webviz_config.webviz_instance_info import WEBVIZ_INSTANCE_INFO, WebvizRunMode


def pytest_addoption(parser: Parser) -> None:
Expand All @@ -28,14 +28,19 @@ def testdata_folder_fixture(request: SubRequest) -> Any:

@pytest.fixture()
def app() -> dash.Dash:
run_mode = WebvizRunMode.NON_PORTABLE
storage_folder = pathlib.Path(__file__).resolve().parent
app_instance_info = WebvizInstanceInfo(run_mode, storage_folder)
dash_app = dash.Dash(__name__)

WEBVIZ_INSTANCE_INFO.initialize(
dash_app=dash_app,
run_mode=WebvizRunMode.NON_PORTABLE,
theme=default_theme,
storage_folder=pathlib.Path(__file__).resolve().parent,
)
try:
WEBVIZ_FACTORY_REGISTRY.initialize(app_instance_info, None)
WEBVIZ_FACTORY_REGISTRY.initialize(None)
except RuntimeError:
pass
dash_app = dash.Dash(__name__)

dash_app.css.config.serve_locally = True
dash_app.scripts.config.serve_locally = True
dash_app.config.suppress_callback_exceptions = True
Expand Down
15 changes: 2 additions & 13 deletions webviz_subsurface/_private_plugins/surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,7 @@ def _update_date(
elif callback == f"{self.date_id_btn_next}.n_clicks":
value = next_value(current_value, dates)
else:
value = (
current_value
if current_value
in dates # pylint: disable=unsupported-membership-test
else dates[0] # pylint: disable=unsubscriptable-object
)
# pylint: disable=not-an-iterable
value = current_value if current_value in dates else dates[0]
options = [{"label": format_date(date), "value": date} for date in dates]
return options, value, {}

Expand Down Expand Up @@ -331,12 +325,7 @@ def _set_data(

dates_in_attr = self._dates_in_attr(attr)

if (
dates_in_attr
and date
and not date
in dates_in_attr # PyCQA/pylint#3045 # pylint: disable=unsupported-membership-test
):
if dates_in_attr and date and not date in dates_in_attr:
raise PreventUpdate
return json.dumps({"name": name, "attribute": attr, "date": date})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ def load_ensemble_summary_csv_file(
df: pd.DataFrame = pd.read_csv(csv_file)

if ensemble_filter is not None:
if not "ENSEMBLE" in df.columns:
if "ENSEMBLE" not in df.columns:
raise ValueError(
"Cannot filter on ensemble, no ENSEMBLE column exist in CSV file"
)

# pylint: disable=unsubscriptable-object
df = df[df["ENSEMBLE"] == ensemble_filter]

if "ENSEMBLE" in df.columns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def create_from_ensemble_csv_file(

if len(ensemble_df) == 0:
raise ValueError("Import resulted in empty DataFrame")
if not "DATE" in ensemble_df.columns:
if "DATE" not in ensemble_df.columns:
raise ValueError("No DATE column present in input data")
if not "REAL" in ensemble_df.columns: # pylint: disable=no-member
if "REAL" not in ensemble_df.columns:
raise ValueError("No REAL column present in input data")

ProviderImplArrowPresampled.write_backing_store_from_ensemble_dataframe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,7 @@ def _generatetable(choiceplot, max_rows=10):
get_path(self.input_dir / "misfit_obs_info.csv"), index_col=0
)
list_ok = list(misfit_info.filter(like="All_obs", axis=1).columns)
listtoplot = [
ele
for ele in misfit_info.columns # PyCQA/pylint#4577 # pylint: disable=no-member
if ele not in list_ok
]
listtoplot = [ele for ele in misfit_info.columns if ele not in list_ok]
if choiceplot == "ALL":
listtoplot = list_ok
active_info = read_csv(
Expand Down
12 changes: 2 additions & 10 deletions webviz_subsurface/plugins/_disk_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,9 @@ def get_disk_usage(scratch_dir: Path, date: Optional[str]) -> pd.DataFrame:
columns={"usageKB": "usageKiB"}, inplace=True
) # Old format had an error (KB instead of KiB)

df[ # PyCQA/pylint#4577 # pylint: disable=unsupported-assignment-operation
"usageGiB"
] = df[ # PyCQA/pylint#4577 # pylint: disable=unsubscriptable-object
"usageKiB"
] / (
1024 ** 2
)
df["usageGiB"] = df["usageKiB"] / (1024 ** 2)

df.drop( # PyCQA/pylint#4577 # pylint: disable=no-member
columns="usageKiB", inplace=True
)
df.drop(columns="usageKiB", inplace=True)

free_space_gib = _estimate_free_space(df, scratch_dir, date)
if free_space_gib < 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ def update_wellpoints_df(self, column_list: List[str]) -> pd.DataFrame:
for col in column_list:
if colm == col:
sorted_list.append(col)
return df[ # PyCQA/pylint#4577 # pylint: disable=unsubscriptable-object
sorted_list
].round(2)
return df[sorted_list].round(2)
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ def __init__(
c
for c in self.smry.columns
if c not in ReservoirSimulationTimeSeriesOneByOne.ENSEMBLE_COLUMNS
and historical_vector(c, self.smry_meta, False)
not in self.smry.columns # PyCQA/pylint#4577 # pylint: disable=no-member
and historical_vector(c, self.smry_meta, False) not in self.smry.columns
]
self.initial_vector = (
initial_vector
Expand Down

0 comments on commit 32b7352

Please sign in to comment.