summaryrefslogtreecommitdiff
path: root/sphinx/websupport
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/websupport')
-rw-r--r--sphinx/websupport/__init__.py10
-rw-r--r--sphinx/websupport/storage/sqlalchemy_db.py12
-rw-r--r--sphinx/websupport/storage/sqlalchemystorage.py2
3 files changed, 16 insertions, 8 deletions
diff --git a/sphinx/websupport/__init__.py b/sphinx/websupport/__init__.py
index 0323a32e8..6d6b289dc 100644
--- a/sphinx/websupport/__init__.py
+++ b/sphinx/websupport/__init__.py
@@ -26,6 +26,10 @@ from sphinx.websupport import errors
from sphinx.websupport.search import BaseSearch, SEARCH_ADAPTERS
from sphinx.websupport.storage import StorageBackend
+if False:
+ # For type annotation
+ from typing import Dict # NOQA
+
class WebSupport(object):
"""The main API class for the web support package. All interactions
@@ -66,7 +70,7 @@ class WebSupport(object):
self._init_search(search)
self._init_storage(storage)
- self._globalcontext = None
+ self._globalcontext = None # type: ignore
self._make_base_comment_options()
@@ -119,7 +123,7 @@ class WebSupport(object):
raise RuntimeError('No srcdir associated with WebSupport object')
app = Sphinx(self.srcdir, self.srcdir, self.outdir, self.doctreedir,
'websupport', status=self.status, warning=self.warning)
- app.builder.set_webinfo(self.staticdir, self.staticroot,
+ app.builder.set_webinfo(self.staticdir, self.staticroot, # type: ignore
self.search, self.storage)
self.storage.pre_build()
@@ -384,7 +388,7 @@ class WebSupport(object):
that remains the same throughout the lifetime of the
:class:`~sphinx.websupport.WebSupport` object.
"""
- self.base_comment_opts = {}
+ self.base_comment_opts = {} # type: Dict[unicode, unicode]
if self.docroot != '':
comment_urls = [
diff --git a/sphinx/websupport/storage/sqlalchemy_db.py b/sphinx/websupport/storage/sqlalchemy_db.py
index 75dcf2538..bbafc4860 100644
--- a/sphinx/websupport/storage/sqlalchemy_db.py
+++ b/sphinx/websupport/storage/sqlalchemy_db.py
@@ -17,13 +17,17 @@ from sqlalchemy import Column, Integer, Text, String, Boolean, \
from sqlalchemy.orm import relation, sessionmaker, aliased
from sqlalchemy.ext.declarative import declarative_base
+if False:
+ # For type annotation
+ from typing import List # NOQA
+
Base = declarative_base()
Session = sessionmaker()
db_prefix = 'sphinx_'
-class Node(Base):
+class Node(Base): # type: ignore
"""Data about a Node in a doctree."""
__tablename__ = db_prefix + 'nodes'
@@ -74,7 +78,7 @@ class Node(Base):
:param results: the flat list of comments
:param username: the name of the user requesting the comments.
"""
- comments = []
+ comments = [] # type: List
list_stack = [comments]
for r in results:
if username:
@@ -101,7 +105,7 @@ class Node(Base):
self.source = source
-class CommentVote(Base):
+class CommentVote(Base): # type: ignore
"""A vote a user has made on a Comment."""
__tablename__ = db_prefix + 'commentvote'
@@ -117,7 +121,7 @@ class CommentVote(Base):
self.value = value
-class Comment(Base):
+class Comment(Base): # type: ignore
"""An individual Comment being stored."""
__tablename__ = db_prefix + 'comments'
diff --git a/sphinx/websupport/storage/sqlalchemystorage.py b/sphinx/websupport/storage/sqlalchemystorage.py
index 08cbc4935..48997b032 100644
--- a/sphinx/websupport/storage/sqlalchemystorage.py
+++ b/sphinx/websupport/storage/sqlalchemystorage.py
@@ -22,7 +22,7 @@ from sphinx.websupport.storage.sqlalchemy_db import Base, Node, \
Comment, CommentVote, Session
from sphinx.websupport.storage.differ import CombinedHtmlDiff
-if sqlalchemy.__version__[:3] < '0.5':
+if sqlalchemy.__version__[:3] < '0.5': # type: ignore
raise ImportError('SQLAlchemy version 0.5 or greater is required for this '
'storage backend; you have version %s' % sqlalchemy.__version__)