Skip to content

Commit

Permalink
Run mypy for tools/serve/ (but still allow untyped defs)
Browse files Browse the repository at this point in the history
Part of #28833.
  • Loading branch information
foolip committed May 18, 2021
1 parent dd606b4 commit 349eb96
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
5 changes: 4 additions & 1 deletion tools/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-

from __future__ import print_function

import abc
import argparse
import importlib
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)}


Expand Down
2 changes: 1 addition & 1 deletion tools/serve/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def start(self, *args, **kwargs):

return result

serve.ServerProc = ServerProcSpy
serve.ServerProc = ServerProcSpy # type: ignore

@pytest.fixture()
def server_subprocesses():
Expand Down
2 changes: 1 addition & 1 deletion tools/serve/test_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

import localpaths
import localpaths # type: ignore
from . import serve
from .serve import ConfigBuilder

Expand Down
5 changes: 4 additions & 1 deletion tools/serve/wave.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 349eb96

Please sign in to comment.