When fixing a file named foo/bar/baz.py where bar does not contain an
init.py, we currently calculate that the module is named
foo.bar.baz. Then, if something like baz.Spam is included in an
annotation, we will erroneously insert an import of baz.
Fix this by calculating module name based on the directory crawl
(which we already do to find the module root).
This is wrong if the file is supposed to be in a namespace packages, I
guess, but I'm pretty sure the existing code is also wrong in that
case but in different ways.
The test framework doesn't really seem set up to test this kind of
thing, so there isn't a test, but I tested manually.
When fixing a file named foo/bar/baz.py where bar does not contain an init.py, we currently calculate that the module is named foo.bar.baz. Then, if something like baz.Spam is included in an annotation, we will erroneously insert an import of baz. Fix this by calculating module name based on the directory crawl (which we already do to find the module root).
This is wrong if the file is supposed to be in a namespace packages, I guess, but I'm pretty sure the existing code is also wrong in that case but in different ways.
The test framework doesn't really seem set up to test this kind of thing, so there isn't a test, but I tested manually.