Repository navigation
fix(import): drop duplicate config annotation (mypy no-redef) - #44930
aminghadersohi wants to merge 1 commit into
Conversation
config was already declared as dict[str, Any] | None above the if schema: block. The inner config: Any = None re-annotation is redundant and trips mypy's no-redef check, since config is still bound to None before load_yaml runs either way.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44930 +/- ##
==========================================
+ Coverage 82.26% 82.43% +0.17%
==========================================
Files 2995 2995
Lines 185026 186898 +1872
Branches 42820 43316 +496
==========================================
+ Hits 152212 154071 +1859
+ Misses 30052 30027 -25
- Partials 2762 2800 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Superseded by #44932, which merged the same fix. |
Code Review Agent Run #86264bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
TL;DR
superset/commands/importers/v1/utils.pyhad two type annotations for the sameconfiglocal, which trips mypy'sno-redefcheck and makes thepre-commit (current)CI job red onmasterand on every PR that merges it.Why
ece8b8bd7b added
config: Any = Noneinside theif schema:block to fix anUnboundLocalErrorwhenload_yamlraises beforeconfigis assigned. That fix is correct, butconfigwas already declared a few lines above (config: dict[str, Any] | None = None, before theif schema:check), so the inner annotation re-declares the same variable with a different type and mypy reportsno-redef.Since
configis already bound toNonebefore entering theif schema:block, the inner re-binding was redundant for both typing and runtime behavior.What
Removes the inner
config: Any = Noneline (and its explanatory comment) fromload_configs. The outerconfig: dict[str, Any] | None = Nonedeclaration already guaranteesconfigis bound before thetry/exceptruns, so theexcept ValidationErrordiagnostic that inspectsconfigstill works exactly as before.How to test
Both pass locally, including the existing
UnboundLocalErrorregression test.