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

DelayedBase.__repr__ does not use repr? #104

Open
albertz opened this issue Sep 13, 2022 · 2 comments
Open

DelayedBase.__repr__ does not use repr? #104

albertz opened this issue Sep 13, 2022 · 2 comments

Comments

@albertz
Copy link
Member

albertz commented Sep 13, 2022

return str(self.get())

class DelayedBase:
    ...

    def __repr__(self):
        return str(self.get())

    def __str__(self):
        return str(self.get())

Why is there str(...) for the __repr__? Isn't this inconsistent? Shouldn't it be repr?

@critias
Copy link
Contributor

critias commented Sep 14, 2022

I agree, it looks like a copy&paste bug. Fixing it could cause to break some recipes 🤔 but I guess it should be done anyway.

@michelwi
Copy link
Contributor

I think if we decided to break stuff, then we should put an effort to make the behavior of DelayedBase and other DelayedOps consistent to those of Path

def __repr__(self):
if gs.LEGACY_PATH_CONVERSION:
return repr(str(self))
else:
return '<Path %s>' % self.get_path()

and Variable
def __repr__(self):
if gs.LEGACY_VARIABLE_CONVERSION:
return repr(self.get())
else:
value = ''
if self.is_set():
value = ' %s' % self.get()
return "<Variable %s%s>" % (self.rel_path(), value)

i.e. the __str__ function serializes the object to its usable form, but may only be used by a worker. the __repr__ may also be used in the manager for logging or displaying on the gui, but should be unusable "by accident" to prevent hash-bugs.

Also we should be more rigorous in applying the check_is_worker function.

Fixing it could cause to break some recipes

It will definitively break things in i6_core, but a am willing to spend time to fix this. It has cost us a lot of time tracing down dubious bugs in the past.

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

No branches or pull requests

3 participants