See https://github.com/Textualize/textual/issues/2887 for the background to this. Long story short: Textual's coverage dropped from around 86% to 66% and it looks like it was us splitting this code out into a pytest plugin that was the cause.
This plugin imports parts of Textual, which in turn means that lots of module-level code was already run before coverage-checking kicked in; by the time tests were running these imports were cached.
So this commit seeks to hold off on the imports until they're actually needed.
See https://github.com/Textualize/textual/issues/2887 for the background to this. Long story short: Textual's coverage dropped from around 86% to 66% and it looks like it was us splitting this code out into a pytest plugin that was the cause.
This plugin imports parts of Textual, which in turn means that lots of module-level code was already run before coverage-checking kicked in; by the time tests were running these imports were cached.
So this commit seeks to hold off on the imports until they're actually needed.