Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward compatible class replaced by a function #280

Closed
gsnider2195 opened this issue Aug 30, 2024 · 1 comment · Fixed by #281
Closed

Backward compatible class replaced by a function #280

gsnider2195 opened this issue Aug 30, 2024 · 1 comment · Fixed by #281

Comments

@gsnider2195
Copy link

The diffsync.DiffSync class was changed to a function

def DiffSync(*args: Any, **kwargs: Any) -> Adapter: # noqa pylint: disable=invalid-name
"""For backwards-compatibility, keep around the old name."""
warnings.warn(
"'diffsync.DiffSync' is deprecated and will be removed with 2.1, use 'diffsync.Adapter' instead.",
DeprecationWarning,
)
return Adapter(*args, **kwargs)

This causes the import of any class using this as a base class to fail:

import diffsync


class TestAdapter(diffsync.DiffSync):
    """A simple DiffSync adapter for testing purposes."""
Traceback (most recent call last):
  File "/home/gary/github/nautobot/nautobot-app-device-onboarding/test_diffsync.py", line 4, in <module>
    class TestAdapter(diffsync.DiffSync):
TypeError: function() argument 'code' must be code, not str
@jmcgill298
Copy link

It seems to me to make sense to do this instead of the func def

class DiffSync(Adapter):

    def __init__(*args, **kwargs):
        warnings.warn(...)
        super.__init__(*args, **kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants