Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions astropy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,17 @@ def online_help(query):
webbrowser.open(url)


__dir__ = ['__version__', '__githash__', '__minimum_numpy_version__',
'__bibtex__', 'test', 'log', 'find_api_page', 'online_help',
'online_docs_root', 'conf']
__dir_inc__ = ['__version__', '__githash__', '__minimum_numpy_version__',
'__bibtex__', 'test', 'log', 'find_api_page', 'online_help',
'online_docs_root', 'conf']


from types import ModuleType as __module_type__
# Clean up top-level namespace--delete everything that isn't in __dir__
# Clean up top-level namespace--delete everything that isn't in __dir_inc__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must admit I find this auto-cleanup bad form, but that's somewhat out of scope of this PR!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a cleanup, I had to change the use of __dir__ to list the attributes that shall not be deleted because setting a list to __dir__ no more works.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saimn - I meant that I found the whole stanza rather bad form, not your change to it! It just seems that by being a bit more careful in the code itself, one can avoid introducing these unwanted things in the namespace (or delete them after their use). Anyway, as said, definitely out of scope here!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhvk - Ah ok! I agree with you, we could find a simpler way to keep the namespace clean.

# or is a magic attribute, and that isn't a submodule of this package
for varname in dir():
if not ((varname.startswith('__') and varname.endswith('__')) or
varname in __dir__ or
varname in __dir_inc__ or
(varname[0] != '_' and
isinstance(locals()[varname], __module_type__) and
locals()[varname].__name__.startswith(__name__ + '.'))):
Expand Down
6 changes: 3 additions & 3 deletions astropy/io/ascii/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""


import collections
import collections.abc

@bsipocz bsipocz Jul 11, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't have this for the 2.0.x backport. I'll remove this change from the backport, but anyway, expect that it won't cause any roubles given the last commit of the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the warning is filtered for lxml, so should be fine.

import itertools
import operator

Expand Down Expand Up @@ -95,10 +95,10 @@ def sortmore(*args, **kw):
if globalkey is None:
globalkey = lambda *x: 0

if not isinstance(globalkey, collections.Callable):
if not isinstance(globalkey, collections.abc.Callable):
raise ValueError('globalkey needs to be callable')

if isinstance(key, collections.Callable):
if isinstance(key, collections.abc.Callable):
k = lambda x: (globalkey(*x), key(x[0]))
elif isinstance(key, tuple):
key = (k if k else lambda x: 0 for k in key)
Expand Down
3 changes: 2 additions & 1 deletion astropy/io/fits/tests/test_fitstime.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def test_io_time_read_fits_location(self, table_types):
assert isinstance(tm['datetime'], Time)
assert tm['datetime'].location.lon.value == 0
assert tm['datetime'].location.lat.value == 0
assert tm['datetime'].location.height.value == 0
assert np.isclose(tm['datetime'].location.height.value, 0,
rtol=0, atol=1e-9)

@pytest.mark.parametrize('table_types', (Table, QTable))
def test_io_time_read_fits_scale(self, table_types):
Expand Down
5 changes: 2 additions & 3 deletions astropy/nddata/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@ def wrapped_function_6(data, wcs=None, unit=None):
if wrapped_function_6.__doc__ is not None:
assert wrapped_function_6.__doc__.strip() == "An awesome function"

signature = inspect.formatargspec(
*inspect.getfullargspec(wrapped_function_6))
signature = inspect.signature(wrapped_function_6)

assert signature == "(data, wcs=None, unit=None)"
assert str(signature) == "(data, wcs=None, unit=None)"


def test_setup_failures1():
Expand Down
19 changes: 18 additions & 1 deletion astropy/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,24 @@ def __exit__(self, *exc_info):
# https://github.com/astropy/astropy/pull/7372
r"Importing from numpy\.testing\.decorators is deprecated, import from numpy\.testing instead\.",
# Deprecation warnings ahead of pytest 4.x
r"MarkInfo objects are deprecated"])}
r"MarkInfo objects are deprecated"]),
(3, 7): set([
# py.test reads files with the 'U' flag, which is
# deprecated.
r"'U' mode is deprecated",
# inspect raises this slightly different warning on Python 3.6.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Python 3.6 and 3.7?

# Keeping it since e.g. lxml as of 3.8.0 is still calling getargspec()
r"inspect\.getargspec\(\) is deprecated, use "
r"inspect\.signature\(\) or inspect\.getfullargspec\(\)",
# https://github.com/astropy/astropy/pull/7372
r"Importing from numpy\.testing\.decorators is deprecated, import from numpy\.testing instead\.",
# Deprecation warnings ahead of pytest 4.x
r"MarkInfo objects are deprecated",
# Deprecation warning for collections.abc, fixed in Astropy but still
# used in lxml, and maybe others
r"Using or importing the ABCs from 'collections'",
]),
}


def enable_deprecations_as_exceptions(include_astropy_deprecations=True,
Expand Down