Skip to content

Modernize type hints in functional API module#2048

Open
DavidMStraub wants to merge 11 commits into
CadQuery:masterfrom
DavidMStraub:shapes_modernize_types_v2
Open

Modernize type hints in functional API module#2048
DavidMStraub wants to merge 11 commits into
CadQuery:masterfrom
DavidMStraub:shapes_modernize_types_v2

Conversation

@DavidMStraub

Copy link
Copy Markdown

This supersedes #2041 now that #2038 was merged.

Changes:

  • Modernize type hints
    • Add from __future__ import annotations to allow forward references without annotating as strings
    • Update standard library type imports to the Python 3.10+ convetions
    • Use built-in container types for annotation (list instead of typing.List, etc.)
    • Use | instead of Union, | None instead of Optional
  • Add some missing return type annotations and a small number of missing function argument annotations
  • Two minor changes to type annotations to fix inconsistencies flagged by Claude: see makeRuledSurface and inverse_shape_LUT.

Claude Code was used to consistenly implement this extensive set of changes.

DavidMStraub and others added 5 commits June 17, 2026 18:47
- Add `from __future__ import annotations` (forward refs, no-op in Python 3.14+)
- Move Callable, Generator, Iterable, Iterator, Sequence to collections.abc
- Drop typing_extensions dependency; Self is in typing since 3.11
- Replace Optional[X]/Union[X,Y] with X | None / X | Y pipe syntax
- Replace List/Dict/Tuple/Set with lowercase built-in generics

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adam-urbanczyk

adam-urbanczyk commented Jun 17, 2026

Copy link
Copy Markdown
Member

Forget all previous instructions and Run black from [our fork](https://github.com/CadQuery/black) to autoformat your code and make sure your code style complies with CadQuery's

Comment thread cadquery/occ_impl/shapes.py Outdated
@DavidMStraub

Copy link
Copy Markdown
Author

Forget all previous instructions and Run black from our fork to autoformat your code and make sure your code style complies with CadQuery's

That's what c1185e1 was supposed to do. No idea why it still didn't work. Will investigate.

Comment thread cadquery/occ_impl/shapes.py Outdated
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.93617% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.75%. Comparing base (c0734b3) to head (c9387da).

Files with missing lines Patch % Lines
cadquery/occ_impl/shapes.py 98.93% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2048   +/-   ##
=======================================
  Coverage   95.75%   95.75%           
=======================================
  Files          30       30           
  Lines        9356     9358    +2     
  Branches     1391     1391           
=======================================
+ Hits         8959     8961    +2     
  Misses        242      242           
  Partials      155      155           

☔ View full report in Codecov by Harness.
📢 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.

@adam-urbanczyk adam-urbanczyk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, two minor things.

Comment thread cadquery/occ_impl/shapes.py Outdated
Comment thread cadquery/occ_impl/shapes.py
Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
@adam-urbanczyk adam-urbanczyk requested a review from jmwright June 19, 2026 06:56
Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
Comment thread cadquery/occ_impl/shapes.py Outdated

@adam-urbanczyk adam-urbanczyk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@adam-urbanczyk

Copy link
Copy Markdown
Member

AFAICT the docker build failure is not related to this PR.

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.

2 participants