-
Notifications
You must be signed in to change notification settings - Fork 59
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
Anypath abstractmethods #266
Conversation
Codecov Report
@@ Coverage Diff @@
## master #266 +/- ##
========================================
- Coverage 94.8% 92.3% -2.5%
========================================
Files 21 21
Lines 1321 1453 +132
========================================
+ Hits 1253 1342 +89
- Misses 68 111 +43
|
Sorry @chbehrens. Delay is because, as you point out, the current implementation is a lot of boilerplate which seems less than ideal just to support use of |
Don't get me wrong, I'm also not keen on it the way it is. I just did it to show what I'd like to achieve in the end behavior-wise but preferably via something more meta programming like. That's why I made it a draft and was wondering whether you have some ideas or what you think of the overall intended behavior. |
@ringohoffman Do you have thoughts on this after implementing your changes in #298? Is there a cleaner/easier way to get useful type hinting for |
I was asking about this over at microsoft/pyright#4331 and got back a few suggestions... and the virtual superclass approach was not one of them. I will have to play around to see which results in the most expected / convenient typing experience. |
Much appreciated! Curious what you discover.
😆 😆 😆 |
@chbehrens I'm going through old PRs to keep them moving. I think that I've come around on this. I was hoping for some cleaner upstream fix that makes this kind of polymorphic class work, but I don't think there's another way to get useful completions for Would you be willing to rebase this on the latest and add tests/docs? Outside of that, I am curious if one of the other ideas in this thread might work: microsoft/pyright#4331 (comment) It does seem that |
I'll try to have a look at it if I find time but let's just close this, an issue would be better suited to track the topic if necessary. |
I've experimented with Protocols, and one of the main problems IIRC is that the Pydantic validation methods were getting caught up in it. There's also some annoying stuff with API changes to |
Disclaimer: I quickly hacked this as a draft/suggestion. There might be better/nicer methods to achieve the same.
I suggest to add some abstractmethods to AnyPath so that the methods available for both CloudPath and pathlib.Path can be seen when AnyPath is used as type annotation. It would be nice if there are more elegant solutions but I think the overall behavior would be useful.
Currently missing:
I probably won't be around the next days but wanted to leave this as starting point to discuss.