Patchwork [2,of,5,RESEND] util: rewrite pycompat imports to make pyflakes always happy

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 11, 2016, 3:50 p.m.
Message ID <b5992be53acb8080b0f9.1478879421@mimosa>
Download mbox | patch
Permalink /patch/17500/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 11, 2016, 3:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1476976178 -32400
#      Fri Oct 21 00:09:38 2016 +0900
# Node ID b5992be53acb8080b0f92c2756d7eb8d0e221d0c
# Parent  ea1fe2ae9003fa4588897545bbc89f1de17e3fa7
util: rewrite pycompat imports to make pyflakes always happy

I'll add more imports which would confuse pyflakes.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -46,25 +46,17 @@  from . import (
     pycompat,
 )
 
-for attr in (
-    'empty',
-    'httplib',
-    'httpserver',
-    'pickle',
-    'queue',
-    'urlerr',
-    'urlparse',
-    # we do import urlreq, but we do it outside the loop
-    #'urlreq',
-    'stringio',
-    'socketserver',
-    'xmlrpclib',
-):
-    a = pycompat.sysstr(attr)
-    globals()[a] = getattr(pycompat, a)
-
-# This line is to make pyflakes happy:
+empty = pycompat.empty
+httplib = pycompat.httplib
+httpserver = pycompat.httpserver
+pickle = pycompat.pickle
+queue = pycompat.queue
+socketserver = pycompat.socketserver
+stringio = pycompat.stringio
+urlerr = pycompat.urlerr
+urlparse = pycompat.urlparse
 urlreq = pycompat.urlreq
+xmlrpclib = pycompat.xmlrpclib
 
 if os.name == 'nt':
     from . import windows as platform