Skip to content

Commit 8898b54

Browse files
authored
Merge pull request #2536 from jdavies-st/flake8-strict
Use flake8 for codestyle check
2 parents 62a34f0 + 65d6968 commit 8898b54

File tree

105 files changed

+448
-656
lines changed

Some content is hidden

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

105 files changed

+448
-656
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_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_download_and_extract(self, tmp_path, alma):
250250
[asdm_url], include_asdm=True, regex=r'.*\.py')
251251
delete_mock.assert_called_once_with(
252252
'cache_path/' + asdm_url.split('/')[-1])
253-
assert downloaded_asdm == [Path(tmp_path, 'foo.py')]
253+
assert Path(*downloaded_asdm) == Path(tmp_path, 'foo.py')
254254

255255
def test_doc_example(self, tmp_path, alma):
256256
alma.cache_location = tmp_path

astroquery/alma/tests/test_alma_utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
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
73
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
134

145
from .. import utils
156

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

0 commit comments

Comments
 (0)