diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-01-22 22:05:38 +0900 |
|---|---|---|
| committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-02-04 15:14:51 +0900 |
| commit | dc2b153835af985c1bd940aa4116b78bf248b6e0 (patch) | |
| tree | 29383d6007d2f13c517ae4646e639362017aa9d4 /sphinx/pycode/__init__.py | |
| parent | 498fa379efe5b6b106c8d3eb56041164cdc8bab3 (diff) | |
| download | sphinx-git-dc2b153835af985c1bd940aa4116b78bf248b6e0.tar.gz | |
Update type annotations
Diffstat (limited to 'sphinx/pycode/__init__.py')
| -rw-r--r-- | sphinx/pycode/__init__.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index de951a19f..04353e805 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -27,17 +27,19 @@ class ModuleAnalyzer(object): @classmethod def for_string(cls, string, modname, srcname='<string>'): + # type: (unicode, unicode, unicode) -> ModuleAnalyzer if isinstance(string, bytes): return cls(BytesIO(string), modname, srcname) - return cls(StringIO(string), modname, srcname, decoded=True) + return cls(StringIO(string), modname, srcname, decoded=True) # type: ignore @classmethod def for_file(cls, filename, modname): + # type: (unicode, unicode) -> ModuleAnalyzer if ('file', filename) in cls.cache: return cls.cache['file', filename] try: with open(filename, 'rb') as f: - obj = cls(f, modname, filename) + obj = cls(f, modname, filename) # type: ignore cls.cache['file', filename] = obj except Exception as err: raise PycodeError('error opening %r' % filename, err) @@ -45,6 +47,7 @@ class ModuleAnalyzer(object): @classmethod def for_module(cls, modname): + # type: (str) -> ModuleAnalyzer if ('module', modname) in cls.cache: entry = cls.cache['module', modname] if isinstance(entry, PycodeError): @@ -126,7 +129,7 @@ if __name__ == '__main__': # ma = ModuleAnalyzer.for_file(__file__.rstrip('c'), 'sphinx.builders.html') ma = ModuleAnalyzer.for_file('sphinx/environment.py', 'sphinx.environment') - ma.tokenize() + ma.tokenize() # type: ignore x1 = time.time() ma.parse() x2 = time.time() |
