-
-
Notifications
You must be signed in to change notification settings - Fork 406
Fix ColorSplasher UnboundLocalError and code cleanup #2938
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
Conversation
Co-authored-by: jmcouffin <7872003+jmcouffin@users.noreply.github.com>
|
@jmcouffin tested, works. Remarks:
|
|
@copilot
|
Co-authored-by: jmcouffin <7872003+jmcouffin@users.noreply.github.com>
|
@copilot review if the spacing is actually used |
Reviewed:
The linter warning refers to the initial assignment ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical UnboundLocalError bug in ColorSplasher where the version variable was referenced before assignment, and includes code cleanup to remove unused variables and trailing whitespace.
Key changes:
- Fixed
versionvariable initialization in bothApplyColors.ExecuteandCreateFilters.Executemethods - Removed genuinely unused variables (
new_uiapp, initialspacingvalue, and exception objecte) - Cleaned up trailing whitespace throughout the file
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25334+1705-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25336+1232-wip |
Fix ColorSplasher UnboundLocalError and code cleanup
Description
ColorSplasher fails with
UnboundLocalError: Local variable 'version' referenced before assignmentwhen applying colors.The
versionvariable is used to check Revit 2019+ background pattern support but was:ApplyColors.Execute: Only defined inside a rooms/spaces/areas conditional block, then referenced unconditionallyCreateFilters.Execute: Never defined at allFix: Move
version = int(HOST_APP.version)to execute unconditionally before use in both methods.Additional cleanup:
new_uiappein exception handlerNote: The
spacingvariable initial assignment triggers a linter warning but is intentionally kept as a safety default. The variable is used later in the code after being updated inside a loop.Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Related Issues
If applicable, link the issues resolved by this pull request:
Additional Notes
Introduced in #2932. Fix affects
ApplyColors.ExecuteandCreateFilters.ExecuteinColorSplasher.pushbutton/script.py.Thank you for contributing to pyRevit! 🎉
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.