Skip to content

Conversation

greyltc
Copy link
Contributor

@greyltc greyltc commented Oct 7, 2025

No description provided.

Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 68.38235% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.28%. Comparing base (18b15d6) to head (c9c3f67).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
cadquery/occ_impl/exporters/assembly.py 57.14% 6 Missing and 6 partials ⚠️
cadquery/occ_impl/shapes.py 66.66% 6 Missing and 5 partials ⚠️
cadquery/occ_impl/importers/__init__.py 46.66% 4 Missing and 4 partials ⚠️
cadquery/occ_impl/importers/assembly.py 60.00% 3 Missing and 3 partials ⚠️
cadquery/assembly.py 71.42% 2 Missing and 2 partials ⚠️
cadquery/occ_impl/exporters/vtk.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1909      +/-   ##
==========================================
- Coverage   95.74%   95.28%   -0.47%     
==========================================
  Files          29       29              
  Lines        7827     7911      +84     
  Branches     1179     1214      +35     
==========================================
+ Hits         7494     7538      +44     
- Misses        192      212      +20     
- Partials      141      161      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greyltc greyltc force-pushed the use-pathlib branch 4 times, most recently from 7a0b6cc to 3bc82aa Compare October 7, 2025 18:42
self._exportBox(exporters.ExportTypes.SVG, ["<svg", "<g transform"])

exporters.export(self._box(), "out.svg")
exporters.export(self._box(), Path("out.svg"))
Copy link
Member

Choose a reason for hiding this comment

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

@greyltc Will users have to import pathlib in their scripts now to be able to use exporters.export? If so, that will break existing user-facing behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! This change means that everything that points to a place on disk goes through pathlib.Path, no more strings for that.

Luckily pathlib is built in (in python's standard library) though.

Copy link
Contributor Author

@greyltc greyltc Oct 8, 2025

Choose a reason for hiding this comment

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

If there are some API/user facing functions you'd like me to switch back to taking string inputs for file locations, let me know and I can switch them back.

Copy link
Member

Choose a reason for hiding this comment

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

Hey, all path arguments shall be strings. So this change cannot change any interface. +1 getting rid of the external dep.

Copy link
Contributor Author

@greyltc greyltc Oct 8, 2025

Choose a reason for hiding this comment

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

all path arguments shall be strings

Where?

Of course the calls to the underlying opencascade library need to be strings (otherwise none of the tests in this PR would have passed). But is your statement here meant to mandate that the paths in the python code be strings everywhere as well?

  • Before this PR: some of the python path objects were str, some were pathlib.Path and some were path.Path.
  • After this PR: every path object is pathlib.Path, except for right as they get passed to the OCP lib calls, they get converted to str, just for those calls.

Copy link
Member

Choose a reason for hiding this comment

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

I mean: the current API shall not change (i.e. not change to function/method signatures). What happens in the function/method bodies is a different story of course.

Copy link
Contributor Author

@greyltc greyltc Oct 8, 2025

Choose a reason for hiding this comment

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

Ok. So those 6 functions listed here (plus Assembly.save) are the ones that need to remain as path string input objects, correct?

Would it be alright if I change them so they can take both str and pathlib.Path path object type inputs?

Copy link
Member

Choose a reason for hiding this comment

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

I think more (Shape.exportStep, ....), essentially I expect no (backward incompatible) signature change from this pr.

Sure, you could annotate it as Path | str

@greyltc greyltc force-pushed the use-pathlib branch 5 times, most recently from 1ca0aba to 80476cb Compare October 12, 2025 18:40
Comment on lines +532 to +533
if isinstance(path, str):
path = Path(path)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if isinstance(path, str):
path = Path(path)
path = Path(path)

or

Suggested change
if isinstance(path, str):
path = Path(path)
path = Path(path) if isinstance(path, str) else path

if self.obj:
yield self.obj if isinstance(self.obj, Shape) else Compound.makeCompound(
s for s in self.obj.vals() if isinstance(s, Shape)
yield (
Copy link
Member

Choose a reason for hiding this comment

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

Why is this changed?


@deprecate()
def readAndDeleteFile(fileName):
def readAndDeleteFile(fileName: Path):
Copy link
Member

Choose a reason for hiding this comment

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

Is this really needed? No changes to legacy functions please.

if isinstance(child.obj, Shape)
else Compound.makeCompound(
s for s in child.obj.vals() if isinstance(s, Shape)
(
Copy link
Member

Choose a reason for hiding this comment

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

Again, why is this changed?


def write3mf(
self, outfile: Union[PathLike, str, IO[bytes]],
self, outfile: Union[Path, str, IO[bytes]],
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this, shouldn't everything be typed as PathLike | str?

# verify that the number of solids is correct
self.assertEqual(len(obj4.solids().vals()), 5)

obj4point5 = (
Copy link
Member

Choose a reason for hiding this comment

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

I assume that you are smoke testing something here. Maybe add a comment

# %% export
def test_export():

filename = Path("box.brep")
Copy link
Member

Choose a reason for hiding this comment

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

This is unnecessary

# smoke test for now
with tmpdir:
show(wp, interact=False, screenshot="img.png", trihedron=False, gradient=False)
filename = tmpdir / "img.png"
Copy link
Member

Choose a reason for hiding this comment

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

Please revert the change. AFAIK pathlib supports with

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.

3 participants