replace controlTypes.STATE_* with controlTypes.State.*#12712
Conversation
Searched using the regex [^\.]\bSTATE_, which finds STATE_ instances where * it is not of the form <Foo>.STATE_ (as oleacc.STATE_* exists) * STATE_ is the prefix of the symbol (as IA2_STATE_* exists) Replaced the remaining instances manually where required. Fixes unit tests to cover new usages and legacy usages.
See test results for failed build of commit 213fb3dfb0 |
feerrenrut
left a comment
There was a problem hiding this comment.
Overall looks good.
I've been thinking "how do we prevent new code from using the old STATE_* constants?" Perhaps we could extend the lint check (which already creates a diff), then regex on that diff looking for STATE_* constants.
How would we determine Once this is merged in, we could replace the mapping def __getattr__(name: str) -> Any:
if name.startswith("STATE_"):
log.error("Deprecated constant used")
return getattr(State, name.split("_", 1)[-1]) |
See test results for failed build of commit 5408e6d2b8 |
Cannot we just search for every
Less noisy for core but horribly annoying for add-ons making Alphas pretty unusable - imagine getting error sound every once in a while just because many add-ons are not going to use new enum's before 2022.1. |
Not noisy at all if we lower the error level a bit. |
That is an option but this means that usage of the oldd constants would be harder to check for new PR's. Essentially looking for them in the diff seems to be a better option than inspecting the log as the latter solution cannot be automated. |
There could be false positives here, eg "
Or if we only perform an error beep on the first runtime usage of a particular constant or group of constants. |
By running a regex against the PR diff (Only lines changed, the same as the linter does).
|
|
@feerrenrut - this will require a force merge as the lint check will not pass |
I think we can do both, and something like marking it with a comment Would adding the warnings/errors be a good idea too? I think it would be better to move to the PEP standard, and update |
Related to #12649, #12712, #12836 Summary of the issue: The mentioned prs performed a large refactor with constant changes Description of user facing changes None known Description of development approach Add the mentioned PRs to .git-blame-ignore-revs to ensure a properly configured git blame will ignore these changes, revealing the history of the underlying code.
Link to issue number:
Part of #12549
Summary of the issue:
controlTypes.STATE_*are deprecated, to be replaced bycontrolTypes.State.*Description of how this pull request fixes the issue:
controlTypes.STATE_withcontrolTypes.State.across .py files[^\.]\bSTATE_, which finds STATE_ instanceswhere:
<Foo>.STATE_(as oleacc.STATE_* exists)Testing strategy:
Manual testing
Existing unit tests exist for controlTypes.
New unit tests are written to ensure displayString and negativeDisplayString works
Existing system tests will work as a basic smoke test for this core feature
Known issues with pull request:
The lint check is likely to fail
Change log entries:
None needed
Code Review Checklist: