From de425fc912347fc755dc73c7ca7b8768327e0084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Wed, 4 May 2022 19:18:05 -0700 Subject: [PATCH 1/5] discard inheriting from `object` --- astroquery/esa/hsa/tests/dummy_handler.py | 2 +- astroquery/esa/hsa/tests/dummy_tap_handler.py | 2 +- astroquery/esa/iso/tests/dummy_handler.py | 2 +- astroquery/esa/iso/tests/dummy_tap_handler.py | 2 +- astroquery/hips2fits/tests/test_hips2fits.py | 2 +- astroquery/hips2fits/tests/test_hips2fits_remote.py | 2 +- astroquery/vizier/tests/test_vizier_remote.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/astroquery/esa/hsa/tests/dummy_handler.py b/astroquery/esa/hsa/tests/dummy_handler.py index cb2ce83e0f..932f5784b7 100644 --- a/astroquery/esa/hsa/tests/dummy_handler.py +++ b/astroquery/esa/hsa/tests/dummy_handler.py @@ -3,7 +3,7 @@ __all__ = ['DummyHandler'] -class DummyHandler(object): +class DummyHandler(): def __init__(self, method, parameters): self._invokedMethod = method diff --git a/astroquery/esa/hsa/tests/dummy_tap_handler.py b/astroquery/esa/hsa/tests/dummy_tap_handler.py index e898bf60a5..f5d29f6cd6 100644 --- a/astroquery/esa/hsa/tests/dummy_tap_handler.py +++ b/astroquery/esa/hsa/tests/dummy_tap_handler.py @@ -4,7 +4,7 @@ from ....utils.tap.model.job import Job -class DummyHSATapHandler(object): +class DummyHSATapHandler(): def __init__(self, method, parameters): self.__invokedMethod = method diff --git a/astroquery/esa/iso/tests/dummy_handler.py b/astroquery/esa/iso/tests/dummy_handler.py index a39a49f2f6..0717ad1811 100644 --- a/astroquery/esa/iso/tests/dummy_handler.py +++ b/astroquery/esa/iso/tests/dummy_handler.py @@ -12,7 +12,7 @@ __all__ = ['DummyHandler'] -class DummyHandler(object): +class DummyHandler(): def __init__(self, method, parameters): self._invokedMethod = method diff --git a/astroquery/esa/iso/tests/dummy_tap_handler.py b/astroquery/esa/iso/tests/dummy_tap_handler.py index 7898208722..623f9ff3a8 100644 --- a/astroquery/esa/iso/tests/dummy_tap_handler.py +++ b/astroquery/esa/iso/tests/dummy_tap_handler.py @@ -13,7 +13,7 @@ from ....utils.tap.model.job import Job -class DummyISOTapHandler(object): +class DummyISOTapHandler(): def __init__(self, method, parameters): self.__invokedMethod = method diff --git a/astroquery/hips2fits/tests/test_hips2fits.py b/astroquery/hips2fits/tests/test_hips2fits.py index 356bea4e12..29a6620f0a 100644 --- a/astroquery/hips2fits/tests/test_hips2fits.py +++ b/astroquery/hips2fits/tests/test_hips2fits.py @@ -15,7 +15,7 @@ import astropy.units as u -class TestHips2fitsRemote(object): +class TestHips2fitsRemote(): # Create a new WCS astropy object w = astropy_wcs.WCS(header={ diff --git a/astroquery/hips2fits/tests/test_hips2fits_remote.py b/astroquery/hips2fits/tests/test_hips2fits_remote.py index 3c7b68e566..0c8369ed18 100644 --- a/astroquery/hips2fits/tests/test_hips2fits_remote.py +++ b/astroquery/hips2fits/tests/test_hips2fits_remote.py @@ -15,7 +15,7 @@ @pytest.mark.remote_data -class TestHips2fitsRemote(object): +class TestHips2fitsRemote(): # Create a new WCS astropy object w = astropy_wcs.WCS(header={ diff --git a/astroquery/vizier/tests/test_vizier_remote.py b/astroquery/vizier/tests/test_vizier_remote.py index 7495ba3fe3..f62f73f0fd 100644 --- a/astroquery/vizier/tests/test_vizier_remote.py +++ b/astroquery/vizier/tests/test_vizier_remote.py @@ -8,7 +8,7 @@ @pytest.mark.remote_data -class TestVizierRemote(object): +class TestVizierRemote(): target = commons.ICRSCoordGenerator(ra=299.590, dec=35.201, unit=(u.deg, u.deg)) From 1dc3b734dfc0e56a2dfc54be55a3e34b8a8b548c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Wed, 4 May 2022 20:09:48 -0700 Subject: [PATCH 2/5] Cleaning up super() calls Using this darling: gsed -i -e 's|\(.*super(\)\(.*)\.\)\(.*)\)|\1).\3|g' --- astroquery/alfalfa/tests/test_alfalfa.py | 2 +- astroquery/alma/core.py | 2 +- astroquery/astrometry_net/core.py | 2 +- astroquery/atomic/core.py | 2 +- astroquery/besancon/core.py | 2 +- astroquery/besancon/tests/test_besancon.py | 2 +- astroquery/cadc/core.py | 2 +- astroquery/casda/core.py | 2 +- astroquery/cds/core.py | 2 +- astroquery/cosmosim/core.py | 2 +- astroquery/esa/hubble/core.py | 2 +- astroquery/esa/iso/core.py | 2 +- astroquery/esa/xmm_newton/core.py | 2 +- astroquery/esasky/core.py | 2 +- astroquery/eso/core.py | 2 +- astroquery/hips2fits/core.py | 2 +- astroquery/hitran/core.py | 2 +- astroquery/jplhorizons/core.py | 2 +- astroquery/lamda/core.py | 2 +- astroquery/mast/discovery_portal.py | 2 +- astroquery/mpc/core.py | 2 +- astroquery/nasa_ads/core.py | 2 +- astroquery/ogle/core.py | 2 +- astroquery/query.py | 4 ++-- astroquery/simbad/tests/test_simbad.py | 2 +- astroquery/skyview/core.py | 2 +- astroquery/skyview/tests/test_skyview.py | 4 ++-- astroquery/splatalogue/core.py | 2 +- astroquery/utils/commons.py | 4 ++-- astroquery/vamdc/core.py | 2 +- astroquery/vizier/core.py | 2 +- astroquery/vo_conesearch/conesearch.py | 2 +- astroquery/vo_conesearch/core.py | 2 +- astroquery/vo_conesearch/vos_catalog.py | 4 ++-- astroquery/wfau/core.py | 2 +- astroquery/xmatch/tests/test_xmatch.py | 2 +- 36 files changed, 40 insertions(+), 40 deletions(-) diff --git a/astroquery/alfalfa/tests/test_alfalfa.py b/astroquery/alfalfa/tests/test_alfalfa.py index 6ee31f6031..d6da174ca0 100644 --- a/astroquery/alfalfa/tests/test_alfalfa.py +++ b/astroquery/alfalfa/tests/test_alfalfa.py @@ -15,7 +15,7 @@ class MockResponseAlfalfa(MockResponse): def __init__(self, content, **kwargs): - super(MockResponseAlfalfa, self).__init__(content, **kwargs) + super().__init__(content, **kwargs) def iter_lines(self): for line in self.text.split("\n"): diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py index 0ccced8a26..54224d86f5 100644 --- a/astroquery/alma/core.py +++ b/astroquery/alma/core.py @@ -193,7 +193,7 @@ class AlmaClass(QueryWithLogin): def __init__(self): # sia service does not need disambiguation but tap does - super(AlmaClass, self).__init__() + super().__init__() self._sia = None self._tap = None self._datalink = None diff --git a/astroquery/astrometry_net/core.py b/astroquery/astrometry_net/core.py index 6476d6566d..dd7ed52e9e 100644 --- a/astroquery/astrometry_net/core.py +++ b/astroquery/astrometry_net/core.py @@ -104,7 +104,7 @@ def show_allowed_settings(self): def __init__(self): """ Show a warning message if the API key is not in the configuration file. """ - super(AstrometryNetClass, self).__init__() + super().__init__() if not conf.api_key: log.warning("Astrometry.net API key not found in configuration file") log.warning("You need to manually edit the configuration file and add it") diff --git a/astroquery/atomic/core.py b/astroquery/atomic/core.py index 0e8a5f72bb..0968681fe0 100644 --- a/astroquery/atomic/core.py +++ b/astroquery/atomic/core.py @@ -26,7 +26,7 @@ class AtomicLineListClass(BaseQuery): TIMEOUT = conf.timeout def __init__(self): - super(AtomicLineListClass, self).__init__() + super().__init__() self.__default_form_values = None def query_object(self, *, wavelength_range=None, wavelength_type=None, wavelength_accuracy=None, element_spectrum=None, diff --git a/astroquery/besancon/core.py b/astroquery/besancon/core.py index dc890ac17e..1d5821742a 100644 --- a/astroquery/besancon/core.py +++ b/astroquery/besancon/core.py @@ -87,7 +87,7 @@ class BesanconClass(BaseQuery): result_re = re.compile(r"[0-9]{10}\.[0-9]{6}\.resu") def __init__(self, email=None): - super(BesanconClass, self).__init__() + super().__init__() self.email = email def get_besancon_model_file(self, filename, verbose=True, timeout=5.0): diff --git a/astroquery/besancon/tests/test_besancon.py b/astroquery/besancon/tests/test_besancon.py index 0254864cbf..7ed5d2d124 100644 --- a/astroquery/besancon/tests/test_besancon.py +++ b/astroquery/besancon/tests/test_besancon.py @@ -105,6 +105,6 @@ def test_default_params(): class MockResponseBesancon(MockResponse): def __init__(self, content=None, url=None, headers={}, **kwargs): - super(MockResponseBesancon, self).__init__(content) + super().__init__(content) self.raw = url # StringIO.StringIO(url) self.headers = headers diff --git a/astroquery/cadc/core.py b/astroquery/cadc/core.py index e1d74caec5..03df96b24a 100644 --- a/astroquery/cadc/core.py +++ b/astroquery/cadc/core.py @@ -88,7 +88,7 @@ def __init__(self, url=None, auth_session=None): Cadc object """ - super(CadcClass, self).__init__() + super().__init__() self.baseurl = url # _auth_session contains the credentials that are used by both # the cadc tap and cadc datalink services diff --git a/astroquery/casda/core.py b/astroquery/casda/core.py index 15f80d5f1e..6d9b074f9c 100644 --- a/astroquery/casda/core.py +++ b/astroquery/casda/core.py @@ -50,7 +50,7 @@ class CasdaClass(BaseQuery): _uws_ns = {'uws': 'http://www.ivoa.net/xml/UWS/v1.0'} def __init__(self, user=None, password=None): - super(CasdaClass, self).__init__() + super().__init__() if user is None: self._authenticated = False else: diff --git a/astroquery/cds/core.py b/astroquery/cds/core.py index 69ee33a5bd..a873d04634 100644 --- a/astroquery/cds/core.py +++ b/astroquery/cds/core.py @@ -52,7 +52,7 @@ class CdsClass(BaseQuery): TIMEOUT = conf.timeout def __init__(self): - super(CdsClass, self).__init__() + super().__init__() self.path_moc_file = None self.return_moc = False diff --git a/astroquery/cosmosim/core.py b/astroquery/cosmosim/core.py index 6a3b763cd9..7604c625ac 100644 --- a/astroquery/cosmosim/core.py +++ b/astroquery/cosmosim/core.py @@ -40,7 +40,7 @@ class CosmoSimClass(QueryWithLogin): USERNAME = conf.username def __init__(self): - super(CosmoSimClass, self).__init__() + super().__init__() def _login(self, username=None, password=None, store_password=False, reenter_password=False): diff --git a/astroquery/esa/hubble/core.py b/astroquery/esa/hubble/core.py index 1530774786..98748c15f6 100644 --- a/astroquery/esa/hubble/core.py +++ b/astroquery/esa/hubble/core.py @@ -44,7 +44,7 @@ class ESAHubbleClass(BaseQuery): copying_string = "Copying file to {0}..." def __init__(self, tap_handler=None): - super(ESAHubbleClass, self).__init__() + super().__init__() if tap_handler is None: self._tap = TapPlus(url="http://hst.esac.esa.int" diff --git a/astroquery/esa/iso/core.py b/astroquery/esa/iso/core.py index 02ff7c7718..db618bf22c 100644 --- a/astroquery/esa/iso/core.py +++ b/astroquery/esa/iso/core.py @@ -31,7 +31,7 @@ class ISOClass(BaseQuery): TIMEOUT = conf.TIMEOUT def __init__(self, tap_handler=None): - super(ISOClass, self).__init__() + super().__init__() if tap_handler is None: self._tap = TapPlus(url=self.metadata_url) diff --git a/astroquery/esa/xmm_newton/core.py b/astroquery/esa/xmm_newton/core.py index 7d96d38834..be2660d462 100644 --- a/astroquery/esa/xmm_newton/core.py +++ b/astroquery/esa/xmm_newton/core.py @@ -38,7 +38,7 @@ class XMMNewtonClass(BaseQuery): TIMEOUT = conf.TIMEOUT def __init__(self, tap_handler=None): - super(XMMNewtonClass, self).__init__() + super().__init__() self.configuration = configparser.ConfigParser() if tap_handler is None: diff --git a/astroquery/esasky/core.py b/astroquery/esasky/core.py index 1faa8c57ab..64f7a449ab 100644 --- a/astroquery/esasky/core.py +++ b/astroquery/esasky/core.py @@ -80,7 +80,7 @@ class ESASkyClass(BaseQuery): 'DWARF_PLANET', 'SPACECRAFT', 'SPACEJUNK', 'EXOPLANET', 'STAR'] def __init__(self, tap_handler=None): - super(ESASkyClass, self).__init__() + super().__init__() if tap_handler is None: self._tap = TapPlus(url=self.URLbase + "/tap") diff --git a/astroquery/eso/core.py b/astroquery/eso/core.py index 4612757c7e..6c1568b5fb 100644 --- a/astroquery/eso/core.py +++ b/astroquery/eso/core.py @@ -43,7 +43,7 @@ class EsoClass(QueryWithLogin): QUERY_INSTRUMENT_URL = conf.query_instrument_url def __init__(self): - super(EsoClass, self).__init__() + super().__init__() self._instrument_list = None self._survey_list = None self.username = None diff --git a/astroquery/hips2fits/core.py b/astroquery/hips2fits/core.py index c48971fe2f..7f94c80ca1 100644 --- a/astroquery/hips2fits/core.py +++ b/astroquery/hips2fits/core.py @@ -57,7 +57,7 @@ class hips2fitsClass(BaseQuery): timeout = conf.timeout def __init__(self, *args): - super(hips2fitsClass, self).__init__() + super().__init__() def query_with_wcs(self, hips, wcs, format="fits", min_cut=0.5, max_cut=99.5, stretch="linear", cmap="Greys_r", get_query_payload=False, verbose=False): """ diff --git a/astroquery/hitran/core.py b/astroquery/hitran/core.py index 31b08e0e4e..cad75faaa0 100644 --- a/astroquery/hitran/core.py +++ b/astroquery/hitran/core.py @@ -149,7 +149,7 @@ def __init__(self, **kwargs): """ Initialize a Hitran query class. """ - super(HitranClass, self).__init__() + super().__init__() def _args_to_payload(self, molecule_number=1, isotopologue_number=1, min_frequency=None, max_frequency=None): diff --git a/astroquery/jplhorizons/core.py b/astroquery/jplhorizons/core.py index 272e7f97fa..5b513e12fd 100644 --- a/astroquery/jplhorizons/core.py +++ b/astroquery/jplhorizons/core.py @@ -89,7 +89,7 @@ def __init__(self, id=None, location=None, epochs=None, >>> print(eros) # doctest: +SKIP JPLHorizons instance "433"; location=568, epochs={'start': '2017-01-01', 'step': '1d', 'stop': '2017-02-01'}, id_type=None """ - super(HorizonsClass, self).__init__() + super().__init__() self.id = id self.location = location diff --git a/astroquery/lamda/core.py b/astroquery/lamda/core.py index e734f782a1..603070aa3e 100644 --- a/astroquery/lamda/core.py +++ b/astroquery/lamda/core.py @@ -39,7 +39,7 @@ class LamdaClass(BaseQuery): url = "http://home.strw.leidenuniv.nl/~moldata/datafiles/{0}.dat" def __init__(self, **kwargs): - super(LamdaClass, self).__init__(**kwargs) + super().__init__(**kwargs) self.moldict_path = os.path.join(self.cache_location, "molecules.json") diff --git a/astroquery/mast/discovery_portal.py b/astroquery/mast/discovery_portal.py index 63f7841d4a..50828055e4 100644 --- a/astroquery/mast/discovery_portal.py +++ b/astroquery/mast/discovery_portal.py @@ -129,7 +129,7 @@ class PortalAPI(BaseQuery): def __init__(self, session=None): - super(PortalAPI, self).__init__() + super().__init__() if session: self._session = session diff --git a/astroquery/mpc/core.py b/astroquery/mpc/core.py index 8f76f9a020..4f48d1d486 100644 --- a/astroquery/mpc/core.py +++ b/astroquery/mpc/core.py @@ -63,7 +63,7 @@ class MPCClass(BaseQuery): } def __init__(self): - super(MPCClass, self).__init__() + super().__init__() def query_object_async(self, target_type, get_query_payload=False, *args, **kwargs): """ diff --git a/astroquery/nasa_ads/core.py b/astroquery/nasa_ads/core.py index 053b047ce0..7ae64fc2b1 100644 --- a/astroquery/nasa_ads/core.py +++ b/astroquery/nasa_ads/core.py @@ -39,7 +39,7 @@ class ADSClass(BaseQuery): def __init__(self, *args): """ set some parameters """ - super(ADSClass, self).__init__() + super().__init__() @class_or_instance def query_simple(self, query_string, get_query_payload=False, diff --git a/astroquery/ogle/core.py b/astroquery/ogle/core.py index 47b49ea976..252ae0d2a8 100644 --- a/astroquery/ogle/core.py +++ b/astroquery/ogle/core.py @@ -40,7 +40,7 @@ def wrapper(*args, **kwargs): class CoordParseError(ValueError): def __init__(self, message='Could not parse `coord` argument.', **kwargs): - super(ValueError, self).__init__(message, **kwargs) + super().__init__(message, **kwargs) @async_to_sync diff --git a/astroquery/query.py b/astroquery/query.py index ab7198464e..0924949ea0 100644 --- a/astroquery/query.py +++ b/astroquery/query.py @@ -146,7 +146,7 @@ class LoginABCMeta(abc.ABCMeta): """ def __new__(cls, name, bases, attrs): - newcls = super(LoginABCMeta, cls).__new__(cls, name, bases, attrs) + newcls = super().__new__(cls, name, bases, attrs) if '_login' in attrs and name not in ('BaseQuery', 'QueryWithLogin'): # skip theses two classes, BaseQuery and QueryWithLogin, so @@ -473,7 +473,7 @@ class QueryWithLogin(BaseQuery): """ def __init__(self): - super(QueryWithLogin, self).__init__() + super().__init__() self._authenticated = False def _get_password(self, service_name, username, reenter=False): diff --git a/astroquery/simbad/tests/test_simbad.py b/astroquery/simbad/tests/test_simbad.py index a5071aa3d1..63c39059ce 100644 --- a/astroquery/simbad/tests/test_simbad.py +++ b/astroquery/simbad/tests/test_simbad.py @@ -40,7 +40,7 @@ class MockResponseSimbad(MockResponse): def __init__(self, script, cache=False, **kwargs): # preserve, e.g., headers - super(MockResponseSimbad, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = self.get_content(script) def get_content(self, script): diff --git a/astroquery/skyview/core.py b/astroquery/skyview/core.py index fb8ee02f58..2cbf6f6734 100644 --- a/astroquery/skyview/core.py +++ b/astroquery/skyview/core.py @@ -20,7 +20,7 @@ class SkyViewClass(BaseQuery): URL = conf.url def __init__(self): - super(SkyViewClass, self).__init__() + super().__init__() self._default_form_values = None def _get_default_form_values(self, form): diff --git a/astroquery/skyview/tests/test_skyview.py b/astroquery/skyview/tests/test_skyview.py index 467e0a030a..464697bdea 100644 --- a/astroquery/skyview/tests/test_skyview.py +++ b/astroquery/skyview/tests/test_skyview.py @@ -35,7 +35,7 @@ def fromname(self, name): class MockResponseSkyView(MockResponse): def __init__(self): - super(MockResponseSkyView, self).__init__() + super().__init__() def get_content(self): return self.content @@ -43,7 +43,7 @@ def get_content(self): class MockResponseSkyviewForm(MockResponse): def __init__(self, method, url, cache=False, params=None, **kwargs): - super(MockResponseSkyviewForm, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = self.get_content(method, url) def get_content(self, method, url): diff --git a/astroquery/splatalogue/core.py b/astroquery/splatalogue/core.py index 7430e5d409..a1b44a94ca 100644 --- a/astroquery/splatalogue/core.py +++ b/astroquery/splatalogue/core.py @@ -65,7 +65,7 @@ def __init__(self, **kwargs): default keyword arguments (see `query_lines`) can be overridden here. """ - super(SplatalogueClass, self).__init__() + super().__init__() self.data = self._default_kwargs() self.set_default_options(**kwargs) diff --git a/astroquery/utils/commons.py b/astroquery/utils/commons.py index 47e6b4e210..ab2966ed1a 100644 --- a/astroquery/utils/commons.py +++ b/astroquery/utils/commons.py @@ -246,12 +246,12 @@ def __init__(self, inp): "or list of (k,v) pairs") self._dict = inp - super(TableList, self).__init__(inp.values()) + super().__init__(inp.values()) def __getitem__(self, key): if isinstance(key, int): # get the value in the (key,value) pair - return super(TableList, self).__getitem__(key) + return super().__getitem__(key) elif key in self._dict: return self._dict[key] else: diff --git a/astroquery/vamdc/core.py b/astroquery/vamdc/core.py index 3dcfa22849..cb90d28ca2 100644 --- a/astroquery/vamdc/core.py +++ b/astroquery/vamdc/core.py @@ -23,7 +23,7 @@ class VamdcClass(BaseQuery): CACHE_LOCATION = conf.cache_location def __init__(self, doimport=True): - super(VamdcClass, self).__init__() + super().__init__() if not doimport: # this is a hack to allow the docstrings to be produced without diff --git a/astroquery/vizier/core.py b/astroquery/vizier/core.py index ba55fe4e23..e27accf2ad 100644 --- a/astroquery/vizier/core.py +++ b/astroquery/vizier/core.py @@ -74,7 +74,7 @@ def __init__(self, columns=["*"], column_filters={}, catalog=None, (This parameter's default is set from a configuration object.) """ - super(VizierClass, self).__init__() + super().__init__() self.columns = columns self.column_filters = column_filters self.catalog = catalog diff --git a/astroquery/vo_conesearch/conesearch.py b/astroquery/vo_conesearch/conesearch.py index 1ee58c77d9..c71b7ff0dc 100644 --- a/astroquery/vo_conesearch/conesearch.py +++ b/astroquery/vo_conesearch/conesearch.py @@ -76,7 +76,7 @@ class AsyncConeSearch(AsyncBase): """ def __init__(self, *args, **kwargs): - super(AsyncConeSearch, self).__init__(conesearch, *args, **kwargs) + super().__init__(conesearch, *args, **kwargs) def conesearch(center, radius, *, verb=1, catalog_db=None, diff --git a/astroquery/vo_conesearch/core.py b/astroquery/vo_conesearch/core.py index 4e44a243f1..e13b109eb5 100644 --- a/astroquery/vo_conesearch/core.py +++ b/astroquery/vo_conesearch/core.py @@ -49,7 +49,7 @@ class ConeSearchClass(BaseQuery): """ def __init__(self): - super(ConeSearchClass, self).__init__() + super().__init__() def query_region_async(self, *args, **kwargs): """ diff --git a/astroquery/vo_conesearch/vos_catalog.py b/astroquery/vo_conesearch/vos_catalog.py index f942d15ba1..61150d9ee3 100644 --- a/astroquery/vo_conesearch/vos_catalog.py +++ b/astroquery/vo_conesearch/vos_catalog.py @@ -99,7 +99,7 @@ class VOSCatalog(VOSBase): _compulsory_keys = ('title', 'url') def __init__(self, tree): - super(VOSCatalog, self).__init__(tree) + super().__init__(tree) for key in self._compulsory_keys: if key not in self._tree: @@ -187,7 +187,7 @@ def __init__(self, tree): if 'catalogs' not in tree: raise VOSError("Invalid VO service catalog database") - super(VOSDatabase, self).__init__(tree) + super().__init__(tree) self._catalogs = tree['catalogs'] if self.version > __dbversion__: # pragma: no cover diff --git a/astroquery/wfau/core.py b/astroquery/wfau/core.py index 283453f633..8f07ea8423 100644 --- a/astroquery/wfau/core.py +++ b/astroquery/wfau/core.py @@ -41,7 +41,7 @@ def __init__(self, username=None, password=None, community=None, """ The BaseWFAUClass __init__ is meant to be overwritten """ - super(BaseWFAUClass, self).__init__() + super().__init__() self.database = database self.programme_id = programme_id self.session = None diff --git a/astroquery/xmatch/tests/test_xmatch.py b/astroquery/xmatch/tests/test_xmatch.py index 8d1024dbca..7e2582848b 100644 --- a/astroquery/xmatch/tests/test_xmatch.py +++ b/astroquery/xmatch/tests/test_xmatch.py @@ -21,7 +21,7 @@ class MockResponseXmatch(MockResponse): def __init__(self, method, url, data, **kwargs): - super(MockResponseXmatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.data = data fn = data_path(DATA_FILES[method.lower()]) From c20b1397defea915d9633a6a66bb9c32831cf170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Wed, 4 May 2022 20:18:52 -0700 Subject: [PATCH 3/5] PEP 3151 --- astroquery/image_cutouts/first/core.py | 2 +- astroquery/magpis/core.py | 2 +- astroquery/nasa_ads/core.py | 2 +- astroquery/query.py | 2 +- astroquery/utils/commons.py | 2 +- astroquery/utils/download_file_list.py | 4 ++-- astroquery/utils/progressbar.py | 2 +- astroquery/vo_conesearch/validator/validate.py | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/astroquery/image_cutouts/first/core.py b/astroquery/image_cutouts/first/core.py index 93db7dfc2a..7a3eaff834 100644 --- a/astroquery/image_cutouts/first/core.py +++ b/astroquery/image_cutouts/first/core.py @@ -67,7 +67,7 @@ def get_images(self, coordinates, image_size=1 * u.arcmin, S = BytesIO(response.content) try: return fits.open(S, ignore_missing_end=True) - except IOError: + except OSError: raise InvalidQueryError(response.content) @prepend_docstr_nosections("\n" + _args_to_payload.__doc__) diff --git a/astroquery/magpis/core.py b/astroquery/magpis/core.py index 8ad591b92a..99536f76f4 100644 --- a/astroquery/magpis/core.py +++ b/astroquery/magpis/core.py @@ -90,7 +90,7 @@ def get_images(self, coordinates, image_size=1 * u.arcmin, content_buffer = BytesIO(response.content) try: return fits.open(content_buffer, ignore_missing_end=True) - except IOError: + except OSError: raise InvalidQueryError(response.content) @prepend_docstr_nosections("\n" + _args_to_payload.__doc__) diff --git a/astroquery/nasa_ads/core.py b/astroquery/nasa_ads/core.py index 7ae64fc2b1..8ddfdff3e6 100644 --- a/astroquery/nasa_ads/core.py +++ b/astroquery/nasa_ads/core.py @@ -123,7 +123,7 @@ def _get_token(self): with open(token_file) as f: self.TOKEN = f.read().strip() return self.TOKEN - except IOError: + except OSError: raise RuntimeError('No API token found! Get yours from: ' 'https://ui.adsabs.harvard.edu/#user/settings/token ' 'and store it in the API_DEV_KEY environment variable.') diff --git a/astroquery/query.py b/astroquery/query.py index 0924949ea0..fd8dfed5c1 100644 --- a/astroquery/query.py +++ b/astroquery/query.py @@ -114,7 +114,7 @@ def from_cache(self, cache_location): response = pickle.load(f) if not isinstance(response, requests.Response): response = None - except IOError: # TODO: change to FileNotFoundError once drop py2 support + except OSError: # TODO: change to FileNotFoundError once drop py2 support response = None if response: log.debug("Retrieving data from {0}".format(request_file)) diff --git a/astroquery/utils/commons.py b/astroquery/utils/commons.py index ab2966ed1a..649c78f744 100644 --- a/astroquery/utils/commons.py +++ b/astroquery/utils/commons.py @@ -408,7 +408,7 @@ def save_fits(self, savepath, link_cache='hard'): if link_cache == 'hard': try: os.link(target, savepath) - except (IOError, OSError, AttributeError): + except (OSError, AttributeError): shutil.copy(target, savepath) elif link_cache == 'sym': try: diff --git a/astroquery/utils/download_file_list.py b/astroquery/utils/download_file_list.py index 1ab484dea0..36d67bc6a0 100644 --- a/astroquery/utils/download_file_list.py +++ b/astroquery/utils/download_file_list.py @@ -71,7 +71,7 @@ def download_list_of_fitsfiles(linklist, output_directory=None, try: # try to open as a fits file fitsfile = fits.open(S, ignore_missing_end=True) - except IOError: + except OSError: # if that fails, try to open as a gzip'd fits file # have to rewind to the start S.seek(0) @@ -117,7 +117,7 @@ def download_list_of_fitsfiles(linklist, output_directory=None, try: fitsfile.writeto(final_file, clobber=overwrite) - except IOError: + except OSError: print("Skipped writing file {0} because it exists " "and overwrite=False".format(final_file)) diff --git a/astroquery/utils/progressbar.py b/astroquery/utils/progressbar.py index 5cf8026e0d..28a4c4f87c 100644 --- a/astroquery/utils/progressbar.py +++ b/astroquery/utils/progressbar.py @@ -66,7 +66,7 @@ def retrieve(url, outfile, opener=None, overwrite=False): S = StringIO(results) try: fitsfile = fits.open(S, ignore_missing_end=True) - except IOError: + except OSError: S.seek(0) G = gzip.GzipFile(fileobj=S) fitsfile = fits.open(G, ignore_missing_end=True) diff --git a/astroquery/vo_conesearch/validator/validate.py b/astroquery/vo_conesearch/validator/validate.py index 6383a860b7..3ba21a1475 100644 --- a/astroquery/vo_conesearch/validator/validate.py +++ b/astroquery/vo_conesearch/validator/validate.py @@ -72,7 +72,7 @@ def check_conesearch_sites(destdir=os.curdir, verbose=True, parallel=True, Raises ------ - IOError + OSError Invalid destination directory. timeout @@ -87,7 +87,7 @@ def check_conesearch_sites(destdir=os.curdir, verbose=True, parallel=True, if (not isinstance(destdir, str) or len(destdir) == 0 or os.path.exists(destdir) and not os.path.isdir(destdir)): - raise IOError('Invalid destination directory') # pragma: no cover + raise OSError('Invalid destination directory') # pragma: no cover if not os.path.exists(destdir): os.mkdir(destdir) From 70419fe3ddf3058ff752406fa178dafd8b5e76a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 5 May 2022 10:56:23 -0700 Subject: [PATCH 4/5] Some more cleanup for classes --- astroquery/esa/hsa/tests/dummy_handler.py | 2 +- astroquery/esa/hsa/tests/dummy_tap_handler.py | 2 +- astroquery/esa/hsa/tests/test_hsa.py | 2 +- astroquery/esa/iso/tests/dummy_handler.py | 2 +- astroquery/esa/iso/tests/dummy_tap_handler.py | 2 +- astroquery/esa/iso/tests/test_iso.py | 2 +- astroquery/esa/xmm_newton/tests/test_xmm_newton.py | 4 ++-- astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py | 2 +- astroquery/gaia/tests/test_gaiatap.py | 2 +- astroquery/hips2fits/tests/test_hips2fits.py | 2 +- astroquery/hips2fits/tests/test_hips2fits_remote.py | 2 +- astroquery/vizier/tests/test_vizier_remote.py | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/astroquery/esa/hsa/tests/dummy_handler.py b/astroquery/esa/hsa/tests/dummy_handler.py index 932f5784b7..bc54d93fb8 100644 --- a/astroquery/esa/hsa/tests/dummy_handler.py +++ b/astroquery/esa/hsa/tests/dummy_handler.py @@ -3,7 +3,7 @@ __all__ = ['DummyHandler'] -class DummyHandler(): +class DummyHandler: def __init__(self, method, parameters): self._invokedMethod = method diff --git a/astroquery/esa/hsa/tests/dummy_tap_handler.py b/astroquery/esa/hsa/tests/dummy_tap_handler.py index f5d29f6cd6..eaaac1cb8e 100644 --- a/astroquery/esa/hsa/tests/dummy_tap_handler.py +++ b/astroquery/esa/hsa/tests/dummy_tap_handler.py @@ -4,7 +4,7 @@ from ....utils.tap.model.job import Job -class DummyHSATapHandler(): +class DummyHSATapHandler: def __init__(self, method, parameters): self.__invokedMethod = method diff --git a/astroquery/esa/hsa/tests/test_hsa.py b/astroquery/esa/hsa/tests/test_hsa.py index 4409c0f429..c7e1b234f7 100644 --- a/astroquery/esa/hsa/tests/test_hsa.py +++ b/astroquery/esa/hsa/tests/test_hsa.py @@ -8,7 +8,7 @@ from ..tests.dummy_tap_handler import DummyHSATapHandler -class TestHSA(): +class TestHSA: def get_dummy_tap_handler(self): parameterst = {'query': "select top 10 * from hsa.v_active_observation", diff --git a/astroquery/esa/iso/tests/dummy_handler.py b/astroquery/esa/iso/tests/dummy_handler.py index 0717ad1811..a6b108d832 100644 --- a/astroquery/esa/iso/tests/dummy_handler.py +++ b/astroquery/esa/iso/tests/dummy_handler.py @@ -12,7 +12,7 @@ __all__ = ['DummyHandler'] -class DummyHandler(): +class DummyHandler: def __init__(self, method, parameters): self._invokedMethod = method diff --git a/astroquery/esa/iso/tests/dummy_tap_handler.py b/astroquery/esa/iso/tests/dummy_tap_handler.py index 623f9ff3a8..0b016e5e92 100644 --- a/astroquery/esa/iso/tests/dummy_tap_handler.py +++ b/astroquery/esa/iso/tests/dummy_tap_handler.py @@ -13,7 +13,7 @@ from ....utils.tap.model.job import Job -class DummyISOTapHandler(): +class DummyISOTapHandler: def __init__(self, method, parameters): self.__invokedMethod = method diff --git a/astroquery/esa/iso/tests/test_iso.py b/astroquery/esa/iso/tests/test_iso.py index 3cd7620203..28f01614ea 100644 --- a/astroquery/esa/iso/tests/test_iso.py +++ b/astroquery/esa/iso/tests/test_iso.py @@ -15,7 +15,7 @@ from astroquery.esa.iso.tests.dummy_tap_handler import DummyISOTapHandler -class TestISO(): +class TestISO: def get_dummy_tap_handler(self): parameters = {'query': "select top 10 * from ida.observations", diff --git a/astroquery/esa/xmm_newton/tests/test_xmm_newton.py b/astroquery/esa/xmm_newton/tests/test_xmm_newton.py index e08ff4e1f0..5fa58e7ce5 100644 --- a/astroquery/esa/xmm_newton/tests/test_xmm_newton.py +++ b/astroquery/esa/xmm_newton/tests/test_xmm_newton.py @@ -25,7 +25,7 @@ def data_path(filename): return os.path.join(data_dir, filename) -class mockResponse(): +class mockResponse: headers = {'Date': 'Wed, 24 Nov 2021 13:43:50 GMT', 'Server': 'Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips', 'Content-Disposition': 'inline; filename="0560181401.tar.gz"', @@ -38,7 +38,7 @@ def raise_for_status(): pass -class TestXMMNewton(): +class TestXMMNewton: def get_dummy_tap_handler(self): parameters = {'query': "select top 10 * from v_public_observations", 'output_file': "test2.vot", diff --git a/astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py b/astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py index 15b9a50ba8..48069d85df 100644 --- a/astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py +++ b/astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py @@ -22,7 +22,7 @@ from ..tests.dummy_tap_handler import DummyXMMNewtonTapHandler -class TestXMMNewtonRemote(): +class TestXMMNewtonRemote: _files = { "0405320501": { "pps": [ diff --git a/astroquery/gaia/tests/test_gaiatap.py b/astroquery/gaia/tests/test_gaiatap.py index 678b205653..4548a2fd5d 100644 --- a/astroquery/gaia/tests/test_gaiatap.py +++ b/astroquery/gaia/tests/test_gaiatap.py @@ -39,7 +39,7 @@ def data_path(filename): return os.path.join(data_dir, filename) -class TestTap(): +class TestTap: def test_query_object(self): conn_handler = DummyConnHandler() diff --git a/astroquery/hips2fits/tests/test_hips2fits.py b/astroquery/hips2fits/tests/test_hips2fits.py index 29a6620f0a..11e19f50e3 100644 --- a/astroquery/hips2fits/tests/test_hips2fits.py +++ b/astroquery/hips2fits/tests/test_hips2fits.py @@ -15,7 +15,7 @@ import astropy.units as u -class TestHips2fitsRemote(): +class TestHips2fitsRemote: # Create a new WCS astropy object w = astropy_wcs.WCS(header={ diff --git a/astroquery/hips2fits/tests/test_hips2fits_remote.py b/astroquery/hips2fits/tests/test_hips2fits_remote.py index 0c8369ed18..cbc2699e13 100644 --- a/astroquery/hips2fits/tests/test_hips2fits_remote.py +++ b/astroquery/hips2fits/tests/test_hips2fits_remote.py @@ -15,7 +15,7 @@ @pytest.mark.remote_data -class TestHips2fitsRemote(): +class TestHips2fitsRemote: # Create a new WCS astropy object w = astropy_wcs.WCS(header={ diff --git a/astroquery/vizier/tests/test_vizier_remote.py b/astroquery/vizier/tests/test_vizier_remote.py index f62f73f0fd..f500c21617 100644 --- a/astroquery/vizier/tests/test_vizier_remote.py +++ b/astroquery/vizier/tests/test_vizier_remote.py @@ -8,7 +8,7 @@ @pytest.mark.remote_data -class TestVizierRemote(): +class TestVizierRemote: target = commons.ICRSCoordGenerator(ra=299.590, dec=35.201, unit=(u.deg, u.deg)) From 9d5a6a673eb05471e63839311e17b090de15292b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 5 May 2022 11:14:19 -0700 Subject: [PATCH 5/5] Being more specific for FileNotFoundError --- astroquery/query.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/astroquery/query.py b/astroquery/query.py index fd8dfed5c1..b8cd1bc9c5 100644 --- a/astroquery/query.py +++ b/astroquery/query.py @@ -114,7 +114,7 @@ def from_cache(self, cache_location): response = pickle.load(f) if not isinstance(response, requests.Response): response = None - except OSError: # TODO: change to FileNotFoundError once drop py2 support + except FileNotFoundError: response = None if response: log.debug("Retrieving data from {0}".format(request_file)) @@ -130,8 +130,8 @@ def remove_cache_file(self, cache_location): if os.path.exists(request_file): os.remove(request_file) else: - raise OSError(f"Tried to remove cache file {request_file} but " - "it does not exist") + raise FileNotFoundError(f"Tried to remove cache file {request_file} but " + "it does not exist") class LoginABCMeta(abc.ABCMeta):