diff options
Diffstat (limited to 'sphinx/domains/__init__.py')
-rw-r--r-- | sphinx/domains/__init__.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py index d241b1523..8f3e6a955 100644 --- a/sphinx/domains/__init__.py +++ b/sphinx/domains/__init__.py @@ -50,8 +50,8 @@ class ObjType: def __init__(self, lname: str, *roles: Any, **attrs: Any) -> None: self.lname = lname - self.roles = roles # type: Tuple - self.attrs = self.known_attrs.copy() # type: Dict + self.roles: Tuple = roles + self.attrs: Dict = self.known_attrs.copy() self.attrs.update(attrs) @@ -88,9 +88,9 @@ class Index(ABC): :rst:role:`ref` role. """ - name = None # type: str - localname = None # type: str - shortname = None # type: str + name: str = None + localname: str = None + shortname: str = None def __init__(self, domain: "Domain") -> None: if self.name is None or self.localname is None: @@ -181,31 +181,31 @@ class Domain: #: domain label: longer, more descriptive (used in messages) label = '' #: type (usually directive) name -> ObjType instance - object_types = {} # type: Dict[str, ObjType] + object_types: Dict[str, ObjType] = {} #: directive name -> directive class - directives = {} # type: Dict[str, Any] + directives: Dict[str, Any] = {} #: role name -> role callable - roles = {} # type: Dict[str, Union[RoleFunction, XRefRole]] + roles: Dict[str, Union[RoleFunction, XRefRole]] = {} #: a list of Index subclasses - indices = [] # type: List[Type[Index]] + indices: List[Type[Index]] = [] #: role name -> a warning message if reference is missing - dangling_warnings = {} # type: Dict[str, str] + dangling_warnings: Dict[str, str] = {} #: node_class -> (enum_node_type, title_getter) - enumerable_nodes = {} # type: Dict[Type[Node], Tuple[str, Callable]] + enumerable_nodes: Dict[Type[Node], Tuple[str, Callable]] = {} #: data value for a fresh environment - initial_data = {} # type: Dict + initial_data: Dict = {} #: data value - data = None # type: Dict + data: Dict = None #: data version, bump this when the format of `self.data` changes data_version = 0 def __init__(self, env: "BuildEnvironment") -> None: - self.env = env # type: BuildEnvironment - self._role_cache = {} # type: Dict[str, Callable] - self._directive_cache = {} # type: Dict[str, Callable] - self._role2type = {} # type: Dict[str, List[str]] - self._type2role = {} # type: Dict[str, str] + self.env: BuildEnvironment = env + self._role_cache: Dict[str, Callable] = {} + self._directive_cache: Dict[str, Callable] = {} + self._role2type: Dict[str, List[str]] = {} + self._type2role: Dict[str, str] = {} # convert class variables to instance one (to enhance through API) self.object_types = dict(self.object_types) @@ -226,8 +226,8 @@ class Domain: for rolename in obj.roles: self._role2type.setdefault(rolename, []).append(name) self._type2role[name] = obj.roles[0] if obj.roles else '' - self.objtypes_for_role = self._role2type.get # type: Callable[[str], List[str]] - self.role_for_objtype = self._type2role.get # type: Callable[[str], str] + self.objtypes_for_role: Callable[[str], List[str]] = self._role2type.get + self.role_for_objtype: Callable[[str], str] = self._type2role.get def setup(self) -> None: """Set up domain object.""" |