Merge lp:~jtv/launchpad/format-relative-imports into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Curtis Hovey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 16046 |
Proposed branch: | lp:~jtv/launchpad/format-relative-imports |
Merge into: | lp:launchpad |
Diff against target: |
24 lines (+5/-2) 1 file modified
utilities/format-imports (+5/-2) |
To merge this branch: | bzr merge lp:~jtv/launchpad/format-relative-imports |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | code | Approve | |
Review via email: mp+124878@code.launchpad.net |
Commit message
Teach format-imports about relative imports, so it doesn't crash on e.g. “from . import main.”
Description of the change
This is a backport of a change I made in MAAS: an import in python can now start with a module/package name or now, for a relative import, with a series of dots. From the script's perspective, either plays the same role in the import statement.
I discussed my solution with wgrant, SteveK, and lifeless but not very much came out. I had a bug and a fix so I took silence as assent.
It's not a particularly forward-looking solution: “.” is defined as local (duh) but there's no cleverness for “..” or “...” etc. — they're /probably/ local imports but the more dots there are, the less likely that becomes. At least my immediate problem of “.” is a clear-cut case. If we ever see more leading dots, that'd be a good time to figure out what the right thing to do is.
Jeroen
+1