Skip to content

Commit d9c1ae0

Browse files
committed
Improve handling of DeprecationWarnings
1 parent f3191a6 commit d9c1ae0

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

scopesim/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@
1414

1515

1616
###############################################################################
17-
# TURN OFF WARNINGS #
17+
# TURN OFF SOME WARNINGS #
1818
###############################################################################
1919

2020
import warnings
2121
import yaml
2222
from astropy.utils.exceptions import AstropyWarning
2323

2424
warnings.simplefilter('ignore', UserWarning)
25-
warnings.simplefilter('ignore', FutureWarning)
2625
warnings.simplefilter('ignore', RuntimeWarning) # warnings for the developer
27-
warnings.simplefilter('default', DeprecationWarning) # allow in general
26+
27+
try:
28+
if __version__.is_prerelease or __version__.is_devrelease:
29+
# Those are usually ignored, but in development we should see them.
30+
warnings.simplefilter("default", DeprecationWarning)
31+
warnings.simplefilter("default", PendingDeprecationWarning)
32+
except AttributeError: # catch __version__ = "undetermined"
33+
pass
34+
2835
warnings.simplefilter('ignore', category=AstropyWarning)
2936
yaml.warnings({'YAMLLoadWarning': False})
3037

scopesim/effects/data_container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(
8585

8686
if filename is None and "file_name" in kwargs:
8787
warn("The 'file_name' kwarg is deprecated and will raise an error "
88-
"in the future, please use 'filename' instead!",
88+
"from version 0.12 onwards, please use 'filename' instead!",
8989
DeprecationWarning, stacklevel=2)
9090
filename = kwargs["file_name"]
9191

scopesim/effects/psfs/semianalytical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def remake_kernel(self, x):
141141
"will be removed in a future release. If you are using this "
142142
"method, pleas let us know by creating an issue at: "
143143
"https://github.com/AstarVienna/ScopeSim/issues",
144-
DeprecationWarning, stacklevel=2)
144+
FutureWarning, stacklevel=2)
145145
self._kernel = None
146146
return self.get_kernel(x)
147147

scopesim/optics/image_plane.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def add(self, hdus_or_tables, sub_pixel=None, spline_order=None,
134134
else:
135135
if isinstance(hdus_or_tables, Table):
136136
warn("Adding a table directly to the ImagePlane is deprecated "
137-
"since v0.10.0. Passing a table "
138-
"to ImagePlane.add() will raise an error in the future. "
139-
"Use FOV to add tables and image HDUs together before.",
137+
"since v0.10.0. Passing a table to ImagePlane.add() will "
138+
"raise an error from version 0.12 onwards. Use FOV to "
139+
"add tables and image HDUs together before.",
140140
DeprecationWarning, stacklevel=2)
141141
self.hdu = add_table_to_imagehdu(hdus_or_tables, self.hdu,
142142
sub_pixel, wcs_suffix)

0 commit comments

Comments
 (0)