Fix remaining ty type errors in baker.py and generators.py#589
Fix remaining ty type errors in baker.py and generators.py#589benaduo wants to merge 1 commit intomodel-bakers:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughSmall, non-functional edits adding explicit type annotations: Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
fe66e1e to
1a178a9
Compare
- cast list passed to other_fields_to_skip.extend() to list[type] to resolve invalid-argument-type error; ty infers GenericRelation as type | None due to the conditional import - cast callable values to Callable[[], list[Any]] before calling to resolve call-top-callable error; ty does not narrow Top[...] types via callable() guards Both cast() calls use imports already present in the file.
1a178a9 to
6a3932d
Compare
amureki
left a comment
There was a problem hiding this comment.
Thanks for picking up the fixes here! 🙏
| other_fields_to_skip.extend( | ||
| cast(list[type], [GenericRelation, GenericForeignKey]) | ||
| ) |
There was a problem hiding this comment.
Honestly, a bit weird to cast here, I'd be also fine with just excluding it # type: ignore[list-item], but okay.
Summary
Fixes two remaining
tytype checker errors not addressed by PR #584.Changes
model_bakery/baker.py
list[type]annotation toother_fields_to_skipto fixinvalid-argument-typewhen.extend([GenericRelation, GenericForeignKey])is called.extend()call withcast(list[type], [...])so ty is satisfied with the conditionally-imported typesmodel_bakery/generators.py
dict[type, Callable]annotation todefault_mapping, replacing the trailing# type: dict[type, Callable]comment that ty does not recogniseMotivation
The CI linter job
linters (ty check model_bakery)still fails on these two issues after #584. This PR resolves them completely.Summary by CodeRabbit