Fix flake8 violations

This commit is contained in:
Takeshi KOMIYA 2019-12-27 01:28:16 +09:00
parent 8ca1bf9aa6
commit 69d67e7050

View File

@ -17,7 +17,7 @@ from importlib import import_module
from sphinx.errors import PycodeError from sphinx.errors import PycodeError
from sphinx.pycode.parser import Parser from sphinx.pycode.parser import Parser
from sphinx.util import get_module_source, detect_encoding from sphinx.util import detect_encoding
class ModuleAnalyzer: class ModuleAnalyzer:
@ -44,7 +44,7 @@ class ModuleAnalyzer:
if source: if source:
# no exception and not None - it must be module source # no exception and not None - it must be module source
return filename, source return filename, source
except ImportError as err: except ImportError:
pass # Try other "source-mining" methods pass # Try other "source-mining" methods
if filename is None and loader and getattr(loader, 'get_filename', None): if filename is None and loader and getattr(loader, 'get_filename', None):
# have loader, but no filename # have loader, but no filename
@ -63,8 +63,8 @@ class ModuleAnalyzer:
filename += 'w' filename += 'w'
elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')): elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')):
raise PycodeError('source is not a .py file: %r' % filename) raise PycodeError('source is not a .py file: %r' % filename)
elif ('.egg' + os.path.sep) in filename: elif ('.egg' + path.sep) in filename:
pat = '(?<=\\.egg)' + re.escape(os.path.sep) pat = '(?<=\\.egg)' + re.escape(path.sep)
eggpath, _ = re.split(pat, filename, 1) eggpath, _ = re.split(pat, filename, 1)
if path.isfile(eggpath): if path.isfile(eggpath):
return filename, None return filename, None