summaryrefslogtreecommitdiff
path: root/sphinx/pycode
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-03-07 20:43:25 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-29 15:12:39 +0900
commita86346aca6bf99a8920da366caaad7c47809ecce (patch)
tree7aa786e7817f9f3e6a338d06df2f02534d91a4c5 /sphinx/pycode
parentaa773cbc88e692df731c78353a1043201bcb9f91 (diff)
downloadsphinx-git-a86346aca6bf99a8920da366caaad7c47809ecce.tar.gz
Remove deprecated features marked as RemovedInSphinx40Warning
Diffstat (limited to 'sphinx/pycode')
-rw-r--r--sphinx/pycode/__init__.py27
1 files changed, 5 insertions, 22 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index 55d5d2c1d..3f6ecaf2b 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -10,14 +10,12 @@
import re
import tokenize
-import warnings
from importlib import import_module
from io import StringIO
from os import path
from typing import Any, Dict, IO, List, Tuple, Optional
from zipfile import ZipFile
-from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.errors import PycodeError
from sphinx.pycode.parser import Parser
@@ -77,7 +75,7 @@ class ModuleAnalyzer:
@classmethod
def for_string(cls, string: str, modname: str, srcname: str = '<string>'
) -> "ModuleAnalyzer":
- return cls(StringIO(string), modname, srcname, decoded=True)
+ return cls(StringIO(string), modname, srcname)
@classmethod
def for_file(cls, filename: str, modname: str) -> "ModuleAnalyzer":
@@ -85,7 +83,7 @@ class ModuleAnalyzer:
return cls.cache['file', filename]
try:
with tokenize.open(filename) as f:
- obj = cls(f, modname, filename, decoded=True)
+ obj = cls(f, modname, filename)
cls.cache['file', filename] = obj
except Exception as err:
if '.egg' + path.sep in filename:
@@ -125,21 +123,12 @@ class ModuleAnalyzer:
cls.cache['module', modname] = obj
return obj
- def __init__(self, source: IO, modname: str, srcname: str, decoded: bool = False) -> None:
+ def __init__(self, source: IO, modname: str, srcname: str) -> None:
self.modname = modname # name of the module
self.srcname = srcname # name of the source file
# cache the source code as well
- pos = source.tell()
- if not decoded:
- warnings.warn('decode option for ModuleAnalyzer is deprecated.',
- RemovedInSphinx40Warning)
- self._encoding, _ = tokenize.detect_encoding(source.readline)
- source.seek(pos)
- self.code = source.read().decode(self._encoding)
- else:
- self._encoding = None
- self.code = source.read()
+ self.code = source.read()
# will be filled by parse()
self.annotations = None # type: Dict[Tuple[str, str], str]
@@ -150,7 +139,7 @@ class ModuleAnalyzer:
def parse(self) -> None:
"""Parse the source code."""
try:
- parser = Parser(self.code, self._encoding)
+ parser = Parser(self.code)
parser.parse()
self.attr_docs = {}
@@ -179,9 +168,3 @@ class ModuleAnalyzer:
self.parse()
return self.tags
-
- @property
- def encoding(self) -> str:
- warnings.warn('ModuleAnalyzer.encoding is deprecated.',
- RemovedInSphinx40Warning)
- return self._encoding