drivendataorg / cloudpathlib

Python pathlib-style classes for cloud storage services such as Amazon S3, Azure Blob Storage, and Google Cloud Storage.
https://cloudpathlib.drivendata.org
MIT License
477 stars 62 forks source link

mark pydantic integration (as an extra?) #385

Open cburroughs opened 11 months ago

cburroughs commented 11 months ago

We run mypy with ignore_missing_imports = false and then have an explicit allow list for packages. Since cloudpathlib imports pydantic (albeit behind a guard) but does not depends on it, mypy fails with :

cloudpath.py:1207: error: Cannot find implementation or library stub for module named "pydantic_core"  [import-not-found]

We would normally set ignore_missing_imports for just pydantic_core, but that's somewhat wonky in this case because pydantic_core does have type stubs, it's just not a dependency.

I think the most straightforward approach would be to add a pydantic extra to cloudpathlib, but there might be a fancier way to inform mypy directly of the "optional-ness" of the imports.

pjbull commented 11 months ago

I'm kind of on the fence about the value of adding an extra here. Would it work for us just to add type ignore at that import line? We don't actually use any of the pydantic types.

pjbull commented 6 months ago

Let's go with the ignore fix here