-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
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.
Due to GitHub API limits, only the first 60 comments can be shown.
module_name = folder_name + "." + filename | ||
module_name = f"{folder_name}.{filename}" | ||
|
||
nodes.extend( | ||
obj | ||
for name, obj in inspect.getmembers( | ||
importlib.import_module(module_name) | ||
) | ||
if inspect.isclass(obj) | ||
and filename in str(obj) | ||
and len(inspect.getmembers(obj)) > 0 | ||
and obj.__identifier__ != '__None' | ||
) | ||
|
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.
Function get_nodes_from_folder
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace a for append loop with list extend (
for-append-to-extend
) - Merge nested if conditions (
merge-nested-ifs
)
|
||
try: | ||
from Qt import QtWidgets, QtGui, QtCore, QtCompat, QtOpenGL | ||
except ImportError as ie: | ||
from .vendor.Qt import __version__ as qtpy_ver | ||
from .vendor.Qt import QtWidgets, QtGui, QtCore, QtCompat ,QtOpenGL | ||
print('NodeGraphQt: Can\'t import "Qt.py" module falling back on ' | ||
'"NodeGraphQt.vendor.Qt ({})"'.format(qtpy_ver)) | ||
print( | ||
f"""NodeGraphQt: Can't import "Qt.py" module falling back on "NodeGraphQt.vendor.Qt ({qtpy_ver})\"""" | ||
) | ||
|
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.
Lines 81-82
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
self.setText('renamed "{}" to "{}"'.format(node.name(), value)) | ||
self.setText(f'renamed "{node.name()}" to "{value}"') | ||
else: | ||
self.setText('property "{}:{}"'.format(node.name(), name)) | ||
self.setText(f'property "{node.name()}:{name}"') |
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.
Function PropertyChangedCmd.__init__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
if hasattr(view, 'widgets') and name in view.widgets.keys(): | ||
# check if previous value is identical to current value, | ||
# prevent signals from causing a infinite loop. | ||
if view.widgets[name].value != value: | ||
view.widgets[name].value = value | ||
if ( | ||
hasattr(view, 'widgets') | ||
and name in view.widgets.keys() | ||
and view.widgets[name].value != value | ||
): | ||
view.widgets[name].value = value |
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.
Function PropertyChangedCmd.set_node_prop
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
This removes the following comments ( why? ):
# prevent signals from causing a infinite loop.
# check if previous value is identical to current value,
print('can\'t find node type {}'.format(node_type)) | ||
print(f"can't find node type {node_type}") |
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.
Function NodeFactory.create_node_instance
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
serial_str = json.dumps(serial_data) | ||
if serial_str: | ||
if serial_str := json.dumps(serial_data): |
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.
Function NodeGraph.copy_nodes
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
text = '{} ({}) nodes'.format(text, len(nodes)) | ||
text = f'{text} ({len(nodes)}) nodes' |
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.
Function NodeGraph.disable_nodes
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
return '<{}("{}") object at {}>'.format( | ||
self.__class__.__name__, self.name(), hex(id(self))) | ||
return f'<{self.__class__.__name__}("{self.name()}") object at {hex(id(self))}>' |
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.
Function NodeGraphMenu.__repr__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
menu = self.qmenu.get_menu(name) | ||
if menu: | ||
if menu := self.qmenu.get_menu(name): |
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.
Function NodeGraphMenu.get_menu
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
if not action.menu(): | ||
if not action.isSeparator(): | ||
actions.append(action) | ||
else: | ||
if action.menu(): | ||
actions += get_actions(action.menu()) | ||
elif not action.isSeparator(): | ||
actions.append(action) |
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.
Function NodeGraphMenu.all_commands.get_actions
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
return '<{}("{}") object at {}>'.format( | ||
self.__class__.__name__, self.name(), hex(id(self))) | ||
return f'<{self.__class__.__name__}("{self.name()}") object at {hex(id(self))}>' |
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.
Function NodeGraphCommand.__repr__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
return '<{}(\'{}\') object at {}>'.format( | ||
self.__class__.__name__, self.name, hex(id(self))) | ||
return f"<{self.__class__.__name__}('{self.name}') object at {hex(id(self))}>" |
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.
Function PortModel.__repr__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
return '<{}(\'{}\') object at {}>'.format( | ||
self.__class__.__name__, self.name, self.id) | ||
return f"<{self.__class__.__name__}('{self.name}') object at {self.id}>" |
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.
Function NodeModel.__repr__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
raise NodePropertyError( | ||
'"{}" reserved for default property.'.format(name)) | ||
raise NodePropertyError(f'"{name}" reserved for default property.') | ||
if name in self._custom_prop.keys(): | ||
raise NodePropertyError( | ||
'"{}" property already exists.'.format(name)) | ||
raise NodePropertyError(f'"{name}" property already exists.') |
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.
Function NodeModel.add_property
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
attrs = self._TEMP_property_attrs.get(name) | ||
if attrs: | ||
if attrs := self._TEMP_property_attrs.get(name): |
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.
Function NodeModel.get_tab_name
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
return '<{}("{}") object at {}>'.format( | ||
port, self.name(), hex(id(self))) | ||
return f'<{port}("{self.name()}") object at {hex(id(self))}>' |
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.
Function Port.__repr__
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
undo_stack.beginMacro('{} port {}'.format(label, self.name())) | ||
undo_stack.beginMacro(f'{label} port {self.name()}') |
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.
Function Port.set_visible
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
raise PortError( | ||
'Can\'t connect port because "{}" is locked.'.format(name)) | ||
raise PortError(f"""Can't connect port because "{name}" is locked.""") |
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.
Function Port.connect_to
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
) - Merge nested if conditions (
merge-nested-ifs
)
raise PortError( | ||
'Can\'t disconnect port because "{}" is locked.'.format(name)) | ||
raise PortError(f"""Can't disconnect port because "{name}" is locked.""") |
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.
Function Port.disconnect_from
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
file_path = viewer.load_dialog(current) | ||
if file_path: | ||
if file_path := viewer.load_dialog(current): |
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.
Function _open_session
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
file_path = viewer.load_dialog(current) | ||
if file_path: | ||
if file_path := viewer.load_dialog(current): |
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.
Function _import_session
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
current = graph.current_session() | ||
if current: | ||
if current := graph.current_session(): |
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.
Function _save_session
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
file_path = viewer.save_dialog(current) | ||
if file_path: | ||
if file_path := viewer.save_dialog(current): |
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.
Function _save_session_as
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
nodes = graph.selected_nodes() | ||
if nodes: | ||
if nodes := graph.selected_nodes(): |
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.
Function _jump_in
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
node = graph.get_node_space() | ||
if node: | ||
if node := graph.get_node_space(): |
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.
Function _jump_out
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
props.update(self._properties) | ||
props |= self._properties |
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.
Function AbstractNodeItem.properties
refactored with the following changes:
- Merge dictionary updates via the union operator. (
dict-assign-update-to-union
)
viewer = self.viewer() | ||
if viewer: | ||
if viewer := self.viewer(): |
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.
Function BackdropNodeItem.mouseDoubleClickEvent
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
sel_color = [x for x in NODE_SEL_COLOR] | ||
sel_color = list(NODE_SEL_COLOR) |
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.
Function BackdropNodeItem.paint
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
if item == self or item == self._sizer: | ||
if item in [self, self._sizer]: |
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.
Function BackdropNodeItem.get_nodes
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
nodes = nodes or self.get_nodes(True) | ||
if nodes: | ||
if nodes := nodes or self.get_nodes(True): |
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.
Function BackdropNodeItem.auto_resize
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.15%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!