Skip to content

Commit c293417

Browse files
authored
Merge pull request #2661 from nkphysics/kwargs-keyword-only
Refactor: Make kwargs keyword only
2 parents 0a67245 + 0c9e965 commit c293417

File tree

60 files changed

+307
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+307
-302
lines changed

CHANGES.rst

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ esa.hubble
2121

2222
- Update to TAP url to query data and download files, aligned with the new eHST Science Archive. [#2567][#2597]
2323
- Status and maintenance messages from eHST TAP when the module is instantiated. get_status_messages method to retrieve them. [#2597]
24-
- Optional parameters in all methods are kwargs keyword only. [#2597]
2524

2625
solarsystem.neodys
2726
^^^^^^^^^^^^^^^^^^
@@ -114,8 +113,6 @@ jplhorizons
114113
- Adding ``optional_setting`` kwarg to the ephemerides methods to allow
115114
passing additional settings. [#1802]
116115

117-
- Optional keyword arguments are now keyword only. [#1802]
118-
119116
- Topocentric coordinates can now be specified for both center and target in observer
120117
and vector queries. [#2625]
121118

@@ -145,16 +142,6 @@ mast
145142
- Expanding ``Cutouts`` functionality to support making Hubble Advanced Product (HAP)
146143
cutouts via HAPCut. [#2613]
147144

148-
nist
149-
^^^^
150-
151-
- Optional parameters in all methods are kwargs keyword only. [#2655]
152-
153-
nvas
154-
^^^^
155-
156-
- Made NVAS optional kwargs keyword only. [#2656]
157-
158145
oac
159146
^^^
160147

@@ -173,7 +160,7 @@ simbad
173160
- It is now possible to specify multiple coordinates together with a single
174161
radius as a string in ``query_region()`` and ``query_region_async()``.
175162
[#2494]
176-
- Optional keyword arguments are now keyword only. [#2609]
163+
177164
- ``ROW_LIMIT`` is now respected when running region queries; previously, it
178165
was ignored for region queries but respected for all others. A new warning,
179166
``BlankResponseWarning``, is introduced for use when one or more query terms result
@@ -185,8 +172,6 @@ skyview
185172

186173
- Fix bug for ``radius`` parameter to not behave as diameter. [#2601]
187174

188-
- Optional keyword arguments are now keyword only. [#2601]
189-
190175
svo_fps
191176
^^^^^^^
192177

@@ -222,9 +207,6 @@ sdss
222207

223208
- The default data release has been changed to DR17. [#2478]
224209

225-
- Optional keyword arguments are now keyword only. [#2477, #2532]
226-
227-
228210
mast
229211
^^^^
230212

@@ -241,6 +223,9 @@ xmatch
241223
Infrastructure, Utility and Other Changes and Additions
242224
-------------------------------------------------------
243225

226+
- Optional keyword arguments are now keyword only. [#1802, #2477, #2532,
227+
#2597, #2601, #2609, #2655, #2656, #2661]
228+
244229
- New function, ``utils.cleanup_downloads.cleanup_saved_downloads``, is
245230
added to help the testcleanup narrative in narrative documentations. [#2384]
246231

astroquery/alfalfa/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_catalog(self):
8888

8989
return catalog
9090

91-
def query_region(self, coordinates, radius=3. * u.arcmin,
91+
def query_region(self, coordinates, *, radius=3. * u.arcmin,
9292
optical_counterpart=False):
9393
"""
9494
Perform object cross-ID in ALFALFA.

astroquery/astrometry_net/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _validate_settings(self, settings):
198198
raise ValueError('Scale type {} requires '
199199
'values for {}'.format(scale_type, required_keys))
200200

201-
def monitor_submission(self, submission_id,
201+
def monitor_submission(self, submission_id, *,
202202
solve_timeout=TIMEOUT, verbose=True):
203203
"""
204204
Monitor the submission for completion.
@@ -270,7 +270,7 @@ def monitor_submission(self, submission_id,
270270
raise RuntimeError('Unrecognized status {}'.format(status))
271271
return wcs
272272

273-
def solve_from_source_list(self, x, y, image_width, image_height,
273+
def solve_from_source_list(self, x, y, image_width, image_height, *,
274274
solve_timeout=TIMEOUT,
275275
verbose=True,
276276
**settings
@@ -320,7 +320,7 @@ def solve_from_source_list(self, x, y, image_width, image_height,
320320
solve_timeout=solve_timeout,
321321
verbose=verbose)
322322

323-
def solve_from_image(self, image_file_path, force_image_upload=False,
323+
def solve_from_image(self, image_file_path, *, force_image_upload=False,
324324
ra_key=None, dec_key=None,
325325
ra_dec_units=None,
326326
fwhm=3, detect_threshold=5,

astroquery/besancon/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ class BesanconClass(BaseQuery):
8686
# sample file name: 1340900648.230224.resu
8787
result_re = re.compile(r"[0-9]{10}\.[0-9]{6}\.resu")
8888

89-
def __init__(self, email=None):
89+
def __init__(self, *, email=None):
9090
super().__init__()
9191
self.email = email
9292

93-
def get_besancon_model_file(self, filename, verbose=True, timeout=5.0):
93+
def get_besancon_model_file(self, filename, *, verbose=True, timeout=5.0):
9494
"""
9595
Download a Besancon model from the website.
9696
@@ -145,7 +145,7 @@ def get_besancon_model_file(self, filename, verbose=True, timeout=5.0):
145145

146146
return parse_besancon_model_string(results)
147147

148-
def _parse_result(self, response, verbose=False, retrieve_file=True):
148+
def _parse_result(self, response, *, verbose=False, retrieve_file=True):
149149
"""
150150
retrieve_file : bool
151151
If True, will try to retrieve the file every 30s until it shows up.
@@ -174,7 +174,7 @@ def _parse_result(self, response, verbose=False, retrieve_file=True):
174174
else:
175175
return filename
176176

177-
def _parse_args(self, glon, glat, email, smallfield=True, extinction=0.7,
177+
def _parse_args(self, glon, glat, email, *, smallfield=True, extinction=0.7,
178178
area=0.0001, verbose=True, clouds=None,
179179
absmag_limits=(-7, 20), mag_limits=copy.copy(mag_limits),
180180
colors_limits=copy.copy(colors_limits),

astroquery/casda/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _login(self, *, username=None, store_password=False,
9595

9696
return authenticated
9797

98-
def query_region_async(self, coordinates, radius=1*u.arcmin, height=None, width=None,
98+
def query_region_async(self, coordinates, *, radius=1*u.arcmin, height=None, width=None,
9999
get_query_payload=False, cache=True):
100100
"""
101101
Queries a region around the specified coordinates. Either a radius or both a height and a width
@@ -135,7 +135,7 @@ def query_region_async(self, coordinates, radius=1*u.arcmin, height=None, width=
135135

136136
# Create the dict of HTTP request parameters by parsing the user
137137
# entered values.
138-
def _args_to_payload(self, radius=1*u.arcmin, **kwargs):
138+
def _args_to_payload(self, *, radius=1*u.arcmin, **kwargs):
139139
request_payload = dict()
140140

141141
# Convert the coordinates to FK5
@@ -206,7 +206,7 @@ def _args_to_payload(self, radius=1*u.arcmin, **kwargs):
206206
# the methods above implicitly call the private _parse_result method.
207207
# This should parse the raw HTTP response and return it as
208208
# an `astropy.table.Table`.
209-
def _parse_result(self, response, verbose=False):
209+
def _parse_result(self, response, *, verbose=False):
210210
# if verbose is False then suppress any VOTable related warnings
211211
if not verbose:
212212
commons.suppress_vo_warnings()
@@ -284,7 +284,7 @@ def _complete_job(self, job_url, verbose):
284284

285285
return fileurls
286286

287-
def stage_data(self, table, verbose=False):
287+
def stage_data(self, table, *, verbose=False):
288288
"""
289289
Request access to a set of data files. All requests for data must use authentication. If you have access to the
290290
data, the requested files will be brought online and a set of URLs to download the files will be returned.
@@ -367,7 +367,7 @@ def cutout(self, table, *, coordinates=None, radius=1*u.arcmin, height=None,
367367

368368
return self._complete_job(job_url, verbose)
369369

370-
def download_files(self, urls, savedir=''):
370+
def download_files(self, urls, *, savedir=''):
371371
"""
372372
Download a series of files
373373
@@ -445,7 +445,7 @@ def _parse_datalink_for_service_and_id(self, response, service_name):
445445

446446
return async_url, authenticated_id_token
447447

448-
def _create_soda_job(self, authenticated_id_tokens, soda_url=None):
448+
def _create_soda_job(self, authenticated_id_tokens, *, soda_url=None):
449449
"""
450450
Creates the async job, returning the url to query the job status and details
451451
@@ -488,7 +488,7 @@ def _add_cutout_params(self, job_location, verbose, cutout_spec):
488488
resp = self._request('POST', job_location + '/parameters', data=cutout_spec, cache=False)
489489
resp.raise_for_status()
490490

491-
def _run_job(self, job_location, verbose, poll_interval=20):
491+
def _run_job(self, job_location, verbose, *, poll_interval=20):
492492
"""
493493
Start an async job (e.g. TAP or SODA) and wait for it to be completed.
494494

astroquery/cds/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self):
5656
self.path_moc_file = None
5757
self.return_moc = False
5858

59-
def query_region(self, region=None, get_query_payload=False, verbose=False, **kwargs):
59+
def query_region(self, *, region=None, get_query_payload=False, verbose=False, **kwargs):
6060
"""
6161
Query the `CDS MOCServer <http://alasky.unistra.fr/MocServer/query>`_ with a region.
6262
@@ -123,11 +123,11 @@ def query_region(self, region=None, get_query_payload=False, verbose=False, **kw
123123
if get_query_payload:
124124
return response
125125

126-
result = self._parse_result(response, verbose)
126+
result = self._parse_result(response, verbose=verbose)
127127

128128
return result
129129

130-
def find_datasets(self, meta_data, get_query_payload=False, verbose=False, **kwargs):
130+
def find_datasets(self, meta_data, *, get_query_payload=False, verbose=False, **kwargs):
131131
"""
132132
Query the `CDS MOCServer <http://alasky.unistra.fr/MocServer/query>`_ to retrieve the data-sets based on their
133133
meta data values. This method does not need any region argument but it requires an expression on the meta datas.
@@ -179,11 +179,11 @@ def find_datasets(self, meta_data, get_query_payload=False, verbose=False, **kwa
179179
if get_query_payload:
180180
return response
181181

182-
result = self._parse_result(response, verbose)
182+
result = self._parse_result(response, verbose=verbose)
183183

184184
return result
185185

186-
def query_region_async(self, get_query_payload=False, **kwargs):
186+
def query_region_async(self, *, get_query_payload=False, **kwargs):
187187
"""
188188
Serves the same purpose as :meth:`~astroquery.cds.CdsClass.query_region` but only returns the HTTP response
189189
rather than the parsed result.
@@ -309,7 +309,7 @@ def _args_to_payload(self, **kwargs):
309309

310310
return request_payload
311311

312-
def _parse_result(self, response, verbose=False):
312+
def _parse_result(self, response, *, verbose=False):
313313
"""
314314
Parsing of the response returned by the MOCServer.
315315

astroquery/dace/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def query_radial_velocities_async(self, object_name):
4242
return self._request("GET", ''.join([self.__DACE_URL, self.__RADIAL_VELOCITIES_ENDPOINT, object_name]),
4343
timeout=self.__DACE_TIMEOUT, headers=self.__HEADERS)
4444

45-
def _parse_result(self, response, verbose=False):
45+
def _parse_result(self, response, *, verbose=False):
4646
try:
4747
json_data = response.json()
4848
dace_dict = self.transform_data_as_dict(json_data)

astroquery/eso/core.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self):
4848
self._survey_list = None
4949
self.username = None
5050

51-
def _activate_form(self, response, form_index=0, form_id=None, inputs={},
51+
def _activate_form(self, response, *, form_index=0, form_id=None, inputs={},
5252
cache=True, method=None):
5353
"""
5454
Parameters
@@ -191,7 +191,7 @@ def _activate_form(self, response, form_index=0, form_id=None, inputs={},
191191

192192
return response
193193

194-
def _login(self, username=None, store_password=False,
194+
def _login(self, *, username=None, store_password=False,
195195
reenter_password=False):
196196
"""
197197
Login to the ESO User Portal.
@@ -257,7 +257,7 @@ def _login(self, username=None, store_password=False,
257257
keyring.set_password("astroquery:www.eso.org", username, password)
258258
return authenticated
259259

260-
def list_instruments(self, cache=True):
260+
def list_instruments(self, *, cache=True):
261261
""" List all the available instrument-specific queries offered by the ESO archive.
262262
263263
Returns
@@ -280,7 +280,7 @@ def list_instruments(self, cache=True):
280280
self._instrument_list.append(instrument)
281281
return self._instrument_list
282282

283-
def list_surveys(self, cache=True):
283+
def list_surveys(self, *, cache=True):
284284
""" List all the available surveys (phase 3) in the ESO archive.
285285
286286
Returns
@@ -311,7 +311,7 @@ def list_surveys(self, cache=True):
311311
self._survey_list.append(survey)
312312
return self._survey_list
313313

314-
def query_surveys(self, surveys='', cache=True,
314+
def query_surveys(self, *, surveys='', cache=True,
315315
help=False, open_form=False, **kwargs):
316316
"""
317317
Query survey Phase 3 data contained in the ESO archive.
@@ -369,7 +369,7 @@ def query_surveys(self, surveys='', cache=True,
369369
else:
370370
warnings.warn("Query returned no results", NoResultsWarning)
371371

372-
def query_main(self, column_filters={}, columns=[],
372+
def query_main(self, *, column_filters={}, columns=[],
373373
open_form=False, help=False, cache=True, **kwargs):
374374
"""
375375
Query raw data contained in the ESO archive.
@@ -403,7 +403,7 @@ def query_main(self, column_filters={}, columns=[],
403403
return self._query(url, column_filters=column_filters, columns=columns,
404404
open_form=open_form, help=help, cache=cache, **kwargs)
405405

406-
def query_instrument(self, instrument, column_filters={}, columns=[],
406+
def query_instrument(self, instrument, *, column_filters={}, columns=[],
407407
open_form=False, help=False, cache=True, **kwargs):
408408
"""
409409
Query instrument-specific raw data contained in the ESO archive.
@@ -441,7 +441,7 @@ def query_instrument(self, instrument, column_filters={}, columns=[],
441441
return self._query(url, column_filters=column_filters, columns=columns,
442442
open_form=open_form, help=help, cache=cache, **kwargs)
443443

444-
def _query(self, url, column_filters={}, columns=[],
444+
def _query(self, url, *, column_filters={}, columns=[],
445445
open_form=False, help=False, cache=True, **kwargs):
446446

447447
table = None
@@ -486,7 +486,7 @@ def _query(self, url, column_filters={}, columns=[],
486486
else:
487487
warnings.warn("Query returned no results", NoResultsWarning)
488488

489-
def get_headers(self, product_ids, cache=True):
489+
def get_headers(self, product_ids, *, cache=True):
490490
"""
491491
Get the headers associated to a list of data product IDs
492492
@@ -557,7 +557,7 @@ def get_headers(self, product_ids, cache=True):
557557
# Return as Table
558558
return Table(result)
559559

560-
def _check_existing_files(self, datasets, continuation=False,
560+
def _check_existing_files(self, datasets, *, continuation=False,
561561
destination=None):
562562
"""Detect already downloaded datasets."""
563563

@@ -628,7 +628,7 @@ def _download_file(self, url, local_filepath, **kwargs):
628628

629629
return resp
630630

631-
def retrieve_data(self, datasets, continuation=False, destination=None,
631+
def retrieve_data(self, datasets, *, continuation=False, destination=None,
632632
with_calib='none', request_all_objects=False,
633633
unzip=True, request_id=None):
634634
"""
@@ -891,7 +891,7 @@ def verify_data_exists(self, dataset):
891891

892892
return 'No data returned' not in content
893893

894-
def query_apex_quicklooks(self, project_id=None, help=False,
894+
def query_apex_quicklooks(self, *, project_id=None, help=False,
895895
open_form=False, cache=True, **kwargs):
896896
"""
897897
APEX data are distributed with quicklook products identified with a
@@ -900,7 +900,7 @@ def query_apex_quicklooks(self, project_id=None, help=False,
900900
901901
Examples
902902
--------
903-
>>> tbl = Eso.query_apex_quicklooks('093.C-0144')
903+
>>> tbl = Eso.query_apex_quicklooks(project_id='093.C-0144')
904904
>>> files = Eso.retrieve_data(tbl['Product ID'])
905905
"""
906906

@@ -944,7 +944,7 @@ def query_apex_quicklooks(self, project_id=None, help=False,
944944

945945
return table
946946

947-
def _print_query_help(self, url, cache=True):
947+
def _print_query_help(self, url, *, cache=True):
948948
"""
949949
Download a form and print it in a quasi-human-readable way
950950
"""
@@ -1006,7 +1006,7 @@ def _print_query_help(self, url, cache=True):
10061006
log.info("\n".join(result_string))
10071007
return result_string
10081008

1009-
def _print_surveys_help(self, url, cache=True):
1009+
def _print_surveys_help(self, url, *, cache=True):
10101010
"""
10111011
Download a form and print it in a quasi-human-readable way
10121012
"""

0 commit comments

Comments
 (0)