question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove runtime dependency on pytest

See original GitHub issue

The import here

https://github.com/astropy/astropy/blob/81804cf0d30c37c117081b4826d938ba84bfdada/astropy/io/misc/asdf/tags/coordinates/skycoord.py#L9

Gives a runtime dependency of astropy’s asdf extension on pytest, which is not desired.

To reproduce, and a traceback:

In [1]: import asdf

In [2]: from astropy.coordinates import SkyCoord

In [3]: coord = SkyCoord(ra=15, dec=12, unit='deg')

In [4]: tree = {'coord': coord}

In [5]: af = asdf.AsdfFile(tree=tree)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-97f03a40ab48> in <module>
----> 1 af = asdf.AsdfFile(tree=tree)

~/miniconda3/envs/test/lib/python3.7/site-packages/asdf/asdf.py in __init__(self, tree, uri, extensions, version, ignore_version_mismatch, ignore_unrecognized_tag, ignore_implicit_conversion, copy_arrays, lazy_load, custom_schema, _readonly)
    120         self._extension_metadata = {}
    121 
--> 122         self._process_extensions(extensions)
    123         self._ignore_version_mismatch = ignore_version_mismatch
    124         self._ignore_unrecognized_tag = ignore_unrecognized_tag

~/miniconda3/envs/test/lib/python3.7/site-packages/asdf/asdf.py in _process_extensions(self, extensions)
    204     def _process_extensions(self, extensions):
    205         if extensions is None or extensions == []:
--> 206             self._extensions = default_extensions.extension_list
    207             self._extension_metadata = default_extensions.package_metadata
    208             return

~/miniconda3/envs/test/lib/python3.7/site-packages/asdf/extension.py in extension_list(self)
    231     def extension_list(self):
    232         if self._extension_list is None:
--> 233             self._extension_list = AsdfExtensionList(self.extensions)
    234 
    235         return self._extension_list

~/miniconda3/envs/test/lib/python3.7/site-packages/asdf/extension.py in extensions(self)
    224                 self._extensions.append(BuiltinExtension())
    225 
--> 226             self._load_installed_extensions()
    227 
    228         return self._extensions

~/miniconda3/envs/test/lib/python3.7/site-packages/asdf/extension.py in _load_installed_extensions(self, group)
    195             with warnings.catch_warnings(record=True) as w:
    196                 warnings.simplefilter('always', category=AsdfDeprecationWarning)
--> 197                 ext = entry_point.load()
    198             if not issubclass(ext, AsdfExtension):
    199                 warnings.warn("Found entry point {}, from {} but it is not a "

~/miniconda3/envs/test/lib/python3.7/site-packages/pkg_resources/__init__.py in load(self, require, *args, **kwargs)
   2432         if require:
   2433             self.require(*args, **kwargs)
-> 2434         return self.resolve()
   2435 
   2436     def resolve(self):

~/miniconda3/envs/test/lib/python3.7/site-packages/pkg_resources/__init__.py in resolve(self)
   2438         Resolve the entry point from its module and attrs.
   2439         """
-> 2440         module = __import__(self.module_name, fromlist=['__name__'], level=0)
   2441         try:
   2442             return functools.reduce(getattr, self.attrs, module)

~/miniconda3/envs/test/lib/python3.7/site-packages/astropy/io/misc/asdf/extension.py in <module>
     15 from .tags.coordinates.frames import *
     16 from .tags.coordinates.earthlocation import *
---> 17 from .tags.coordinates.skycoord import *
     18 from .tags.coordinates.representation import *
     19 from .tags.fits.fits import *

~/miniconda3/envs/test/lib/python3.7/site-packages/astropy/io/misc/asdf/tags/coordinates/skycoord.py in <module>
      7 
      8 from astropy.coordinates import SkyCoord
----> 9 from astropy.table.tests.test_operations import skycoord_equal
     10 
     11 from ...types import AstropyType

~/miniconda3/envs/test/lib/python3.7/site-packages/astropy/table/tests/test_operations.py in <module>
      4 from collections import OrderedDict
      5 
----> 6 import pytest
      7 import numpy as np
      8 

ModuleNotFoundError: No module named 'pytest'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
astrojuanlucommented, Aug 7, 2019

oh, wow, that should never be imported from there…

Speaking of which, I learned about the existence of this package recently, just FYI https://pypi.org/project/import-linter/

1reaction
dhomeiercommented, Aug 7, 2019
$ grep -r "allclose_jd = " astropy
astropy/io/misc/asdf/tags/time/timedelta.py:allclose_jd = functools.partial(np.allclose, rtol=2. ** -52, atol=0)

I don’t find this in the version on master. Declaring them locally would of course at least allow you to get rid of the import.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing runtime dependency on Python - ROS Answers
Is it possible to remove runtime dependency of ROS on Python. Catkin, the build system, may need python for code generation from messages; ......
Read more >
pytest-dependency Documentation - Read the Docs
The pytest-dependency module defines a marker that can be applied to tests. The marker accepts an argument that.
Read more >
Deprecations and Removals — pytest documentation
Deprecations and Removals¶. This page lists all pytest features that are currently deprecated or have been removed in past major releases.
Read more >
How do I disable a test using pytest? - Stack Overflow
The first example always skips the test, the second example allows you to conditionally skip tests (great when tests depend on the platform, ......
Read more >
How to Uninstall Python Packages - ActiveState
Open a command or terminal window (depending on the operating system); cd into the project directory; pip uninstall <packagename>. To use pipenv ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found