villebro commented on PR #32857:
URL: https://github.com/apache/superset/pull/32857#issuecomment-2761712139
> Oh interesting. Wondering if it would make sense to refactor this logic
and be based on a class attribute instead of the same override in many derived
classes. Maybe something like:
>
> ```python
> class BaseEngine:
> ALLOW_DUPLICATE_ALIAS = True
> {...}
> @classmethod. # <<< switching to a classmethod
> def _mutate_label(cls, label: str) -> str:
> if cls.ALLOW_DUPLICATE_ALIAS:
> return label
> else:
> return f"{label}_{md5_sha_from_str(label)[:6]}"
> ```
>
> Then in all the derived class that have that method you'd need to set
`ALLOW_DUPLICATE_ALIAS = False`
@mistercrunch looking at what types of label mutations we have in place,
they're pretty varied: some suffix a partial MD5, some lowercase everything,
some replace periods with underscores, some ensure the first character isn't a
number etc. So a one size fits all solution likely won't work well. But I agree
that this is probably ripe for refactoring, as it's pretty unintuitive to
expect specs to implement a private method for something like this.. 😬
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]