Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 865b206

Browse files
committed
PEP8 : re-arrange imports
Put all module level imports at top
1 parent be9cde6 commit 865b206

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

lib/matplotlib/__init__.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@
107107
import distutils.version
108108
from itertools import chain
109109

110+
import io
111+
import locale
112+
import os
113+
import re
114+
import tempfile
115+
import warnings
116+
import contextlib
117+
import distutils.sysconfig
118+
119+
# cbook must import matplotlib only within function
120+
# definitions, so it is safe to import from it here.
121+
from matplotlib.cbook import is_string_like, mplDeprecation
122+
from matplotlib.compat import subprocess
123+
from matplotlib.rcsetup import (defaultParams,
124+
validate_backend)
125+
126+
import numpy
127+
from six.moves.urllib.request import urlopen
128+
from six.moves import reload_module as reload
129+
110130
__version__ = str('1.5.dev1')
111131
__version__numpy__ = str('1.6') # minimum required numpy version
112132

@@ -164,39 +184,11 @@ def _forward_ilshift(self, other):
164184
return self
165185
pyparsing.Forward.__ilshift__ = _forward_ilshift
166186

167-
try:
168-
from urllib.request import urlopen
169-
except ImportError:
170-
from urllib2 import urlopen
171-
172-
import io
173-
import locale
174-
import os
175-
import re
176-
import tempfile
177-
import warnings
178-
import contextlib
179-
import distutils.sysconfig
180-
181-
# cbook must import matplotlib only within function
182-
# definitions, so it is safe to import from it here.
183-
from matplotlib.cbook import is_string_like, mplDeprecation
184-
from matplotlib.compat import subprocess
185-
186-
try:
187-
reload
188-
except NameError:
189-
# Python 3
190-
from imp import reload
191-
192187

193188
if not hasattr(sys, 'argv'): # for modpython
194189
sys.argv = [str('modpython')]
195190

196191

197-
from matplotlib.rcsetup import (defaultParams,
198-
validate_backend)
199-
200192
major, minor1, minor2, s, tmp = sys.version_info
201193
_python24 = (major == 2 and minor1 >= 4) or major >= 3
202194

@@ -208,7 +200,6 @@ def _forward_ilshift(self, other):
208200
raise ImportError('matplotlib requires Python 2.4 or later')
209201

210202

211-
import numpy
212203
if not compare_versions(numpy.__version__, __version__numpy__):
213204
raise ImportError(
214205
'numpy %s or later is required; you have %s' % (
@@ -1125,7 +1116,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
11251116
rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
11261117

11271118
if rcParams['axes.formatter.use_locale']:
1128-
import locale
11291119
locale.setlocale(locale.LC_ALL, '')
11301120

11311121

0 commit comments

Comments
 (0)