Juniper/jsnapy

Bad import - icdiff.get_options

ggaddy opened this issue · 3 comments

Description of Issue/Question

The code for icdiff doesnt seem to have this function anymore get_options

from icdiff import diff, codec_print, get_options, ConsoleDiff

  File "/opt/prelude/modules/jsnapy.py", line 4, in <module>
    from jnpr.jsnapy import SnapAdmin  # pylint: disable=import-error
  File "/usr/local/lib/python3.8/site-packages/jnpr/jsnapy/__init__.py", line 83, in <module>
    from jnpr.jsnapy.jsnapy import SnapAdmin
  File "/usr/local/lib/python3.8/site-packages/jnpr/jsnapy/jsnapy.py", line 22, in <module>
    from jnpr.jsnapy.check import Comparator
  File "/usr/local/lib/python3.8/site-packages/jnpr/jsnapy/check.py", line 19, in <module>
    from icdiff import diff, codec_print, get_options, ConsoleDiff
ImportError: cannot import name 'get_options' from 'icdiff' (/usr/local/lib/python3.8/site-packages/icdiff.py)

I can reproduce by just attempting to import the icdiff functions

[root@ef67e431-test prelude]# python
Python 3.8.6 (default, Jan 22 2021, 11:41:28)
>>> from icdiff import diff, codec_print, get_options, ConsoleDiff
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'get_options' from 'icdiff' (/usr/local/lib/python3.8/site-packages/icdiff.py) <---

Setup

Steps to Reproduce Issue

Just try the code from check.py L19

[root@ef67e431-test prelude]# python
Python 3.8.6 (default, Jan 22 2021, 11:41:28)
>>> from icdiff import diff, codec_print, get_options, ConsoleDiff
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'get_options' from 'icdiff' (/usr/local/lib/python3.8/site-packages/icdiff.py)

Versions Report

[root@ef67e431-test jsnapy]# python --version
Python 3.8.6

[root@ef67e431-test jsnapy]# python -m pip list | grep -i jsnapy
jsnapy                1.3.6

[root@ef67e431-test jsnapy]# python -m pip list | grep -i icdiff
icdiff                2.0.3

I just ran into this, it seems this changed in icdiff
https://pypi.org/project/icdiff/2.0.4/#history

Collecting icdiff==1.9.1
  Downloading icdiff-1.9.1.tar.gz (9.1 kB)
Building wheels for collected packages: icdiff
  Building wheel for icdiff (setup.py) ... done
  Created wheel for icdiff: filename=icdiff-1.9.1-py3-none-any.whl size=9823 sha256=ceee8a2269c589ecffa1489105a5657ca6d77b9f93f7fbfa88d6d6bf03a23070
  Stored in directory: /home/juniper/.cache/pip/wheels/e0/06/98/1f6fffca9c636b12c06357553640bdbf4271aefe16e0204abe
Successfully built icdiff
Installing collected packages: icdiff
  Attempting uninstall: icdiff
    Found existing installation: icdiff 2.0.4
    Uninstalling icdiff-2.0.4:
      Successfully uninstalled icdiff-2.0.4
Successfully installed icdiff-1.9.1  
(infra) me@me:~/$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from icdiff import diff, codec_print, get_options, ConsoleDiff
>>>

me-mbp:~/tmp > diff icdiff-1.9.1/icdiff.py icdiff-2.0.4/icdiff.py | grep def

< def get_options():
> def create_option_parser():

Fix is merged as part of pull request - #396