Skip to content

Commit 6a0311c

Browse files
committed
fix: add deprecation warning in io module
1 parent 57b49d2 commit 6a0311c

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/essdiffraction/src/ess/beer/io.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33

44
"""Backward-compatible import location for BEER McStas helpers."""
55

6+
import warnings
7+
68
from . import mcstas as _mcstas
79
from .mcstas import * # noqa: F403
810
from .mcstas import __all__ # noqa: F401
911

12+
warnings.warn(
13+
"ess.beer.io is deprecated; use ess.beer.mcstas instead.",
14+
DeprecationWarning,
15+
stacklevel=2,
16+
)
17+
1018

1119
def __getattr__(name: str):
1220
"""Return attributes from the replacement :mod:`ess.beer.mcstas` module."""

packages/essdiffraction/tests/beer/mcstas_reduction_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import importlib
2+
import sys
3+
14
import numpy as np
25
import pytest
36
import scipp as sc
@@ -162,9 +165,12 @@ def test_can_load_monitor():
162165

163166

164167
def test_io_module_reexports_mcstas_loaders():
165-
from ess.beer.io import load_beer_mcstas as load_beer_mcstas_from_io
168+
sys.modules.pop('ess.beer.io', None)
169+
170+
with pytest.warns(DeprecationWarning, match='ess.beer.io'):
171+
io = importlib.import_module('ess.beer.io')
166172

167-
assert load_beer_mcstas_from_io is load_beer_mcstas
173+
assert io.load_beer_mcstas is load_beer_mcstas
168174

169175

170176
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)