Add EmailStr and ValidationError to pydantic shim#2112
Conversation
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
👋 @devin-ai-integration[bot] |
📝 WalkthroughWalkthroughThe pull request adds two new imports— Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@elementary/utils/pydantic_shim.py`:
- Line 23: Remove the unused blanket "# noqa" on the pydantic v1 import in
pydantic_shim.py (the line starting with "from pydantic.v1 import"); either drop
the "# noqa" entirely or replace it with a specific Ruff code (e.g., "# noqa:
F401" if the import is intentionally unused) so the linter no longer reports
RUF100.
| validator, | ||
| ) | ||
| elif pydantic_major == "2": | ||
| from pydantic.v1 import ( # type: ignore # noqa |
There was a problem hiding this comment.
Remove unused blanket # noqa (RUF100).
Ruff reports the # noqa is unused; drop it or replace with a specific code if needed.
Proposed fix
-from pydantic.v1 import ( # type: ignore # noqa
+from pydantic.v1 import ( # type: ignore📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from pydantic.v1 import ( # type: ignore # noqa | |
| from pydantic.v1 import ( # type: ignore |
🧰 Tools
🪛 Ruff (0.15.0)
[warning] 23-23: Unused blanket noqa directive
Remove unused noqa directive
(RUF100)
🤖 Prompt for AI Agents
In `@elementary/utils/pydantic_shim.py` at line 23, Remove the unused blanket "#
noqa" on the pydantic v1 import in pydantic_shim.py (the line starting with
"from pydantic.v1 import"); either drop the "# noqa" entirely or replace it with
a specific Ruff code (e.g., "# noqa: F401" if the import is intentionally
unused) so the linter no longer reports RUF100.
Add EmailStr and ValidationError to pydantic shim
Summary
Adds
EmailStrandValidationErrorto the pydantic v1/v2 compatibility shim so downstream consumers (elementary-internal) can import all pydantic v1 types from a single source (elementary.utils.pydantic_shim) rather than mixing shim imports with directpydantic.v1imports.Review & Testing Checklist for Human
EmailStris available in bothpydanticv1 andpydantic.v1(v2 compat layer). Note:EmailStrrequires theemail-validatorpackage — confirm this is either already a transitive dependency or consider whether it should be explicitly added to elementary's dependencies.BaseModel,Extra,Field,create_model,root_validator,validator; this only adds to that list.Notes
pydantic.v1imports to use the shim instead.Summary by CodeRabbit