Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NewType. #263

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Support NewType. #263

merged 1 commit into from
Nov 27, 2024

Conversation

BrianPugh
Copy link
Owner

@BrianPugh BrianPugh commented Nov 26, 2024

@m09 can you play around with this and give feedback? I'm not experienced with NewType, so I could use some backup 😄. The actual passed in object never gets cast to the declared new-type, but I don't think that matters since static type checkers in the parenting project won't be peeking into Cyclopts.

Addresses #262.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.09%. Comparing base (17bc23e) to head (6578b73).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #263      +/-   ##
==========================================
+ Coverage   94.08%   94.09%   +0.01%     
==========================================
  Files          26       26              
  Lines        2975     2981       +6     
  Branches      627      627              
==========================================
+ Hits         2799     2805       +6     
  Misses         84       84              
  Partials       92       92              
Flag Coverage Δ
unittests 94.09% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@m09
Copy link

m09 commented Nov 26, 2024

I tried it in a few ways (newtype alone, in a union, in a list, then give it as argument to a function to see if mypy complains) and everything went perfectly fine on my 3.10 (as you suspected I didn't get warnings from mypy even though the object is not cast).

I cannot speak for other python versions but it looks very promising (and what a lightning fast PR!)

Thanks for the great work :)

@BrianPugh
Copy link
Owner Author

good enough for me! Other python versions are checked by the unit tests. Merging now and this will be available in v3.1.1 momentarily!

@BrianPugh BrianPugh merged commit 8c403b5 into main Nov 27, 2024
17 checks passed
@BrianPugh BrianPugh deleted the new-type branch November 27, 2024 01:51
@BrianPugh BrianPugh mentioned this pull request Nov 27, 2024
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