diff --git a/tools/mypy.ini b/tools/mypy.ini index a80ecfd30c880a..e32acd468ff057 100644 --- a/tools/mypy.ini +++ b/tools/mypy.ini @@ -33,6 +33,9 @@ ignore_missing_imports = True [mypy-html5lib.*] ignore_missing_imports = True +[mypy-mod_pywebsocket.*] +ignore_missing_imports = True + [mypy-mozdevice.*] ignore_missing_imports = True @@ -90,7 +93,7 @@ disallow_untyped_defs = False disallow_untyped_defs = False [mypy-tools.serve.*] -ignore_errors = True +disallow_untyped_defs = False [mypy-tools.wave.*] disallow_untyped_defs = False diff --git a/tools/serve/serve.py b/tools/serve/serve.py index 1d70952a8e4e88..2fde7114f6802a 100644 --- a/tools/serve/serve.py +++ b/tools/serve/serve.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import print_function - import abc import argparse import importlib @@ -21,10 +17,11 @@ import uuid from collections import defaultdict, OrderedDict from itertools import chain, product +from typing import ClassVar, List, Set, Tuple -from localpaths import repo_root +from localpaths import repo_root # type: ignore -from manifest.sourcefile import read_script_metadata, js_meta_re, parse_variants +from manifest.sourcefile import read_script_metadata, js_meta_re, parse_variants # type: ignore from wptserve import server as wptserve, handlers from wptserve import stash from wptserve import config @@ -62,7 +59,7 @@ class WrapperHandler(object): __meta__ = abc.ABCMeta - headers = [] + headers = [] # type: ClassVar[List[Tuple[str, str]]] def __init__(self, base_path=None, url_base="/"): self.base_path = base_path @@ -180,7 +177,7 @@ def check_exposure(self, request): class HtmlWrapperHandler(WrapperHandler): - global_type = None + global_type = None # type: ClassVar[str] headers = [('Content-Type', 'text/html')] def check_exposure(self, request): @@ -892,10 +889,10 @@ def iter_procs(servers): yield server.proc -def _make_subdomains_product(s, depth=2): +def _make_subdomains_product(s: Set[str], depth: int = 2) -> Set[str]: return {u".".join(x) for x in chain(*(product(s, repeat=i) for i in range(1, depth+1)))} -def _make_origin_policy_subdomains(limit): +def _make_origin_policy_subdomains(limit: int) -> Set[str]: return {u"op%d" % x for x in range(1,limit+1)} diff --git a/tools/serve/test_functional.py b/tools/serve/test_functional.py index c30ca15a145ede..14ea649be86cac 100644 --- a/tools/serve/test_functional.py +++ b/tools/serve/test_functional.py @@ -25,7 +25,7 @@ def start(self, *args, **kwargs): return result -serve.ServerProc = ServerProcSpy +serve.ServerProc = ServerProcSpy # type: ignore @pytest.fixture() def server_subprocesses(): diff --git a/tools/serve/test_serve.py b/tools/serve/test_serve.py index 0a07db7d099292..5a51376c4892c5 100644 --- a/tools/serve/test_serve.py +++ b/tools/serve/test_serve.py @@ -4,7 +4,7 @@ import pytest -import localpaths +import localpaths # type: ignore from . import serve from .serve import ConfigBuilder diff --git a/tools/serve/wave.py b/tools/serve/wave.py index b13c6ef34de2ab..b9eb8df70abd40 100644 --- a/tools/serve/wave.py +++ b/tools/serve/wave.py @@ -1,4 +1,7 @@ -# -*- coding: utf-8 -*- +# The ./wpt serve-wave command is broken, so mypy errors are ignored instead of +# making untestable changes to the problematic imports. +# See https://github.com/web-platform-tests/wpt/issues/29024. +# mypy: ignore-errors import subprocess from manifest import manifest