poly check: ignore dependencies within TYPE_CHECKING statement 🎉 #407
DavidVujic
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
From version 1.40 of the CLI and 1.46 of the Poetry plugin, the poly tool will ignore any imports (bricks or third-party) that are defined within an:
This means that the
poly checkcommand will not report on missing dependencies for imports that are defined within thetyping.TYPE_CHECKINGclause. This is useful for imported modules that only contain types used for typing annotations and not during runtime. Tools like MyPy already respects this syntax.There's one limitation though:
The poly commands (check, libs and test diff) will locate imports to ignore that are directly within the
ifclause, but not if there is nesting - such as a function definition within theif TYPE_CHECKINGstatement, that has imports in the function body.The idea origins from issue #336 and is requested by several Polylith users ⭐
Implementation details in Pull Request #406
Beta Was this translation helpful? Give feedback.
All reactions