python: Convert assignment type annotations to Python 3.6 style.

Commit split by tabbott; this has changes to scripts/, tools/, and
puppet/.

scripts/lib/hash_reqs.py, scripts/lib/setup_venv.py,
scripts/lib/zulip_tools.py, and tools/lib/provision.py are excluded so
tools/provision still gives the right error message on Ubuntu 16.04
with Python 3.5.

Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:

-shebang_rules: List[Rule] = [
+shebang_rules: List["Rule"] = [

-trailing_whitespace_rule: Rule = {
+trailing_whitespace_rule: "Rule" = {

-whitespace_rules: List[Rule] = [
+whitespace_rules: List["Rule"] = [

-comma_whitespace_rule: List[Rule] = [
+comma_whitespace_rule: List["Rule"] = [

-prose_style_rules: List[Rule] = [
+prose_style_rules: List["Rule"] = [

-html_rules: List[Rule] = whitespace_rules + prose_style_rules + [
+html_rules: List["Rule"] = whitespace_rules + prose_style_rules + [

-    target_port: int = None
+    target_port: int

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-21 16:09:50 -07:00
committed by Tim Abbott
parent ad07814fa4
commit f8339f019d
26 changed files with 89 additions and 88 deletions

View File

@@ -20,8 +20,8 @@ class UnusedImagesLinterSpider(BaseDocumentationSpider):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self.static_images = set() # type: Set[str]
self.images_static_dir = get_images_dir(self.images_path) # type: str
self.static_images: Set[str] = set()
self.images_static_dir: str = get_images_dir(self.images_path)
def _is_external_url(self, url: str) -> bool:
is_external = url.startswith('http') and self.start_urls[0] not in url
@@ -43,7 +43,7 @@ class UnusedImagesLinterSpider(BaseDocumentationSpider):
class HelpDocumentationSpider(UnusedImagesLinterSpider):
name = "help_documentation_crawler"
start_urls = ['http://localhost:9981/help']
deny_domains = [] # type: List[str]
deny_domains: List[str] = []
deny = ['/privacy']
images_path = "static/images/help"
@@ -51,7 +51,7 @@ class HelpDocumentationSpider(UnusedImagesLinterSpider):
class APIDocumentationSpider(UnusedImagesLinterSpider):
name = 'api_documentation_crawler'
start_urls = ['http://localhost:9981/api']
deny_domains = [] # type: List[str]
deny_domains: List[str] = []
images_path = "static/images/api"
class PorticoDocumentationSpider(BaseDocumentationSpider):
@@ -79,4 +79,4 @@ class PorticoDocumentationSpider(BaseDocumentationSpider):
'http://localhost:9981/for/working-groups-and-communities',
'http://localhost:9981/for/mystery-hunt',
'http://localhost:9981/security']
deny_domains = [] # type: List[str]
deny_domains: List[str] = []

View File

@@ -44,12 +44,12 @@ VNU_IGNORE = re.compile(r'|'.join([
class BaseDocumentationSpider(scrapy.Spider):
name = None # type: Optional[str]
name: Optional[str] = None
# Exclude domain address.
deny_domains = [] # type: List[str]
start_urls = [] # type: List[str]
deny = [] # type: List[str]
file_extensions = ['.' + ext for ext in IGNORED_EXTENSIONS] # type: List[str]
deny_domains: List[str] = []
start_urls: List[str] = []
deny: List[str] = []
file_extensions: List[str] = ['.' + ext for ext in IGNORED_EXTENSIONS]
tags = ('a', 'area', 'img')
attrs = ('href', 'src')
@@ -107,7 +107,7 @@ class BaseDocumentationSpider(scrapy.Spider):
return callback
def _make_requests(self, url: str) -> Iterable[Request]:
callback = self.parse # type: Callable[[Response], Optional[Iterable[Request]]]
callback: Callable[[Response], Optional[Iterable[Request]]] = self.parse
dont_filter = False
method = 'GET'
if self._is_external_url(url):