Skip to content

fix: replace unused pydantic import with importlib.util.find_spec#1343

Merged
sansyrox merged 2 commits into
mainfrom
fix/ruff-unused-pydantic-import
Mar 28, 2026
Merged

fix: replace unused pydantic import with importlib.util.find_spec#1343
sansyrox merged 2 commits into
mainfrom
fix/ruff-unused-pydantic-import

Conversation

@sansyrox
Copy link
Copy Markdown
Member

@sansyrox sansyrox commented Mar 22, 2026

Summary

Test plan

  • ruff check passes on the file
  • Pre-commit CI passes

Made with Cursor

Summary by CodeRabbit

  • Tests
    • Improved test collection to detect the presence of an external dependency without importing it, avoiding unnecessary imports during test discovery.
  • Refactor
    • Minor import cleanup to simplify internal module ordering.

Silences ruff F401 that was failing the pre-commit CI.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
robyn Ready Ready Preview, Comment Mar 22, 2026 2:47pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70214870-bfd5-45c8-8b9a-aea00e843913

📥 Commits

Reviewing files that changed from the base of the PR and between 404166f and 98c14c7.

📒 Files selected for processing (1)
  • robyn/openapi.py
✅ Files skipped from review due to trivial changes (1)
  • robyn/openapi.py

📝 Walkthrough

Walkthrough

Refactored pydantic detection in tests to use importlib.util.find_spec() (avoiding imports during collection) and cleaned up/reordered pydantic_support imports in robyn/openapi.py; no functional behavior changed.

Changes

Cohort / File(s) Summary
Test Collection Optimization
integration_tests/test_pydantic.py
Replaced try/except ImportError import check with importlib.util.find_spec("pydantic") and updated pytestmark to skip based on the spec check (no import during test discovery).
Import cleanup
robyn/openapi.py
Reordered/merged robyn.pydantic_support import lines to include get_pydantic_openapi_schema and is_pydantic_model; removed duplicate/previous import line. No logic changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 I sniffed for pydantic with a gentle spec,
No heavy import—just a lighter check.
Tests hop along, discovery stays spry,
Imports kept tidy beneath the sky. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing an unused pydantic import with importlib.util.find_spec to fix a ruff F401 lint error.
Description check ✅ Passed The description provides clear context about fixing the ruff F401 lint failure from PR #1342 and includes a basic test plan, though it lacks a structured format following the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ruff-unused-pydantic-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 22, 2026

Merging this PR will not alter performance

✅ 189 untouched benchmarks


Comparing fix/ruff-unused-pydantic-import (98c14c7) with main (a54ff96)

Open in CodSpeed

Copy link
Copy Markdown

@themavik themavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importlib.util.find_spec("pydantic") is a clean way to gate the integration test without importing pydantic just for the probe.

@sansyrox sansyrox merged commit 3e04c65 into main Mar 28, 2026
41 of 43 checks passed
@sansyrox sansyrox deleted the fix/ruff-unused-pydantic-import branch March 28, 2026 19:28
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