CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Inherited classes not initialized properly in Python3 when constructor uses super() #921

Closed ygorelik closed 5 years ago

ygorelik commented 5 years ago

Current Behavior

Inherited classes are not initialized properly in Python3 when constructor uses super().

Example from errors.py:

class YServiceError(YError):
    '''
    Exception for Service Side Validation
    '''
    def __init__(self, error_code=None, error_msg=None):
        super(YServiceError, self).__init__(
            error_code=error_code, error_msg=error_msg)

This code works fine in Python2, but python3 requires different syntax:

class YServiceError(YError):
    '''
    Exception for Service Side Validation
    '''
    def __init__(self, error_code=None, error_msg=None):
        super().__init__(
            error_code=error_code, error_msg=error_msg)

System Information

YDK-0.5.5 and YDK-0.8.3

dasomeom commented 5 years ago

This was also noted in Python 3.7.3 virtual environment on Mac platform. The error log:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1758, in <module>
    main()
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1752, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1147, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/deom/gnmi-client/run.py", line 6, in <module>
    cli.main()
  File "/Users/deom/gnmi-client/gnmi_client/cli.py", line 15, in main
    return client.main()
  File "/Users/deom/gnmi-client/gnmi_client/gnmi_client.py", line 386, in main
    self.connect_to_device()
  File "/Users/deom/gnmi-client/gnmi_client/logger.py", line 24, in wrapper
    return_val = func(*args, **kwargs)
  File "/Users/deom/gnmi-client/gnmi_client/gnmi_client.py", line 319, in connect_to_device
    self.provider = gNMISession(repo, "domingo", 57400, "admin", "admin")
  File "/Users/deom/v3/lib/python3.7/site-packages/ydk/gnmi/path/gnmi_session.py", line 39, in __init__
    server_certificate, private_key)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. ydk_gnmi_.path.gNMISession(repo: ydk::path::Repository, address: str, port: int, username: str, password: str, server_certificate: str='', private_key: str='')

Invoked with: <ydk_.path.Repository object at 0x106863960>, 'domingo', 57400, 'admin', 'admin', '', ''