Submitter | Yuya Nishihara |
---|---|
Date | May 18, 2016, 11:49 a.m. |
Message ID | <20160518204948.6c2d1902@mimosa> |
Download | mbox | patch |
Permalink | /patch/15162/ |
State | Superseded |
Commit | b3a677c82a35e499e84f69245f65e682c4be698f |
Headers | show |
Comments
Yuya Nishihara wrote: > I don't know if it is better idea than making policy module, but we can add > a utility function to avoid "from . import modulepolicy" in commands.py. > > --- a/mercurial/util.py > +++ b/mercurial/util.py > @@ -357,6 +357,10 @@ def popen4(cmd, env=None, newlines=False > env=env) > return p.stdin, p.stdout, p.stderr, p > > +def modulepolicy(): > + from . import modulepolicy > + return modulepolicy Personally, I'd like this. I did it the hard way because iirc augie objected to that style saying it's poor form. I don't really care which way we do it. I just need the ability to use hg debuginstall so that ./run-tests.py --with-hg works properly. The sooner the better.
> On May 18, 2016, at 14:00, timeless <timeless@gmail.com> wrote: > >> +def modulepolicy(): >> + from . import modulepolicy >> + return modulepolicy > > Personally, I'd like this. I did it the hard way because iirc augie > objected to that style saying it's poor form. I'm generally opposed to imports hidden inside functions because it's a great way to hide circular dependencies.
On Wed, 18 May 2016 14:13:07 -0400, Augie Fackler wrote: > > On May 18, 2016, at 14:00, timeless <timeless@gmail.com> wrote: > > > >> +def modulepolicy(): > >> + from . import modulepolicy > >> + return modulepolicy > > > > Personally, I'd like this. I did it the hard way because iirc augie > > objected to that style saying it's poor form. > > I'm generally opposed to imports hidden inside functions because it's a great > way to hide circular dependencies. Since there isn't circular dependencies, we could move the import outside of the function. But we'll need a way to silence the import checker.
Patch
--- a/mercurial/util.py +++ b/mercurial/util.py @@ -357,6 +357,10 @@ def popen4(cmd, env=None, newlines=False env=env) return p.stdin, p.stdout, p.stderr, p +def modulepolicy(): + from . import modulepolicy + return modulepolicy + def version(): """Return version information if available.""" try: