Skip to content

Commit cee41df

Browse files
authored
Merge pull request #2690 from nkphysics/utls-kwarg-konly
Make utils and utis/tap kwargs keyword only
2 parents 8e8c106 + e685bb6 commit cee41df

File tree

24 files changed

+181
-182
lines changed

24 files changed

+181
-182
lines changed

astroquery/esa/hubble/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def download_product(self, observation_id, *, calibration_level=None,
105105
params["PRODUCTTYPE"] = product_type
106106

107107
filename = self._get_product_filename(product_type, filename)
108-
self._tap.load_data(params, filename, verbose=verbose)
108+
self._tap.load_data(params_dict=params, output_file=filename, verbose=verbose)
109109

110110
return filename
111111

@@ -254,7 +254,7 @@ def get_artifact(self, artifact_id, *, filename=None, verbose=False):
254254
if filename is None:
255255
filename = artifact_id
256256

257-
self._tap.load_data(params, filename, verbose=verbose)
257+
self._tap.load_data(params_dict=params, output_file=filename, verbose=verbose)
258258

259259
return filename
260260

@@ -302,7 +302,7 @@ def get_postcard(self, observation_id, *, calibration_level="RAW",
302302
if filename is None:
303303
filename = observation_id
304304

305-
self._tap.load_data(params, filename, verbose=verbose)
305+
self._tap.load_data(params_dict=params, output_file=filename, verbose=verbose)
306306

307307
return filename
308308

@@ -505,7 +505,7 @@ def _query_tap_target(self, target):
505505
subContext = conf.EHST_TARGET_ACTION
506506
connHandler = self._tap._TapPlus__getconnhandler()
507507
data = urlencode(params)
508-
target_response = connHandler.execute_secure(subContext, data, True)
508+
target_response = connHandler.execute_secure(subContext, data, verbose=True)
509509
for line in target_response:
510510
target_result = json.loads(line.decode("utf-8"))
511511
if target_result['objects']:
@@ -763,7 +763,7 @@ def get_status_messages(self):
763763
try:
764764
subContext = conf.EHST_MESSAGES
765765
connHandler = self._tap._TapPlus__getconnhandler()
766-
response = connHandler.execute_tapget(subContext, False)
766+
response = connHandler.execute_tapget(subContext, verbose=False)
767767
if response.status == 200:
768768
for line in response:
769769
string_message = line.decode("utf-8")

astroquery/esa/jwst/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def load_tables(self, *, only_names=False, include_shared_tables=False,
9393
-------
9494
A list of table objects
9595
"""
96-
return self.__jwsttap.load_tables(only_names,
97-
include_shared_tables,
98-
verbose)
96+
return self.__jwsttap.load_tables(only_names=only_names,
97+
include_shared_tables=include_shared_tables,
98+
verbose=verbose)
9999

100100
def load_table(self, table, *, verbose=False):
101101
"""Loads the specified table
@@ -112,7 +112,7 @@ def load_table(self, table, *, verbose=False):
112112
-------
113113
A table object
114114
"""
115-
return self.__jwsttap.load_table(table, verbose)
115+
return self.__jwsttap.load_table(table, verbose=verbose)
116116

117117
def launch_job(self, query, *, name=None, output_file=None,
118118
output_format="votable", verbose=False, dump_to_file=False,
@@ -686,7 +686,7 @@ def get_status_messages(self):
686686
try:
687687
subContext = conf.JWST_MESSAGES
688688
connHandler = self.__jwsttap._TapPlus__getconnhandler()
689-
response = connHandler.execute_tapget(subContext, False)
689+
response = connHandler.execute_tapget(subContext, verbose=False)
690690
if response.status == 200:
691691
for line in response:
692692
string_message = line.decode("utf-8")

astroquery/esa/jwst/tests/test_jwsttap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test_list_async_jobs(self):
231231

232232
def test_query_region(self):
233233
connHandler = DummyConnHandler()
234-
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
234+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=connHandler)
235235
tap = JwstClass(tap_plus_handler=tapplus, show_messages=False)
236236

237237
# Launch response: we use default response because the
@@ -364,7 +364,7 @@ def test_query_region(self):
364364

365365
def test_query_region_async(self):
366366
connHandler = DummyConnHandler()
367-
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
367+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=connHandler)
368368
tap = JwstClass(tap_plus_handler=tapplus, show_messages=False)
369369
jobid = '12345'
370370
# Launch response
@@ -436,7 +436,7 @@ def test_query_region_async(self):
436436

437437
def test_cone_search_sync(self):
438438
connHandler = DummyConnHandler()
439-
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
439+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=connHandler)
440440
tap = JwstClass(tap_plus_handler=tapplus, show_messages=False)
441441
# Launch response: we use default response because the
442442
# query contains decimals
@@ -521,7 +521,7 @@ def test_cone_search_sync(self):
521521

522522
def test_cone_search_async(self):
523523
connHandler = DummyConnHandler()
524-
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
524+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=connHandler)
525525
tap = JwstClass(tap_plus_handler=tapplus, show_messages=False)
526526
jobid = '12345'
527527
# Launch response

astroquery/gaia/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def get_status_messages(self):
912912
try:
913913
subContext = self.GAIA_MESSAGES
914914
connHandler = self._TapPlus__getconnhandler()
915-
response = connHandler.execute_tapget(subContext, False)
915+
response = connHandler.execute_tapget(subContext, verbose=False)
916916
if response.status == 200:
917917
if isinstance(response, Iterable):
918918
for line in response:

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def column_attrs():
5454
@pytest.fixture(scope="module")
5555
def mock_querier():
5656
conn_handler = DummyConnHandler()
57-
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
57+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
5858
launch_response = DummyResponse(200)
5959
launch_response.set_data(method="POST", body=JOB_DATA)
6060
# The query contains decimals: default response is more robust.
@@ -65,7 +65,7 @@ def mock_querier():
6565
@pytest.fixture(scope="module")
6666
def mock_querier_async():
6767
conn_handler = DummyConnHandler()
68-
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
68+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
6969
jobid = "12345"
7070

7171
launch_response = DummyResponse(303)
@@ -105,7 +105,7 @@ def test_show_message():
105105
tableRequest = 'notification?action=GetNotifications'
106106
connHandler.set_response(tableRequest, dummy_response)
107107

108-
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
108+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=connHandler)
109109
GaiaClass(tap_plus_conn_handler=connHandler, datalink_handler=tapplus, show_server_messages=True)
110110

111111

@@ -258,7 +258,7 @@ def test_cross_match_missing_mandatory_kwarg(cross_match_kwargs, missing_kwarg):
258258
@patch.object(TapPlus, 'login')
259259
def test_login(mock_login):
260260
conn_handler = DummyConnHandler()
261-
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
261+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
262262
tap = GaiaClass(tap_plus_conn_handler=conn_handler, datalink_handler=tapplus, show_server_messages=False)
263263
tap.login(user="user", password="password")
264264
assert (mock_login.call_count == 2)
@@ -271,7 +271,7 @@ def test_login(mock_login):
271271
@patch.object(TapPlus, 'login')
272272
def test_login_gui(mock_login_gui, mock_login):
273273
conn_handler = DummyConnHandler()
274-
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
274+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
275275
tap = GaiaClass(tap_plus_conn_handler=conn_handler, datalink_handler=tapplus, show_server_messages=False)
276276
tap.login_gui()
277277
assert (mock_login_gui.call_count == 1)
@@ -283,7 +283,7 @@ def test_login_gui(mock_login_gui, mock_login):
283283
@patch.object(TapPlus, 'logout')
284284
def test_logout(mock_logout):
285285
conn_handler = DummyConnHandler()
286-
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
286+
tapplus = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
287287
tap = GaiaClass(tap_plus_conn_handler=conn_handler, datalink_handler=tapplus, show_server_messages=False)
288288
tap.logout()
289289
assert (mock_logout.call_count == 2)

astroquery/sdss/tests/test_sdss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def mockreturn(method, url, **kwargs):
4444
with open(filename, 'rb') as infile:
4545
content = infile.read()
4646

47-
return MockResponse(content, url)
47+
return MockResponse(content=content, url=url)
4848

4949
mp = request.getfixturevalue("monkeypatch")
5050

astroquery/utils/commons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def get_fits(self):
280280

281281
return self._fits
282282

283-
def save_fits(self, savepath, link_cache='hard'):
283+
def save_fits(self, savepath, *, link_cache='hard'):
284284
"""
285285
Save a FITS file to savepath
286286

astroquery/utils/docstr_chompers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def dec(fn):
1010
return dec
1111

1212

13-
def prepend_docstr_nosections(doc, sections=['Returns', ]):
13+
def prepend_docstr_nosections(doc, *, sections=['Returns', ]):
1414
"""
1515
Decorator to prepend to the function's docstr after stripping out the
1616
list of sections provided (by default "Returns" only).

astroquery/utils/mocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MockResponse:
1212
A mocked/non-remote version of `astroquery.query.AstroResponse`
1313
"""
1414

15-
def __init__(self, content=None, url=None, headers={}, content_type=None,
15+
def __init__(self, content=None, *, url=None, headers={}, content_type=None,
1616
stream=False, auth=None, status_code=200, verify=True,
1717
allow_redirects=True, json=None):
1818
assert content is None or hasattr(content, 'decode')

astroquery/utils/process_asyncs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def newmethod(self, *args, **kwargs):
5353
return cls
5454

5555

56-
def async_to_sync_docstr(doc, returntype='table'):
56+
def async_to_sync_docstr(doc, *, returntype='table'):
5757
"""
5858
Strip of the "Returns" component of a docstr and replace it with "Returns a
5959
table" code

0 commit comments

Comments
 (0)