Skip to content

Commit cb57f54

Browse files
mhvkbsipocz
authored andcommitted
Merge pull request #7617 from saimn/py37
Fixes for Python 3.7
1 parent cda666d commit cb57f54

5 files changed

Lines changed: 31 additions & 14 deletions

File tree

‎astropy/__init__.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,17 @@ def online_help(query):
318318
webbrowser.open(url)
319319

320320

321-
__dir__ = ['__version__', '__githash__', '__minimum_numpy_version__',
322-
'__bibtex__', 'test', 'log', 'find_api_page', 'online_help',
323-
'online_docs_root', 'conf']
321+
__dir_inc__ = ['__version__', '__githash__', '__minimum_numpy_version__',
322+
'__bibtex__', 'test', 'log', 'find_api_page', 'online_help',
323+
'online_docs_root', 'conf']
324324

325325

326326
from types import ModuleType as __module_type__
327-
# Clean up top-level namespace--delete everything that isn't in __dir__
327+
# Clean up top-level namespace--delete everything that isn't in __dir_inc__
328328
# or is a magic attribute, and that isn't a submodule of this package
329329
for varname in dir():
330330
if not ((varname.startswith('__') and varname.endswith('__')) or
331-
varname in __dir__ or
331+
varname in __dir_inc__ or
332332
(varname[0] != '_' and
333333
isinstance(locals()[varname], __module_type__) and
334334
locals()[varname].__name__.startswith(__name__ + '.'))):

‎astropy/io/ascii/misc.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99

10-
import collections
10+
import collections.abc
1111
import itertools
1212
import operator
1313

@@ -95,10 +95,10 @@ def sortmore(*args, **kw):
9595
if globalkey is None:
9696
globalkey = lambda *x: 0
9797

98-
if not isinstance(globalkey, collections.Callable):
98+
if not isinstance(globalkey, collections.abc.Callable):
9999
raise ValueError('globalkey needs to be callable')
100100

101-
if isinstance(key, collections.Callable):
101+
if isinstance(key, collections.abc.Callable):
102102
k = lambda x: (globalkey(*x), key(x[0]))
103103
elif isinstance(key, tuple):
104104
key = (k if k else lambda x: 0 for k in key)

‎astropy/io/fits/tests/test_fitstime.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def test_io_time_read_fits_location(self, table_types):
301301
assert isinstance(tm['datetime'], Time)
302302
assert tm['datetime'].location.lon.value == 0
303303
assert tm['datetime'].location.lat.value == 0
304-
assert tm['datetime'].location.height.value == 0
304+
assert np.isclose(tm['datetime'].location.height.value, 0,
305+
rtol=0, atol=1e-9)
305306

306307
@pytest.mark.parametrize('table_types', (Table, QTable))
307308
def test_io_time_read_fits_scale(self, table_types):

‎astropy/nddata/tests/test_decorators.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,9 @@ def wrapped_function_6(data, wcs=None, unit=None):
181181
if wrapped_function_6.__doc__ is not None:
182182
assert wrapped_function_6.__doc__.strip() == "An awesome function"
183183

184-
signature = inspect.formatargspec(
185-
*inspect.getfullargspec(wrapped_function_6))
184+
signature = inspect.signature(wrapped_function_6)
186185

187-
assert signature == "(data, wcs=None, unit=None)"
186+
assert str(signature) == "(data, wcs=None, unit=None)"
188187

189188

190189
def test_setup_failures1():

‎astropy/tests/helper.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,31 @@ def __exit__(self, *exc_info):
150150
# py.test reads files with the 'U' flag, which is
151151
# deprecated.
152152
r"'U' mode is deprecated",
153-
# inspect raises this slightly different warning on Python 3.6.
153+
# inspect raises this slightly different warning on Python 3.6-3.7.
154154
# Keeping it since e.g. lxml as of 3.8.0 is still calling getargspec()
155155
r"inspect\.getargspec\(\) is deprecated, use "
156156
r"inspect\.signature\(\) or inspect\.getfullargspec\(\)",
157157
# https://github.com/astropy/astropy/pull/7372
158158
r"Importing from numpy\.testing\.decorators is deprecated, import from numpy\.testing instead\.",
159159
# Deprecation warnings ahead of pytest 4.x
160-
r"MarkInfo objects are deprecated"])}
160+
r"MarkInfo objects are deprecated"]),
161+
(3, 7): set([
162+
# py.test reads files with the 'U' flag, which is
163+
# deprecated.
164+
r"'U' mode is deprecated",
165+
# inspect raises this slightly different warning on Python 3.6-3.7.
166+
# Keeping it since e.g. lxml as of 3.8.0 is still calling getargspec()
167+
r"inspect\.getargspec\(\) is deprecated, use "
168+
r"inspect\.signature\(\) or inspect\.getfullargspec\(\)",
169+
# https://github.com/astropy/astropy/pull/7372
170+
r"Importing from numpy\.testing\.decorators is deprecated, import from numpy\.testing instead\.",
171+
# Deprecation warnings ahead of pytest 4.x
172+
r"MarkInfo objects are deprecated",
173+
# Deprecation warning for collections.abc, fixed in Astropy but still
174+
# used in lxml, and maybe others
175+
r"Using or importing the ABCs from 'collections'",
176+
]),
177+
}
161178

162179

163180
def enable_deprecations_as_exceptions(include_astropy_deprecations=True,

0 commit comments

Comments
 (0)