Swap "import scap.foo as foo" imports for just "from . import foo"
AbandonedPublic

Authored by demon on Dec 4 2017, 3:26 PM.

Details

Reviewers
thcipriani
mmodell
Group Reviewers
Release-Engineering-Team
Patch without arc
git checkout -b D905 && curl -L https://phabricator.wikimedia.org/D905?download=true | git apply
Summary

The latter is more Pythonic, and is the official recommended style for python 3. Since we've got absolute_imports from the future, this will be fine.

I think it also fixes some circular references that were tripping me up on another patch.

Test Plan

Ran some unit tests, specifically with D902 and some follow-ups tacked on

Diff Detail

demon created this revision.Dec 4 2017, 3:26 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald TranscriptDec 4 2017, 3:26 PM
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript
demon requested review of this revision.Dec 4 2017, 3:27 PM
hashar edited the summary of this revision. (Show Details)Dec 4 2017, 4:01 PM
demon edited the test plan for this revision. (Show Details)Dec 4 2017, 4:08 PM

We switched this because of problems with circular imports: rMSCA70fb37008ba9: Replace most instances of `from . import x`. What has actually changed since then?

demon added a comment.Dec 4 2017, 6:01 PM
In D905#18041, @mmodell wrote:

We switched this because of problems with circular imports: rMSCA70fb37008ba9: Replace most instances of `from . import x`. What has actually changed since then?

I don't know. Python is fucking weird. I just know I was getting all kinds of crap from pytest and doing this fixed it.

mmodell added a comment.EditedDec 4 2017, 8:39 PM

The problem is that import x as y knows how to avoid recursion but from x import y can't handle recursion. In the past it would not work with from . import utils inside a module that utils also imports. Part of the problem is the way we do a bunch of imports inside of scap/__init__.py and tests/ definitely complicate things even further.

demon abandoned this revision.Dec 4 2017, 9:07 PM

And for some insane reason I don't get, I'm no longer getting the weird import errors I had earlier--was able to update D902 just fine.

F'ing Python...