Skip to content

Commit 72cb9dc

Browse files
committed
MAINT: more style adjustments to fix all linter issues
1 parent 30f774f commit 72cb9dc

Some content is hidden

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

56 files changed

+296
-351
lines changed

astroquery/alma/tests/test_alma.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ def test_gen_array_sql():
179179
# string arrays should be OR'd together
180180
common_select = "select * from ivoa.obscore WHERE "
181181
test_keywords = ["High-mass star formation", "Disks around high-mass stars"]
182-
assert _gen_sql({"spatial_resolution": "<0.1",
183-
"science_keyword": test_keywords}) == common_select + \
184-
"spatial_resolution<=0.1 AND (science_keyword='High-mass star formation' OR science_keyword='Disks around high-mass stars')"
182+
assert (_gen_sql({"spatial_resolution": "<0.1", "science_keyword": test_keywords})
183+
== common_select + ("spatial_resolution<=0.1 AND (science_keyword='High-mass star formation' "
184+
"OR science_keyword='Disks around high-mass stars')"))
185185

186186

187187
def test_gen_datetime_sql():
@@ -198,12 +198,9 @@ def test_gen_datetime_sql():
198198

199199
def test_gen_spec_res_sql():
200200
common_select = 'select * from ivoa.obscore WHERE '
201-
assert _gen_sql({'spectral_resolution': 70}) == common_select + \
202-
"em_resolution=20985472.06"
203-
assert _gen_sql({'spectral_resolution': '<70'}) == common_select + \
204-
"em_resolution>=20985472.06"
205-
assert _gen_sql({'spectral_resolution': '>70'}) == common_select + \
206-
"em_resolution<=20985472.06"
201+
assert _gen_sql({'spectral_resolution': 70}) == common_select + "em_resolution=20985472.06"
202+
assert _gen_sql({'spectral_resolution': '<70'}) == common_select + "em_resolution>=20985472.06"
203+
assert _gen_sql({'spectral_resolution': '>70'}) == common_select + "em_resolution<=20985472.06"
207204
assert _gen_sql({'spectral_resolution': '(70 .. 80)'}) == common_select + \
208205
"(23983396.64<=em_resolution AND em_resolution<=20985472.06)"
209206
assert _gen_sql({'spectral_resolution': '(70|80)'}) == common_select + \
@@ -471,7 +468,9 @@ class MockResponse:
471468
'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
472469
adhoc_service_1_param2 = type(
473470
'', (object, ), {
474-
'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar'})()
471+
'ID': 'accessURL',
472+
'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar'}
473+
)()
475474
adhoc_service_1 = type(
476475
'', (object, ), {
477476
'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar', 'params': [
@@ -481,7 +480,9 @@ class MockResponse:
481480
'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
482481
adhoc_service_2_param2 = type(
483482
'', (object, ), {
484-
'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar'})()
483+
'ID': 'accessURL',
484+
'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar'}
485+
)()
485486
adhoc_service_2 = type(
486487
'', (object, ), {
487488
'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar', 'params': [

astroquery/alma/tests/test_alma_remote.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ def test_verify_html_file(alma, caplog, tmp_path):
563563
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
564564

565565
result = alma.download_files(
566-
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
566+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)],
567+
verify_only=True)
567568
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
568569
local_filepath = Path(result[0])
569570
expected_file_length = local_filepath.stat().st_size
@@ -576,9 +577,11 @@ def test_verify_html_file(alma, caplog, tmp_path):
576577
caplog.clear()
577578
new_file_length = expected_file_length + 10
578579
with pytest.warns(expected_warning=CorruptDataWarning,
579-
match=f"Found cached file {local_filepath} with size {new_file_length} > expected size {expected_file_length}. The download is likely corrupted."):
580+
match=(f"Found cached file {local_filepath} with size {new_file_length} > expected size "
581+
f"{expected_file_length}. The download is likely corrupted.")):
580582
result = alma.download_files(
581-
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
583+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)],
584+
verify_only=True)
582585
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
583586

584587
# manipulate the file: make it small
@@ -587,7 +590,9 @@ def test_verify_html_file(alma, caplog, tmp_path):
587590

588591
caplog.clear()
589592
result = alma.download_files(
590-
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
593+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)],
594+
verify_only=True)
591595
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
592596
existing_file_length = 10
593-
assert f"Found cached file {local_filepath} with size {existing_file_length} < expected size {expected_file_length}. The download should be continued." in caplog.text
597+
assert (f"Found cached file {local_filepath} with size {existing_file_length} < expected size "
598+
f"{expected_file_length}. The download should be continued.") in caplog.text

astroquery/alma/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ def parse_frequency_support(frequency_support_str):
2929
supports = frequency_support_str.split('U')
3030

3131
freq_ranges = [(float(sup[0]),
32-
float(sup[1].split(',')[0].strip(string.ascii_letters))) *
33-
u.Unit(sup[1].split(',')[0].strip(string.punctuation
34-
+ string.digits))
32+
float(sup[1].split(',')[0].strip(string.ascii_letters)))
33+
* u.Unit(sup[1].split(',')[0].strip(string.punctuation + string.digits))
3534
for i in supports for sup in [i.strip('[] ').split('..'), ]]
3635
return u.Quantity(freq_ranges)
3736

astroquery/atomic/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def __init__(self):
2929
super().__init__()
3030
self.__default_form_values = None
3131

32-
def query_object(self, *, wavelength_range=None, wavelength_type=None, wavelength_accuracy=None, element_spectrum=None,
32+
def query_object(self, *, wavelength_range=None, wavelength_type=None, wavelength_accuracy=None,
33+
element_spectrum=None,
3334
minimal_abundance=None, depl_factor=None, lower_level_energy_range=None,
3435
upper_level_energy_range=None, nmax=None, multiplet=None, transitions=None,
3536
show_fine_structure=None, show_auto_ionizing_transitions=None,

astroquery/besancon/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ def _parse_args(self, glon, glat, email, smallfield=True, extinction=0.7,
286286

287287
return request_data
288288

289-
@prepend_docstr_nosections("\n" + _parse_args.__doc__ +
290-
_parse_result.__doc__)
289+
@prepend_docstr_nosections("\n" + _parse_args.__doc__ + _parse_result.__doc__)
291290
def query_async(self, *args, **kwargs):
292291
"""
293292
Returns

astroquery/casda/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def _login(self, *, username=None, store_password=False,
9898
def query_region_async(self, coordinates, radius=1*u.arcmin, height=None, width=None,
9999
get_query_payload=False, cache=True):
100100
"""
101-
Queries a region around the specified coordinates. Either a radius or both a height and a width must be provided.
101+
Queries a region around the specified coordinates. Either a radius or both a height and a width
102+
must be provided.
102103
103104
Parameters
104105
----------

astroquery/casda/tests/test_casda.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,12 @@ def test_args_to_payload_combined(patch_get):
557557

558558

559559
def test_download_file(patch_get):
560-
urls = ['https://ingest.pawsey.org/bucket_name/path/askap_img.fits?security=stuff',
561-
'http://casda.csiro.au/download/web/111-000-111-000/askap_img.fits.checksum',
562-
'https://ingest.pawsey.org.au/casda-prd-as110-01/dc52217/primary_images/RACS-DR1_0000%2B18A.fits?security=stuff']
560+
urls = [
561+
'https://ingest.pawsey.org/bucket_name/path/askap_img.fits?security=stuff',
562+
'http://casda.csiro.au/download/web/111-000-111-000/askap_img.fits.checksum',
563+
'https://ingest.pawsey.org.au/casda-prd-as110-01/dc52217/primary_images/RACS-DR1_0000%2B18A.fits?security=stuff'
564+
]
565+
563566
casda = Casda()
564567
fake_login(casda, USERNAME, PASSWORD)
565568

astroquery/cosmosim/core.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,7 @@ def explore_db(self, db=None, table=None, col=None):
924924
info_list += ([self.db_dict[proj][key]
925925
if isinstance(self.db_dict[proj][key], str)
926926
else ""
927-
for key in self.db_dict[proj].keys()] +
928-
['-' * tmp2_largest])
927+
for key in self.db_dict[proj].keys()] + ['-' * tmp2_largest])
929928
t['Projects'] = proj_list
930929
t['Project Items'] = attr_list
931930
t['Information'] = info_list
@@ -963,20 +962,18 @@ def explore_db(self, db=None, table=None, col=None):
963962
"the `{0}` db.".format(db))
964963
return
965964

966-
t['Projects'] = (['--> @ {}:'.format(db)]
967-
+ ['' for i in range(size2 - 1)])
965+
t['Projects'] = (['--> @ {}:'.format(db)] + ['' for i in range(size2 - 1)])
968966
t['Project Items'] = (
969967
['--> @ {}:'.format(key)
970968
if (isinstance(self.db_dict[db][key], dict)
971969
and (len(list(self.db_dict[db][key].keys()))
972970
== len(list(self.db_dict[db]['tables'].keys()))))
973971
else '@ {}'.format(key)
974972
if (isinstance(self.db_dict[db][key], dict)
975-
and (len(list(self.db_dict[db][key].keys())) !=
976-
len(self.db_dict[db]['tables'].keys())))
973+
and (len(list(self.db_dict[db][key].keys()))
974+
!= len(self.db_dict[db]['tables'].keys())))
977975
else str(key)
978-
for key in self.db_dict[db].keys()] +
979-
['' for i in range(size2 - size1)])
976+
for key in self.db_dict[db].keys()] + ['' for i in range(size2 - size1)])
980977
# if only db is specified
981978
if not table:
982979
if not col:
@@ -994,14 +991,11 @@ def explore_db(self, db=None, table=None, col=None):
994991
if key != table], key=len))
995992
t['Tables'] = (
996993
['--> @ {}:'.format(i)
997-
if (i == table
998-
and isinstance(self.db_dict[db]['tables'][i], dict))
994+
if (i == table and isinstance(self.db_dict[db]['tables'][i], dict))
999995
else '@ {}'.format(i)
1000-
if (i != table
1001-
and isinstance(self.db_dict[db]['tables'][i], dict))
996+
if (i != table and isinstance(self.db_dict[db]['tables'][i], dict))
1002997
else str(i)
1003-
for i in reordered] +
1004-
['' for j in range(size2 - len(reordered))])
998+
for i in reordered] + ['' for j in range(size2 - len(reordered))])
1005999

10061000
# if column has been specified
10071001
if col:
@@ -1012,8 +1006,7 @@ def explore_db(self, db=None, table=None, col=None):
10121006
+ ['' for j in range(size2 - len(tblcols_dict))])
10131007
col_dict = (self.db_dict[db]['tables'][table]
10141008
['columns'].keys())
1015-
reordered = ([str(col)]
1016-
+ [i for i in col_dict if i != col])
1009+
reordered = ([str(col)] + [i for i in col_dict if i != col])
10171010

10181011
temp_columns = []
10191012

@@ -1031,14 +1024,12 @@ def explore_db(self, db=None, table=None, col=None):
10311024

10321025
if len(col_dict) < size2:
10331026
size_diff = size2 - len(col_dict)
1034-
t['Columns'] = (temp_columns
1035-
+ ['' for j in range(size_diff)])
1027+
t['Columns'] = (temp_columns + ['' for j in range(size_diff)])
10361028

10371029
colinfo_dict = col_dict = columns[col]
10381030
t['Col. Info'] = (
10391031
['{} : {}'.format(i, colinfo_dict[i])
1040-
for i in colinfo_dict.keys()] +
1041-
['' for j in range(size2 - len(colinfo_dict))])
1032+
for i in colinfo_dict.keys()] + ['' for j in range(size2 - len(colinfo_dict))])
10421033
else:
10431034
t['Columns'] = temp_columns
10441035

@@ -1053,20 +1044,17 @@ def explore_db(self, db=None, table=None, col=None):
10531044
tmp_table = self.db_dict[db]['tables'][table]
10541045
t['Table Items'] = (
10551046
['@ {}'.format(i) if isinstance(tmp_table[i], dict)
1056-
else '{}:'.format(i) for i in tblcols_dict]
1057-
+ ['' for i in range(size_diff)])
1047+
else '{}:'.format(i) for i in tblcols_dict] + ['' for i in range(size_diff)])
10581048
t['Table Info'] = (
10591049
[str(tmp_table[i])
10601050
if not isinstance(tmp_table[i], dict)
1061-
else '' for i in tblcols_dict]
1062-
+ ['' for i in range(size_diff)])
1051+
else '' for i in tblcols_dict] + ['' for i in range(size_diff)])
10631052
if len(col_dict) < size2:
10641053
t['Columns'] = (
10651054
['@ {}'.format(i)
10661055
if isinstance(tmp_table['columns'][i], dict)
10671056
else str(i)
1068-
for i in reordered] +
1069-
['' for i in range(size2 - len(col_dict))])
1057+
for i in reordered] + ['' for i in range(size2 - len(col_dict))])
10701058
else:
10711059
t['Columns'] = reordered
10721060
else:

astroquery/esa/hubble/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def get_hap_hst_link(self, observation_id):
164164
elif 'HAP' in observation_type:
165165
oids = self._select_related_members(observation_id)
166166
elif 'HST' in observation_type:
167-
query = f"select observation_id from ehst.observation where obs_type='HAP Simple' and members like '%{observation_id}%'"
167+
query = ("select observation_id from ehst.observation where obs_type='HAP Simple' "
168+
f"and members like '%{observation_id}%'")
168169
job = self.query_tap(query=query)
169170
oids = job["observation_id"].pformat(show_name=False)
170171
else:

astroquery/esasky/core.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ def query_ids_spectra(self, observation_ids, *, missions=__ALL_STRING, row_limit
10041004
--------
10051005
query_ids_spectra(observation_ids=['0001730501', '0011420101'], missions='XMM-NEWTON')
10061006
query_ids_spectra(observation_ids='0001730501')
1007-
query_ids_spectra(observation_ids=['0001730501', '0011420101', '1342246640'], missions=['XMM-NEWTON', 'Herschel'])
1007+
query_ids_spectra(observation_ids=['0001730501', '1342246640'], missions=['XMM-NEWTON', 'Herschel'])
10081008
"""
10091009
sanitized_observation_ids = self._sanitize_input_ids(observation_ids)
10101010
sanitized_missions = self._sanitize_input_spectra(missions)
@@ -1146,8 +1146,10 @@ def get_images(self, *, position=None, observation_ids=None, radius=__ZERO_ARCMI
11461146
--------
11471147
get_images(position="m101", radius="14'", missions="all")
11481148
1149-
missions = ["SUZAKU", "ISO-IR", "Chandra", "XMM-OM-OPTICAL", "XMM", "XMM-OM-UV", "HST-IR", "Herschel", "Spitzer", "HST-UV", "HST-OPTICAL"]
1150-
observation_ids = ["100001010", "01500403", "21171", "0852000101", "0851180201", "0851180201", "n3tr01c3q", "1342247257", "30002561-25100", "hst_07553_3h_wfpc2_f160bw_pc", "ocli05leq"]
1149+
missions = ["SUZAKU", "ISO-IR", "Chandra", "XMM-OM-OPTICAL", "XMM", "XMM-OM-UV", "HST-IR", "Herschel",
1150+
"Spitzer", "HST-UV", "HST-OPTICAL"]
1151+
observation_ids = ["100001010", "01500403", "21171", "0852000101", "0851180201", "0851180201", "n3tr01c3q",
1152+
"1342247257", "30002561-25100", "hst_07553_3h_wfpc2_f160bw_pc", "ocli05leq"]
11511153
get_images(observation_ids=observation_ids, missions=missions)
11521154
"""
11531155
if position is None and observation_ids is None:
@@ -1242,7 +1244,7 @@ def get_spectra(self, *, position=None, observation_ids=None, radius=__ZERO_ARCM
12421244
get_spectra(position="m101", radius="14'", missions=["HST-IR", "XMM-NEWTON", "HERSCHEL"])
12431245
12441246
missions = ["ISO-IR", "Chandra", "IUE", "XMM-NEWTON", "HST-IR", "Herschel", "HST-UV", "HST-OPTICAL"]
1245-
observation_ids = ["02101201", "1005", "LWR13178", "0001730201", "ibh706cqq", "1342253595", "z1ax0102t", "oeik2s020"]
1247+
observation_ids = ["02101201", "1005", "LWR13178", "0001730201", "ibh706cqq", "1342253595", "oeik2s020"]
12461248
get_spectra(observation_ids=observation_ids, missions=missions)
12471249
12481250
"""
@@ -1772,8 +1774,8 @@ def _build_id_query(self, ids, row_limit, json):
17721774
if data_type in self._NUMBER_DATA_TYPES:
17731775
valid_ids = [int(obs_id) for obs_id in ids if obs_id.isdigit()]
17741776
if not valid_ids:
1775-
raise ValueError("Could not construct query for mission {}. Database column type is a number, "
1776-
"while none of the input id's could be interpreted as numbers.".format(json['mission']))
1777+
raise ValueError(f"Could not construct query for mission {json['mission']}. Database column type is "
1778+
"a number, while none of the input id's could be interpreted as numbers.")
17771779
return ""
17781780

17791781
observation_ids_query_list = ", ".join(repr(id) for id in valid_ids)

0 commit comments

Comments
 (0)