Skip to content

Commit

Permalink
Merge pull request #6193 from johnhaddon/codeCompletionTweaks
Browse files Browse the repository at this point in the history
PythonCompleter : Don't evaluate properties
  • Loading branch information
johnhaddon authored Jan 13, 2025
2 parents 4abc2fb + 4f8233b commit cb56922
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Improvements
- Viewer :
- The shading mode menu icon now updates to indicate when a non-default shading mode is in use.
- Added the ability to toggle between default shading and the last selected shading mode by <kbd>Ctrl</kbd> + clicking the shading mode menu button.
- PythonEditor : Added workaround for slow code completion caused by poorly performing Python property getters.

Fixes
-----
Expand Down
14 changes: 13 additions & 1 deletion python/GafferUI/CodeWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,19 @@ def __attrAndItemCompletions( self, text ) :
items = []
for n in dir( rootObject ) :
with IECore.IgnoredExceptions( AttributeError ) :
items.append( ( n, getattr( rootObject, n ) ) )
if not isinstance( getattr( type( rootObject ), n, None ), property ) :
# Get the value using `getattr()`, so that
# `__completions()` can distinguish between callable and
# non-callable values.
items.append( ( n, getattr( rootObject, n ) ) )
else :
# Avoid calling the property getter to get the attribute
# value, because one particular Gaffer pipeline has many
# slow-to-get properties. We assume that this is no
# great loss in other pipelines, because it is unlikely that
# a property returns a callable.
items.append( ( n, None ) )

return self.__completions(
items = items,
prefix = prefix, partialName = partial[1:],
Expand Down

0 comments on commit cb56922

Please sign in to comment.