Skip to content

feat(api): add pythonscad implementation - #2

Open
kilo-code-bot[bot] wants to merge 7 commits into
mainfrom
session/agent_ae0e72e7-e312-4395-93c5-635bdc2a250d
Open

feat(api): add pythonscad implementation#2
kilo-code-bot[bot] wants to merge 7 commits into
mainfrom
session/agent_ae0e72e7-e312-4395-93c5-635bdc2a250d

Conversation

@kilo-code-bot

@kilo-code-bot kilo-code-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Add support for the pythonscad API implementation, including its module registration, dependency requirements, and unit tests.

This implementation:

  • Adds PYTHONSCAD = 'ps' to the Implementation enum
  • Registers the backend in APIS_INFO with appropriate capability flags
  • Adds the backend to supported_apis() probing
  • Creates a complete ps.py backend implementation following the sp2.py pattern
  • Adds unit test coverage
  • Updates requirements and setup.py for installation

The backend uses pythonscad's native API with a trimesh/mandril fallback for reliable geometric queries.

Add support for the pythonscad API implementation, including its
module registration, dependency requirements, and unit tests.
Comment thread src/b13d/api/ps.py Outdated
return PsCone(l, r1=rad, r2=rad, sides=sides, direction="Z", api=self)

def cylinder_x(self, l: float, rad: float) -> Shape:
return PsRod(l, rad, None, self.rotZtoX, self)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: self.rotZtoX is undefined — PsShapeAPI does not define this attribute, unlike TMShapeAPI where rotZtoX is a class-level rotation matrix. This will raise AttributeError when cylinder_x is called.

Suggested change
return PsRod(l, rad, None, self.rotZtoX, self)
return PsRod(l, rad, None, None, self)

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/b13d/api/ps.py Outdated
return PsRod(l, rad, None, self.rotZtoX, self)

def cylinder_y(self, l: float, rad: float) -> Shape:
return PsRod(l, rad, None, self.rotZtoY, self)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: self.rotZtoY is undefined — PsShapeAPI does not define this attribute, unlike TMShapeAPI where rotZtoY is a class-level rotation matrix. This will raise AttributeError when cylinder_y is called.

Suggested change
return PsRod(l, rad, None, self.rotZtoY, self)
return PsRod(l, rad, None, None, self)

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/b13d/api/ps.py
if hasattr(shape.solid, 'to_scad'):
scad_content = shape.solid.to_scad()
elif hasattr(shape.solid, '__str__'):
scad_content = str(shape.solid)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: str(shape.solid) will write the literal string "None" to the SCAD file if shape.solid is None, producing invalid output without any error.

Suggested change
scad_content = str(shape.solid)
scad_content = str(shape.solid) if shape.solid is not None else "// Empty solid"

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/b13d/api/ps.py
try:
return self._scad_func_eval(num)
except:
assert f"# WARNING: {num} is not numeric"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: assert f"# WARNING: {num} is not numeric" always passes because a non-empty string is truthy. This silently swallows type errors instead of raising an exception.

Suggested change
assert f"# WARNING: {num} is not numeric"
assert False, f"# WARNING: {num} is not numeric"

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/b13d/api/ps.py Outdated

class PsRod(PShape):
def __init__(
self, l: float, rad: float, sides, rotMat: NDArray, api: PsShapeAPI

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: NDArray is not imported in this file. Even though from __future__ import annotations defers evaluation, NDArray is undefined and will cause NameError in runtime introspection contexts.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Author

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • src/pylele/parts/worm_gear.py
Previous Review Summaries (5 snapshots, latest commit d6e81c5)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit d6e81c5)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • README.md
  • src/b13d/api/core.py
  • src/b13d/api/cq.py

Previous review (commit 95a815d)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
WARNING 1
Issue Details (click to expand)

WARNING

File Line Issue
src/b13d/api/ps.py 681 Duplicate if __name__ == "__main__": block
Files Reviewed (1 file)
  • src/b13d/api/ps.py - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit 8977f20)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
WARNING 1
Issue Details (click to expand)

WARNING

File Line Issue
src/b13d/api/ps.py 681 Duplicate if __name__ == "__main__": block
Files Reviewed (1 file)
  • src/b13d/api/ps.py - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit 49b187e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • src/b13d/api/ps.py

Previous review (commit 2d92842)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 2
WARNING 3
Issue Details (click to expand)

CRITICAL

File Line Issue
src/b13d/api/ps.py 155 self.rotZtoX is undefined — PsShapeAPI does not define this attribute, unlike TMShapeAPI where rotZtoX is a class-level rotation matrix. This will raise AttributeError when cylinder_x is called.
src/b13d/api/ps.py 158 self.rotZtoY is undefined — PsShapeAPI does not define this attribute, unlike TMShapeAPI where rotZtoY is a class-level rotation matrix. This will raise AttributeError when cylinder_y is called.

WARNING

File Line Issue
src/b13d/api/ps.py 313 assert f"# WARNING: {num} is not numeric" always passes because a non-empty string is truthy. This silently swallows type errors instead of raising an exception.
src/b13d/api/ps.py 540 NDArray is not imported in this file. Even though from __future__ import annotations defers evaluation, NDArray is undefined and will cause NameError in runtime introspection contexts.
src/b13d/api/ps.py 108 str(shape.solid) will write the literal string "None" to the SCAD file if shape.solid is None, producing invalid output without any error.
Files Reviewed (5 files)
  • src/b13d/api/ps.py - 5 issues
  • src/b13d/api/core.py - 0 issues
  • setup.py - 0 issues
  • requirements_pythonscad.txt - 0 issues
  • src/b13d/test.py - 0 issues

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash · Input: 52.1K · Output: 5.9K · Cached: 251.4K

kilo-code-bot Bot added 2 commits July 18, 2026 09:13
Replaces the `PsRod` class with `PsCone` in `cylinder_x`, `cylinder_y`, and `cylinder_z` methods to simplify cylinder generation and remove unused rotation logic.
Move PsBall, PsBox, and PsCone classes out of the PShape class scope to the module level.
Comment thread src/b13d/api/ps.py
if __name__ == "__main__":
run_api_test("pythonscad")

if __name__ == "__main__":

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Duplicate if __name__ == "__main__": block

The refactoring that moved nested classes to top-level accidentally duplicated the __main__ block at lines 678 and 681. Python only executes the first one, making lines 681-682 dead code.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant