Skip to content

Commit 557a5a3

Browse files
committed
Fix flake8 F codes
1 parent 62a34f0 commit 557a5a3

File tree

90 files changed

+363
-504
lines changed

Some content is hidden

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

90 files changed

+363
-504
lines changed

astroquery/__init__.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
# Affiliated packages may add whatever they like to this file, but
1010
# should keep this content at the top.
1111
# ----------------------------------------------------------------------------
12-
from ._astropy_init import *
12+
from ._astropy_init import __version__, __githash__, test
1313
# ----------------------------------------------------------------------------
1414

1515
import os
1616
import logging
1717

1818
from .logger import _init_log
1919

20+
__all__ = ["__version__", "__githash__", "__citation__", "__bibtex__", "test", "log"]
21+
2022

2123
# Set the bibtex entry to the article referenced in CITATION.
2224
def _get_bibtex():
@@ -32,18 +34,6 @@ def _get_bibtex():
3234
__citation__ = __bibtex__ = _get_bibtex()
3335

3436

35-
try:
36-
from .version import version as __version__
37-
except ImportError:
38-
# TODO: Issue a warning using the logging framework
39-
__version__ = ''
40-
try:
41-
from .version import githash as __githash__
42-
except ImportError:
43-
# TODO: Issue a warning using the logging framework
44-
__githash__ = ''
45-
46-
4737
# Setup logging for astroquery
4838
logging.addLevelName(5, "TRACE")
4939
log = logging.getLogger()

astroquery/alfalfa/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
This package is for querying the ALFALFA data repository hosted at
99
http://arecibo.tc.cornell.edu/hiarchive/alfalfa/
1010
"""
11+
import warnings
1112

1213
from .core import Alfalfa, AlfalfaClass
1314

14-
import warnings
15+
16+
__all__ = ["Alfalfa", "AlfalfaClass"]
17+
18+
1519
warnings.warn("Experimental: ALFALFA has not yet been refactored to have "
1620
"its API match the rest of astroquery.")

astroquery/alma/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def retrieve_data_from_uid(self, uids, *, cache=True):
833833
if len(files) == 1:
834834
file_urls = files['access_url']
835835
if isinstance(file_urls, str) and file_urls == '':
836-
raise ValueError(f"Cannot download uid {uid} because it has no file")
836+
raise ValueError(f"Cannot download uid {uids} because it has no file")
837837
else:
838838
file_urls = [url for url in files['access_url'] if url]
839839

astroquery/alma/tests/test_alma.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2-
from cmath import exp
32
from io import StringIO
43
import os
54

65
import pytest
7-
import requests
8-
import unittest
96
from unittest.mock import patch, Mock
107

118
from astropy import units as u
@@ -14,7 +11,6 @@
1411
from astropy.coordinates import SkyCoord
1512
from astropy.time import Time
1613

17-
import astroquery.alma
1814
from astroquery.alma import Alma
1915
from astroquery.alma.core import _gen_sql, _OBSCORE_TO_ALMARESULT
2016
from astroquery.alma.tapsql import _val_parse

astroquery/alma/tests/test_alma_utils.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
import numpy as np
3-
import pytest
4-
import warnings
5-
6-
from astropy import wcs
7-
from astropy import units as u
8-
try:
9-
from pyregion.parser_helper import Shape
10-
pyregion_OK = True
11-
except ImportError:
12-
pyregion_OK = False
133

144
from .. import utils
155

astroquery/astrometry_net/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import json
55

66
from astropy.io import fits
7-
from astroquery import log
87
from astropy.stats import sigma_clipped_stats
98
from astropy.coordinates import SkyCoord
109

astroquery/cadc/core.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from ..utils import async_to_sync, commons
1919
from ..query import BaseQuery
2020
from bs4 import BeautifulSoup
21-
from astropy.utils.exceptions import AstropyDeprecationWarning
22-
from astropy.utils.decorators import deprecated
2321
from astropy import units as u
2422
import pyvo
2523
from pyvo.auth import authsession
@@ -454,8 +452,8 @@ def get_image_list(self, query_result, coordinates, radius):
454452
range(0, len(publisher_ids), batch_size)):
455453
datalink = pyvo.dal.adhoc.DatalinkResults.from_result_url(
456454
'{}?{}'.format(self.data_link_url,
457-
urlencode({'ID': pid_sublist}, True),
458-
session=self.cadcdatalink._session))
455+
urlencode({'ID': pid_sublist}, True)),
456+
session=self.cadcdatalink._session)
459457
for service_def in datalink.bysemantics('#cutout'):
460458
access_url = service_def.access_url
461459
if isinstance(access_url, bytes): # ASTROPY_LT_4_1

astroquery/casda/core.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3-
# 1. standard library imports
43
from io import BytesIO
54
import os
65
from urllib.parse import unquote, urlparse
@@ -9,26 +8,20 @@
98
from datetime import datetime, timezone
109
import keyring
1110

12-
# 2. third party imports
1311
import astropy.units as u
1412
import astropy.coordinates as coord
1513
from astropy.table import Table
1614
from astropy.io.votable import parse
1715
from astroquery import log
1816
import numpy as np
1917

20-
# 3. local imports - use relative imports
2118
from ..query import QueryWithLogin
2219
from ..utils import commons
23-
# prepend_docstr is a way to copy docstrings between methods
24-
from ..utils import prepend_docstr_nosections
25-
# async_to_sync generates the relevant query tools from _async methods
2620
from ..utils import async_to_sync
27-
# import configurable items declared in __init__.py
2821
from . import conf
2922
from ..exceptions import LoginError
3023

31-
# export all the public classes and methods
24+
3225
__all__ = ['Casda', 'CasdaClass']
3326

3427

astroquery/casda/tests/test_casda.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from astroquery.exceptions import LoginError
1919

2020
try:
21-
from unittest.mock import Mock, patch, MagicMock
21+
from unittest.mock import Mock, MagicMock
2222
except ImportError:
2323
pytest.skip("Install mock for the casda tests.", allow_module_level=True)
2424

@@ -137,7 +137,7 @@ def test_login_no_default_user():
137137
assert casda._authenticated is False
138138
assert casda.USERNAME == ''
139139

140-
with pytest.raises(LoginError, match=r"If you do not pass a username to login\(\),") as excinfo:
140+
with pytest.raises(LoginError, match=r"If you do not pass a username to login\(\),"):
141141
Casda.login()
142142

143143
assert casda._authenticated is False
@@ -285,7 +285,7 @@ def test_filter_out_unreleased():
285285
def test_stage_data_unauthorised(patch_get):
286286
table = Table()
287287

288-
with pytest.raises(ValueError, match=r"Credentials must be supplied") as excinfo:
288+
with pytest.raises(ValueError, match=r"Credentials must be supplied"):
289289
Casda.stage_data(table)
290290

291291

@@ -308,7 +308,7 @@ def test_stage_data_invalid_credentials(patch_get):
308308
casda._auth = (USERNAME, 'notthepassword')
309309
casda._authenticated = True
310310

311-
with pytest.raises(requests.exceptions.HTTPError) as excinfo:
311+
with pytest.raises(requests.exceptions.HTTPError):
312312
casda.stage_data(table)
313313

314314

@@ -320,7 +320,7 @@ def test_stage_data_no_link(patch_get):
320320
fake_login(casda, USERNAME, PASSWORD)
321321
casda.POLL_INTERVAL = 1
322322

323-
with pytest.raises(ValueError, match=r"You do not have access to any of the requested data files\.") as excinfo:
323+
with pytest.raises(ValueError, match=r"You do not have access to any of the requested data files\."):
324324
casda.stage_data(table)
325325

326326

@@ -357,16 +357,12 @@ def test_cutout_no_args(patch_get):
357357
prefix = 'https://somewhere/casda/datalink/links?'
358358
access_urls = [prefix + 'cube-244']
359359
table = Table([Column(data=access_urls, name='access_url')])
360-
ra = 333.9092*u.deg
361-
dec = -45.8418*u.deg
362-
radius = 30*u.arcmin
363-
centre = SkyCoord(ra, dec)
364360

365361
casda = Casda()
366362
fake_login(casda, USERNAME, PASSWORD)
367363
casda.POLL_INTERVAL = 1
368364
with pytest.raises(ValueError,
369-
match=r"Please provide cutout parameters such as coordinates, band or channel\.") as excinfo:
365+
match=r"Please provide cutout parameters such as coordinates, band or channel\."):
370366
casda.cutout(table)
371367

372368

@@ -379,7 +375,7 @@ def test_cutout_unauthorised(patch_get):
379375
radius = 30*u.arcmin
380376
centre = SkyCoord(ra, dec)
381377

382-
with pytest.raises(ValueError, match=r"Credentials must be supplied to download CASDA image data") as excinfo:
378+
with pytest.raises(ValueError, match=r"Credentials must be supplied to download CASDA image data"):
383379
Casda.cutout(table, coordinates=centre, radius=radius, verbose=True)
384380

385381

astroquery/cds/tests/test_mocserver.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@
88
from astropy import coordinates
99
from astropy.table import Table
1010

11-
try:
12-
from mocpy import MOC
13-
HAS_MOCPY = True
14-
except ImportError:
15-
HAS_MOCPY = False
16-
17-
try:
18-
from regions import CircleSkyRegion, PolygonSkyRegion
19-
HAS_REGIONS = True
20-
except ImportError:
21-
HAS_REGIONS = False
22-
2311
from ..core import cds
2412
from astroquery.utils.mocks import MockResponse
2513

2614

15+
pytest.importorskip("mocpy")
16+
pytest.importorskip("regions")
17+
18+
from regions import CircleSkyRegion, PolygonSkyRegion
19+
20+
2721
DATA_FILES = {
2822
'PROPERTIES_SEARCH': 'properties.json',
2923
'HIPS_FROM_SAADA_AND_ALASKY': 'hips_from_saada_alasky.json',
@@ -72,8 +66,6 @@ def data_path(filename):
7266
"""
7367

7468

75-
@pytest.mark.skipif('not HAS_REGIONS')
76-
@pytest.mark.skipif('not HAS_MOCPY')
7769
@pytest.mark.parametrize('datafile',
7870
['PROPERTIES_SEARCH', 'HIPS_FROM_SAADA_AND_ALASKY'])
7971
def test_request_results(patch_get, datafile):
@@ -97,8 +89,6 @@ def test_request_results(patch_get, datafile):
9789
"""
9890

9991

100-
@pytest.mark.skipif('not HAS_REGIONS')
101-
@pytest.mark.skipif('not HAS_MOCPY')
10292
@pytest.mark.parametrize('RA, DEC, RADIUS',
10393
[(10.8, 6.5, 0.5),
10494
(25.6, -23.2, 1.1),
@@ -117,8 +107,6 @@ def test_cone_search_spatial_request(RA, DEC, RADIUS):
117107
(request_payload['SR'] == str(RADIUS))
118108

119109

120-
@pytest.mark.skipif('not HAS_REGIONS')
121-
@pytest.mark.skipif('not HAS_MOCPY')
122110
@pytest.mark.parametrize('poly, poly_payload',
123111
[(polygon1, 'Polygon 57.376 24.053 56.391 24.622 56.025 24.049 56.616 24.291'),
124112
(polygon2, 'Polygon 58.376 24.053 53.391 25.622 56.025 22.049 54.616 27.291')])
@@ -132,8 +120,6 @@ def test_polygon_spatial_request(poly, poly_payload):
132120
assert request_payload['stc'] == poly_payload
133121

134122

135-
@pytest.mark.skipif('not HAS_REGIONS')
136-
@pytest.mark.skipif('not HAS_MOCPY')
137123
@pytest.mark.parametrize('intersect',
138124
['encloses', 'overlaps', 'covers'])
139125
def test_intersect_param(intersect):

0 commit comments

Comments
 (0)