Skip to content

Commit f32a0d5

Browse files
authored
Merge pull request #2165 from eerovaher/rm-six
Remove `six`
2 parents 729cf6d + f0f6a6a commit f32a0d5

File tree

43 files changed

+97
-148
lines changed

Some content is hidden

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

43 files changed

+97
-148
lines changed

astroquery/alma/core.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from bs4 import BeautifulSoup
1313
import pyvo
1414

15-
from six.moves.urllib_parse import urljoin
16-
import six
15+
from urllib.parse import urljoin
1716
from astropy.table import Table, Column, vstack
1817
from astroquery import log
1918
from astropy.utils import deprecated
@@ -567,7 +566,7 @@ def get_data_info(self, uids, expand_tarfiles=False,
567566
"""
568567
if uids is None:
569568
raise AttributeError('UIDs required')
570-
if isinstance(uids, six.string_types + (np.bytes_,)):
569+
if isinstance(uids, (str, bytes)):
571570
uids = [uids]
572571
if not isinstance(uids, (list, tuple, np.ndarray)):
573572
raise TypeError("Datasets must be given as a list of strings.")
@@ -811,7 +810,7 @@ def retrieve_data_from_uid(self, uids, cache=True):
811810
downloaded_files : list
812811
A list of the downloaded file paths
813812
"""
814-
if isinstance(uids, six.string_types + (np.bytes_,)):
813+
if isinstance(uids, (str, bytes)):
815814
uids = [uids]
816815
if not isinstance(uids, (list, tuple, np.ndarray)):
817816
raise TypeError("Datasets must be given as a list of strings.")
@@ -1073,7 +1072,7 @@ def download_and_extract_files(self, urls, delete=True, regex=r'.*\.fits$',
10731072
data from an ASDM tarball
10741073
"""
10751074

1076-
if isinstance(urls, six.string_types):
1075+
if isinstance(urls, str):
10771076
urls = [urls]
10781077
if not isinstance(urls, (list, tuple, np.ndarray)):
10791078
raise TypeError("Datasets must be given as a list of strings.")
@@ -1174,7 +1173,6 @@ def _json_summary_to_table(self, data, base_url):
11741173
March 2020 - should be removed along with stage_data_prefeb2020
11751174
"""
11761175
from ..utils import url_helpers
1177-
from six import iteritems
11781176
columns = {'mous_uid': [], 'URL': [], 'size': []}
11791177
for entry in data['node_data']:
11801178
# de_type can be useful (e.g., MOUS), but it is not necessarily
@@ -1212,7 +1210,7 @@ def _json_summary_to_table(self, data, base_url):
12121210

12131211
columns['size'] = u.Quantity(columns['size'], u.Gbyte)
12141212

1215-
tbl = Table([Column(name=k, data=v) for k, v in iteritems(columns)])
1213+
tbl = Table([Column(name=k, data=v) for k, v in columns.items()])
12161214
return tbl
12171215

12181216
def get_project_metadata(self, projectid, cache=True):

astroquery/alma/tests/test_alma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
from io import StringIO
23
import os
34

45
import pytest
56
from unittest.mock import patch, Mock
6-
from six import StringIO
77

88
from astropy import units as u
99
from astropy import coordinates as coord

astroquery/astrometry_net/core.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import json
55

6-
import six
7-
from six import string_types
86
from astropy.io import fits
97
from astroquery import log
108
from astropy.stats import sigma_clipped_stats
@@ -137,7 +135,7 @@ def _validate_settings(self, settings):
137135
"""
138136

139137
# Check the types and values
140-
for key, value in six.iteritems(settings):
138+
for key, value in settings.items():
141139
if key not in self._constraints or value is None:
142140
message = ('Setting {} is not allowed. Display all of '
143141
'the allowed settings with: '
@@ -284,7 +282,7 @@ def solve_from_source_list(self, x, y, image_width, image_height,
284282
For a list of the remaining settings, use the method
285283
`~AstrometryNetClass.show_allowed_settings`.
286284
"""
287-
settings = {k: v for k, v in six.iteritems(settings) if v is not None}
285+
settings = {k: v for k, v in settings.items() if v is not None}
288286
self._validate_settings(settings)
289287
if self._session_id is None:
290288
self._login()
@@ -363,7 +361,7 @@ def solve_from_image(self, image_file_path, force_image_upload=False,
363361
settings['center_ra'] = center.ra.degree
364362
settings['center_dec'] = center.dec.degree
365363

366-
settings = {k: v for k, v in six.iteritems(settings) if v is not None}
364+
settings = {k: v for k, v in settings.items() if v is not None}
367365
self._validate_settings(settings)
368366

369367
if force_image_upload or self._no_source_detector:

astroquery/astrometry_net/tests/test_astrometry_net.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from distutils.version import LooseVersion
55

66
import pytest
7-
import six
87

98
from ...utils.testing_tools import MockResponse
109
from ...exceptions import (InvalidQueryError)
@@ -87,7 +86,7 @@ def test_setting_validation_basic():
8786
anet = AstrometryNet()
8887
# This gets us a list of settings, their types, and restrictions.
8988
constraints = anet._constraints
90-
for constraint, vals in six.iteritems(constraints):
89+
for constraint, vals in constraints.items():
9190
if vals['type'] == str or vals['type'] == bool:
9291
settings = {constraint: 'asdiuhiuas'}
9392
with pytest.raises(ValueError) as e:

astroquery/atomic/core.py

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

3-
from six.moves.urllib import parse as urlparse
4-
from six.moves import map, zip
5-
from six import StringIO
6-
import six
3+
from io import StringIO
4+
from urllib import parse as urlparse
75

86
from collections import defaultdict
97

@@ -292,7 +290,7 @@ def _submit_form(self, input=None, cache=True):
292290
# only overwrite payload's values if the `input` value is not None
293291
# to avoid overwriting of the form's default values
294292
payload = self._default_form_values.copy()
295-
for k, v in six.iteritems(input):
293+
for k, v in input.items():
296294
if v is not None:
297295
payload[k] = v
298296
url = urlparse.urljoin(self.FORM_URL, self._default_form.get('action'))
@@ -346,7 +344,7 @@ def _get_default_form_values(self, form):
346344

347345
# avoid values with size 1 lists
348346
d = dict(res)
349-
for k, v in six.iteritems(d):
347+
for k, v in d.items():
350348
if len(v) == 1:
351349
d[k] = v[0]
352350
return d

astroquery/besancon/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import warnings
1010
from astropy.io import ascii
11-
from six.moves.urllib_error import URLError
11+
from urllib.error import URLError
1212
from collections import OrderedDict
1313
from ..query import BaseQuery
1414
from ..utils import commons, prepend_docstr_nosections, async_to_sync

astroquery/besancon/tests/test_besancon.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from contextlib import contextmanager
55
import pytest
66
from astropy.io.ascii.tests.common import assert_equal
7-
from six import string_types
87
from ... import besancon
98
from ...utils import commons
109
from ...utils.testing_tools import MockResponse
@@ -65,7 +64,7 @@ def patch_post(request):
6564
def patch_get_readable_fileobj(request):
6665
@contextmanager
6766
def get_readable_fileobj_mockreturn(filename, **kwargs):
68-
if isinstance(filename, string_types):
67+
if isinstance(filename, str):
6968
if '1376235131.430670' in filename:
7069
is_binary = kwargs.get('encoding', None) == 'binary'
7170
file_obj = open(data_path('1376235131.430670.resu'),

astroquery/cadc/tests/test_cadctap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
=============
66
77
"""
8+
from io import BytesIO
9+
from urllib.parse import urlsplit, parse_qs
810
import os
911
import sys
1012

1113
from astropy.table import Table as AstroTable
1214
from astropy.io.fits.hdu.hdulist import HDUList
1315
from astropy.io.votable.tree import VOTableFile, Resource, Table, Field
1416
from astropy.io.votable import parse
15-
from six import BytesIO
16-
from six.moves.urllib_parse import urlsplit, parse_qs
1717
from astroquery.utils.commons import parse_coordinates, FileContainer
1818
from astropy import units as u
1919
from astropy.utils.exceptions import AstropyDeprecationWarning

astroquery/cosmosim/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import re
1313
import os
1414
import threading
15-
from six.moves.email_mime_multipart import MIMEMultipart
16-
from six.moves.email_mime_base import MIMEBase, message
17-
from six.moves.email_mime_text import MIMEText
15+
from email.mime.multipart import MIMEMultipart
16+
from email.mime.base import MIMEBase, message
17+
from email.mime.text import MIMEText
1818

1919
# Astropy imports
2020
from astropy.table import Table

astroquery/esa/hubble/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from astroquery.utils.tap.model import modelutils
2626
from astroquery.query import BaseQuery
2727
from astropy.table import Table
28-
from six import BytesIO
28+
from io import BytesIO
2929
import shutil
3030
import os
3131
import json

0 commit comments

Comments
 (0)