fix: rename shadowed 'format' builtin in _render_graphviz#759
Conversation
In burr/core/graph.py, the function _render_graphviz() used 'format' as a local variable name, which shadows Python's built-in format() function. Renamed it to 'fmt' to avoid the shadowing while preserving all existing behavior. The variable is used only within the function scope and the rename is consistent and self-documenting.
There was a problem hiding this comment.
Pull request overview
This PR removes a local variable name that shadows Python’s built-in format() inside burr/core/graph.py:_render_graphviz(), reducing linter warnings and improving readability without changing behavior.
Changes:
- Renames the local variable
formattofmtwithin_render_graphviz(). - Updates all uses of the renamed variable while preserving the
format=keyword argument in Graphviz calls.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Friendly ping for review 🙏 This is a small, focused fix. CI is passing. Thank you! |
|
Hi! 👋 This PR has passed all CI checks and looks ready for review. Could a maintainer please take a look when they have a chance? Thank you! |
skrawcz
left a comment
There was a problem hiding this comment.
LGTM — clean rename of a shadowed builtin. Variable format → fmt in _render_graphviz(), no behavioral change. All graph tests pass.
|
The pre-commit - pathlib.Path(f"{path_without_suffix}.{fmt}").write_bytes(
- graphviz_obj.pipe(format=fmt)
- )
+ pathlib.Path(f"{path_without_suffix}.{fmt}").write_bytes(graphviz_obj.pipe(format=fmt))Or just run |
Problem
In
burr/core/graph.py, the function_render_graphviz()usesformatas a local variable name (lines 98, 100). This shadows Python's built-informat()function, which can lead to confusion and potential bugs if the builtin is needed within the function's scope. Many linters (flake8 A001/A002, pylint W0622) flag this as a code smell.Fix
Renamed the local variable from
formattofmtacross all 5 occurrences within the function:The keyword argument
format=in calls tographviz_obj.render()andgraphviz_obj.pipe()is preserved as-is — only the local variable assignment and its usages are renamed. All behavior remains identical.