Conversation
| self.shape_converter.applyTransformOnGroup(transform, group) | ||
|
|
||
| def xlink_href_target(self, node, group=None): | ||
| def xlink_href_target(self, node: NodeTracker, group: Optional[Any] = None) -> Any: |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the explicit–implicit return mixing, add an explicit return None at the end of the xlink_href_target function. This does not change functionality, as the function would implicitly return None anyway if no return statements are hit, but improves code clarity.
Edit only the function xlink_href_target in src/svglib/svglib.py, adding return None before the function ends (after line 834 <end of function>). No external imports or definitions are needed.
| @@ -831,6 +831,7 @@ | ||
| # The missing definition should appear later in the file | ||
| self.waiting_use_nodes[fragment].append((node, group)) | ||
| return DELAYED | ||
| return None | ||
|
|
||
| def renderTitle_(self, node: NodeTracker) -> None: | ||
| # Main SVG title attr. could be used in the PDF document info field. |
| def renderUse( | ||
| self, | ||
| node: NodeTracker, | ||
| group: Optional[Any] = None, | ||
| clipping: Optional[Any] = None, | ||
| ) -> Any: |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, add an explicit return None statement at the end of the renderUse method in src/svglib/svglib.py. This ensures that, if none of the previous if/elif/else branches are taken, the function's return value is explicitly specified. This change keeps the function's behaviour the same as before, but makes the intent clearer for maintainers. The only change required is to add the explicit return at the end of the method.
| @@ -956,8 +956,8 @@ | ||
| self.renderNode(list(node.iter_children())[-1], parent=group) | ||
| self.apply_node_attr_to_group(node, group) | ||
| return group | ||
| return None | ||
|
|
||
|
|
||
| class SvgShapeConverter: | ||
| """An abstract SVG shape converter. | ||
|
|
| """Converter from SVG shapes to RLG (ReportLab Graphics) shapes.""" | ||
|
|
||
| def convertShape(self, name, node, clipping=None): | ||
| def convertShape(self, name: str, node: Any, clipping: Optional[Any] = None) -> Any: |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, explicitly return None instead of using a bare return statement where no value is intended. In this code, update the line return (line 997) to return None. This minor edit improves code readability and consistency, making it clear what value is returned in all branches. No other changes, imports, or definitions are required.
| @@ -994,7 +994,7 @@ | ||
| method_name = f"convert{name.capitalize()}" | ||
| shape = getattr(self, method_name)(node) | ||
| if not shape: | ||
| return | ||
| return None | ||
| if name not in ("path", "polyline", "text"): | ||
| # Only apply style where the convert method did not apply it. | ||
| self.applyStyleOnShape(shape, node) |
…with implicit (fall through) returns Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…with implicit (fall through) returns Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| # The missing definition should appear later in the file | ||
| self.waiting_use_nodes[fragment].append((node, group)) | ||
| return DELAYED | ||
| return None |
Check warning
Code scanning / CodeQL
Unreachable code Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
The fix is straightforward: remove the unreachable return None statement on line 834 within the xlink_href_target method in src/svglib/svglib.py. This code is never executed given the preceding unconditional return DELAYED. No functional change will be introduced by this deletion, and code clarity will be improved. Only one line (834) in the file is to be removed; no imports, methods, or additional definitions are needed.
| @@ -831,7 +831,6 @@ | ||
| # The missing definition should appear later in the file | ||
| self.waiting_use_nodes[fragment].append((node, group)) | ||
| return DELAYED | ||
| return None | ||
|
|
||
| def renderTitle_(self, node: NodeTracker) -> None: | ||
| # Main SVG title attr. could be used in the PDF document info field. |
…with implicit (fall through) returns Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
for more information, see https://pre-commit.ci
| self.renderNode(list(node.iter_children())[-1], parent=group) | ||
| self.apply_node_attr_to_group(node, group) | ||
| return group | ||
| return None |
Check warning
Code scanning / CodeQL
Unreachable code Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix this issue, we should delete the unreachable return None statement on line 959 of src/svglib/svglib.py. This statement appears directly after another return and cannot ever be executed. Removing it will clarify the code and avoid confusion. No other code changes, imports, or definitions are necessary, as the removal has no impact on existing functionality. The edit should only remove the single unreachable line, keeping all other content intact.
| @@ -956,9 +956,9 @@ | ||
| self.renderNode(list(node.iter_children())[-1], parent=group) | ||
| self.apply_node_attr_to_group(node, group) | ||
| return group | ||
| return None | ||
|
|
||
|
|
||
|
|
||
| class SvgShapeConverter: | ||
| """An abstract SVG shape converter. | ||
|
|
Add static type checking.