mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
mypy: Fix future syntax errors and other minor mistakes.
When we move to the Python 3 mypy syntax, we can't reference a class before its definition.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Any
|
from zulip import Client
|
||||||
from api.zulip import Client
|
|
||||||
|
|
||||||
def add_subscriptions(client):
|
def add_subscriptions(client):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ def get_whitespace_and_comments(tokens, i, end, line=None):
|
|||||||
|
|
||||||
|
|
||||||
def parse_sections(tokens, start, end):
|
def parse_sections(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> CssSectionList
|
# type: (List[Token], int, int) -> 'CssSectionList'
|
||||||
i = start
|
i = start
|
||||||
sections = []
|
sections = []
|
||||||
while i < end:
|
while i < end:
|
||||||
@@ -101,7 +101,7 @@ def parse_sections(tokens, start, end):
|
|||||||
return section_list
|
return section_list
|
||||||
|
|
||||||
def parse_section(tokens, start, end, pre_fluff, post_fluff):
|
def parse_section(tokens, start, end, pre_fluff, post_fluff):
|
||||||
# type: (List[Token], int, int, str, str) -> Union[CssNestedSection, CssSection]
|
# type: (List[Token], int, int, str, str) -> Union['CssNestedSection', 'CssSection']
|
||||||
assert not ws(tokens[start].s)
|
assert not ws(tokens[start].s)
|
||||||
assert tokens[end-1].s == '}' # caller should strip trailing fluff
|
assert tokens[end-1].s == '}' # caller should strip trailing fluff
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ def parse_section(tokens, start, end, pre_fluff, post_fluff):
|
|||||||
return section
|
return section
|
||||||
|
|
||||||
def parse_selectors_section(tokens, start, end):
|
def parse_selectors_section(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> Tuple[int, CssSelectorList]
|
# type: (List[Token], int, int) -> Tuple[int, 'CssSelectorList']
|
||||||
start, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
start, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
||||||
assert pre_fluff == ''
|
assert pre_fluff == ''
|
||||||
i = start
|
i = start
|
||||||
@@ -143,7 +143,7 @@ def parse_selectors_section(tokens, start, end):
|
|||||||
return i, selector_list
|
return i, selector_list
|
||||||
|
|
||||||
def parse_selectors(tokens, start, end):
|
def parse_selectors(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> CssSelectorList
|
# type: (List[Token], int, int) -> 'CssSelectorList'
|
||||||
i = start
|
i = start
|
||||||
selectors = []
|
selectors = []
|
||||||
while i < end:
|
while i < end:
|
||||||
@@ -190,7 +190,7 @@ def parse_selector(tokens, start, end):
|
|||||||
return selector
|
return selector
|
||||||
|
|
||||||
def parse_declaration_block(tokens, start, end):
|
def parse_declaration_block(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> CssDeclarationBlock
|
# type: (List[Token], int, int) -> 'CssDeclarationBlock'
|
||||||
assert tokens[start].s == '{' # caller should strip leading fluff
|
assert tokens[start].s == '{' # caller should strip leading fluff
|
||||||
assert tokens[end-1].s == '}' # caller should strip trailing fluff
|
assert tokens[end-1].s == '}' # caller should strip trailing fluff
|
||||||
i = start + 1
|
i = start + 1
|
||||||
@@ -212,7 +212,7 @@ def parse_declaration_block(tokens, start, end):
|
|||||||
return declaration_block
|
return declaration_block
|
||||||
|
|
||||||
def parse_declaration(tokens, start, end):
|
def parse_declaration(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> CssDeclaration
|
# type: (List[Token], int, int) -> 'CssDeclaration'
|
||||||
i, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
i, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
||||||
|
|
||||||
if (i >= end) or (tokens[i].s == '}'):
|
if (i >= end) or (tokens[i].s == '}'):
|
||||||
@@ -241,7 +241,7 @@ def parse_declaration(tokens, start, end):
|
|||||||
return declaration
|
return declaration
|
||||||
|
|
||||||
def parse_value(tokens, start, end):
|
def parse_value(tokens, start, end):
|
||||||
# type: (List[Token], int, int) -> CssValue
|
# type: (List[Token], int, int) -> 'CssValue'
|
||||||
i, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
i, pre_fluff = get_whitespace_and_comments(tokens, start, end)
|
||||||
if i < end:
|
if i < end:
|
||||||
value = tokens[i]
|
value = tokens[i]
|
||||||
@@ -353,7 +353,7 @@ def handle_postfluff(post_fluff, indent=False, space_after_first_line=False):
|
|||||||
|
|
||||||
class CssSectionList(object):
|
class CssSectionList(object):
|
||||||
def __init__(self, tokens, sections):
|
def __init__(self, tokens, sections):
|
||||||
# type: (List[Token], List[Union[CssNestedSection, CssSection]]) -> None
|
# type: (List[Token], List[Union['CssNestedSection', 'CssSection']]) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.sections = sections
|
self.sections = sections
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ class CssSectionList(object):
|
|||||||
|
|
||||||
class CssNestedSection(object):
|
class CssNestedSection(object):
|
||||||
def __init__(self, tokens, selector_list, section_list, pre_fluff, post_fluff):
|
def __init__(self, tokens, selector_list, section_list, pre_fluff, post_fluff):
|
||||||
# type: (List[Token], CssSelectorList, CssSectionList, str, str) -> None
|
# type: (List[Token], 'CssSelectorList', CssSectionList, str, str) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.selector_list = selector_list
|
self.selector_list = selector_list
|
||||||
self.section_list = section_list
|
self.section_list = section_list
|
||||||
@@ -391,7 +391,7 @@ class CssNestedSection(object):
|
|||||||
|
|
||||||
class CssSection(object):
|
class CssSection(object):
|
||||||
def __init__(self, tokens, selector_list, declaration_block, pre_fluff, post_fluff):
|
def __init__(self, tokens, selector_list, declaration_block, pre_fluff, post_fluff):
|
||||||
# type: (List[Token], CssSelectorList, CssDeclarationBlock, str, str) -> None
|
# type: (List[Token], 'CssSelectorList', 'CssDeclarationBlock', str, str) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.selector_list = selector_list
|
self.selector_list = selector_list
|
||||||
self.declaration_block = declaration_block
|
self.declaration_block = declaration_block
|
||||||
@@ -410,7 +410,7 @@ class CssSection(object):
|
|||||||
|
|
||||||
class CssSelectorList(object):
|
class CssSelectorList(object):
|
||||||
def __init__(self, tokens, selectors):
|
def __init__(self, tokens, selectors):
|
||||||
# type: (List[Token], List[CssSelector]) -> None
|
# type: (List[Token], List['CssSelector']) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.selectors = selectors
|
self.selectors = selectors
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ class CssSelector(object):
|
|||||||
|
|
||||||
class CssDeclarationBlock(object):
|
class CssDeclarationBlock(object):
|
||||||
def __init__(self, tokens, declarations):
|
def __init__(self, tokens, declarations):
|
||||||
# type: (List[Token], List[CssDeclaration]) -> None
|
# type: (List[Token], List['CssDeclaration']) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.declarations = declarations
|
self.declarations = declarations
|
||||||
|
|
||||||
@@ -447,7 +447,7 @@ class CssDeclarationBlock(object):
|
|||||||
|
|
||||||
class CssDeclaration(object):
|
class CssDeclaration(object):
|
||||||
def __init__(self, tokens, pre_fluff, post_fluff, css_property, css_value, semicolon):
|
def __init__(self, tokens, pre_fluff, post_fluff, css_property, css_value, semicolon):
|
||||||
# type: (List[Token], str, str, str, CssValue, bool) -> None
|
# type: (List[Token], str, str, str, 'CssValue', bool) -> None
|
||||||
self.tokens = tokens
|
self.tokens = tokens
|
||||||
self.pre_fluff = pre_fluff
|
self.pre_fluff = pre_fluff
|
||||||
self.post_fluff = post_fluff
|
self.post_fluff = post_fluff
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Graph(object):
|
|||||||
self.nodes.add(child)
|
self.nodes.add(child)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
# type: () -> Graph
|
# type: () -> 'Graph'
|
||||||
return Graph(self.edges())
|
return Graph(self.edges())
|
||||||
|
|
||||||
def num_edges(self):
|
def num_edges(self):
|
||||||
@@ -28,7 +28,7 @@ class Graph(object):
|
|||||||
return len(self.edges())
|
return len(self.edges())
|
||||||
|
|
||||||
def minus_edge(self, edge):
|
def minus_edge(self, edge):
|
||||||
# type: (Edge) -> Graph
|
# type: (Edge) -> 'Graph'
|
||||||
edges = self.edges().copy()
|
edges = self.edges().copy()
|
||||||
edges.remove(edge)
|
edges.remove(edge)
|
||||||
return Graph(edges)
|
return Graph(edges)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class HtmlTreeBranch(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, tags, fn):
|
def __init__(self, tags, fn):
|
||||||
# type: (List[TagInfo], Optional[str]) -> None
|
# type: (List['TagInfo'], Optional[str]) -> None
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
self.fn = fn
|
self.fn = fn
|
||||||
self.line = tags[-1].token.line
|
self.line = tags[-1].token.line
|
||||||
@@ -189,8 +189,8 @@ def html_tag_tree(text):
|
|||||||
|
|
||||||
|
|
||||||
def build_id_dict(templates):
|
def build_id_dict(templates):
|
||||||
# type: (List[str]) -> (Dict[str,List[str]])
|
# type: (List[str]) -> (Dict[str, List[str]])
|
||||||
template_id_dict = defaultdict(list) # type: (Dict[str,List[str]])
|
template_id_dict = defaultdict(list) # type: (Dict[str, List[str]])
|
||||||
|
|
||||||
for fn in templates:
|
for fn in templates:
|
||||||
text = open(fn).read()
|
text = open(fn).read()
|
||||||
|
|||||||
Reference in New Issue
Block a user