Pydantic integration and AnyPath polymorphic class#130
Conversation
Codecov Report
@@ Coverage Diff @@
## master #130 +/- ##
========================================
+ Coverage 92.0% 92.2% +0.2%
========================================
Files 19 20 +1
Lines 1066 1098 +32
========================================
+ Hits 981 1013 +32
Misses 85 85
|
Agreed to leave it out of the explicit requirements and just use it in dev. |
pjbull
left a comment
There was a problem hiding this comment.
This is 🔥 🔥 🔥
One thought is I don't think this implementation will support Pure paths. I'm fine opening an issue and deciding how we want to handle that later, but just wanted to mention.
|
I thought of the
|
AnyPathpolymorphic class. Closes AddAnyPathclass that will dispatch to either local or cloud #77.pathlib.Pathinstance appropriately based on the input.isinstanceandissubclasslogic so that it's a virtual superclass ofCloudPathandPath.AnyPathcan be used as a type declaration on a Pydantic model, and the validation will appropriately try to cast the input into the class. Closes Add pydantic validator support #126.Question:
requirements-dev.txtfor the tests. Should we make this anextrasoption instead? There's no direct runtime dependency by cloudpathlib on pydantic. You'd only actually need pydantic if you try to make a model and need to importBaseModel.Note:
issubclass, so theAnyPathimplementation doesn't quite pass mypy. I'm currently just putting in some# type: ignores, but one may consider this implementation not-type-safe shenanigans. I may open an issue on mypy later to ask about if there is a recommended way to do things.