Skip to content

Commit 0686caf

Browse files
committed
Deprecate arguments with deprecation decorators instead of warnings
1 parent fca11cc commit 0686caf

2 files changed

Lines changed: 8 additions & 48 deletions

File tree

astroquery/esasky/__init__.py

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from astropy import config as _config
55
from astropy.config import paths
66
from astropy.utils.exceptions import AstropyDeprecationWarning
7+
from astropy.utils.decorators import deprecated_attribute
78

89
import os
910

@@ -32,47 +33,9 @@ class Conf(_config.ConfigNamespace):
3233
ESASKY_ROW_LIMIT = _config.ConfigItem(10000, 'Maximum number of rows returned (set to -1 for unlimited).',
3334
aliases=['astroquery.esasky.row_limit'])
3435

35-
@property
36-
def urlBase(self):
37-
return self.ESASKY_DOMAIN_SERVER
38-
39-
@urlBase.setter
40-
def urlBase(self, value):
41-
warnings.warn(
42-
"'urlBase' is deprecated and will be removed in a future version. "
43-
"Use 'ESASKY_DOMAIN_SERVER' instead.",
44-
AstropyDeprecationWarning,
45-
stacklevel=2,
46-
)
47-
self.ESASKY_DOMAIN_SERVER = value
48-
49-
@property
50-
def timeout(self):
51-
return self.ESASKY_CONNECTION_TIMEOUT
52-
53-
@timeout.setter
54-
def timeout(self, value):
55-
warnings.warn(
56-
"'timeout' is deprecated and will be removed in a future version. "
57-
"Use 'ESASKY_CONNECTION_TIMEOUT' instead.",
58-
AstropyDeprecationWarning,
59-
stacklevel=2,
60-
)
61-
self.ESASKY_CONNECTION_TIMEOUT = value
62-
63-
@property
64-
def row_limit(self):
65-
return self.ESASKY_ROW_LIMIT
66-
67-
@row_limit.setter
68-
def row_limit(self, value):
69-
warnings.warn(
70-
"'row_limit' is deprecated and will be removed in a future version. "
71-
"Use 'ESASKY_ROW_LIMIT' instead.",
72-
AstropyDeprecationWarning,
73-
stacklevel=2,
74-
)
75-
self.ESASKY_ROW_LIMIT = value
36+
urlBase = deprecated_attribute(name='urlBase', alternative='ESASKY_DOMAIN_SERVER', since='8.0')
37+
timeout = deprecated_attribute(name='timeout', alternative='ESASKY_CONNECTION_TIMEOUT', since='8.0')
38+
row_limit = deprecated_attribute(name='row_limit', alternative='ESASKY_ROW_LIMIT', since='8.0')
7639

7740
cache_location = os.path.join(paths.get_cache_dir(), 'astroquery/esasky', )
7841

astroquery/esasky/core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from . import conf
2626
from .. import version
2727
from astropy.coordinates.name_resolve import sesame_database
28+
from astropy.utils import deprecated_renamed_argument
2829

2930

3031
# We do trust the ESA tar files, this is to avoid the new to Python 3.12 deprecation warning
@@ -82,15 +83,11 @@ class ESASkyClass(EsaTap):
8283
SSO_TYPES = ['ALL', 'ASTEROID', 'COMET', 'SATELLITE', 'PLANET',
8384
'DWARF_PLANET', 'SPACECRAFT', 'SPACEJUNK', 'EXOPLANET', 'STAR']
8485

86+
@deprecated_renamed_argument('tap_handler', None, since='8.0', message="The 'tap_handler' parameter is deprecated"
87+
"and will be removed in a future version. Use the ESASky instance directly for TAP"
88+
"queries (Using esa.utils.EsaTap and PyVO).")
8589
def __init__(self, *, tap_handler=None, show_messages=False, auth_session=None, tap_url=None):
8690
super().__init__(auth_session=auth_session, tap_url=tap_url)
87-
if tap_handler is not None:
88-
warnings.warn(
89-
"The 'tap_handler' parameter is deprecated and will be removed in a future version. "
90-
"Use the ESASky instance directly for TAP queries (Using esa.utils.EsaTap and PyVO).",
91-
AstropyDeprecationWarning,
92-
stacklevel=2,
93-
)
9491

9592
if show_messages:
9693
self.get_status_messages()

0 commit comments

Comments
 (0)