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 Jun 11, 2021
1 parent 146f12e commit 85b070c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 4 additions & 1 deletion tools/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ignore_missing_imports = True
[mypy-marionette_driver.*]
ignore_missing_imports = True

[mypy-mod_pywebsocket.*]
ignore_missing_imports = True

[mypy-mozcrash.*]
ignore_missing_imports = True

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

import abc
import argparse
import importlib
Expand All @@ -19,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 @@ -59,7 +58,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 @@ -177,7 +176,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 @@ -860,11 +859,11 @@ def iter_servers(servers):
yield server


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 @@ -5,7 +5,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 85b070c

Please sign in to comment.