mypy: Upgrade from 0.730 to 0.740.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-11-13 01:06:02 -08:00 committed by Tim Abbott
parent 40f4ead738
commit 0d20145b93
12 changed files with 46 additions and 38 deletions

View File

@ -1122,6 +1122,7 @@ def support(request: HttpRequest) -> HttpResponse:
URLValidator()(key_word)
parse_result = urllib.parse.urlparse(key_word)
hostname = parse_result.hostname
assert hostname is not None
if parse_result.port:
hostname = "{}:{}".format(hostname, parse_result.port)
subdomain = get_subdomain_from_hostname(hostname)
@ -1282,7 +1283,7 @@ def realm_activity_link(realm_str: str) -> mark_safe:
def realm_stats_link(realm_str: str) -> mark_safe:
url_name = 'analytics.views.stats_for_realm'
url = reverse(url_name, kwargs=dict(realm_str=realm_str))
stats_link = '<a href="{}"><i class="fa fa-pie-chart"></i></a>'.format(url, realm_str)
stats_link = '<a href="{}"><i class="fa fa-pie-chart"></i>{}</a>'.format(url, realm_str)
return mark_safe(stats_link)
def remote_installation_stats_link(server_id: int, hostname: str) -> mark_safe:

View File

@ -26,7 +26,7 @@ def run(args, dry_run=False):
stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode:
logger.error("Could not invoke %s\nstdout: %s\nstderror: %s"
logger.error("Could not invoke %s\nstdout: %r\nstderror: %r"
% (args[0], stdout, stderr))
sys.exit(1)
return stdout.decode()

View File

@ -485,18 +485,21 @@ mypy-extensions==0.4.3 \
--hash=sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d \
--hash=sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8 \
# via mypy
mypy==0.730 \
--hash=sha256:1d98fd818ad3128a5408148c9e4a5edce6ed6b58cc314283e631dd5d9216527b \
--hash=sha256:22ee018e8fc212fe601aba65d3699689dd29a26410ef0d2cc1943de7bec7e3ac \
--hash=sha256:3a24f80776edc706ec8d05329e854d5b9e464cd332e25cde10c8da2da0a0db6c \
--hash=sha256:42a78944e80770f21609f504ca6c8173f7768043205b5ac51c9144e057dcf879 \
--hash=sha256:4b2b20106973548975f0c0b1112eceb4d77ed0cafe0a231a1318f3b3a22fc795 \
--hash=sha256:591a9625b4d285f3ba69f541c84c0ad9e7bffa7794da3fa0585ef13cf95cb021 \
--hash=sha256:5b4b70da3d8bae73b908a90bb2c387b977e59d484d22c604a2131f6f4397c1a3 \
--hash=sha256:84edda1ffeda0941b2ab38ecf49302326df79947fa33d98cdcfbf8ca9cf0bb23 \
--hash=sha256:b2b83d29babd61b876ae375786960a5374bba0e4aba3c293328ca6ca5dc448dd \
--hash=sha256:cc4502f84c37223a1a5ab700649b5ab1b5e4d2bf2d426907161f20672a21930b \
--hash=sha256:e29e24dd6e7f39f200a5bb55dcaa645d38a397dd5a6674f6042ef02df5795046
mypy==0.740 \
--hash=sha256:1521c186a3d200c399bd5573c828ea2db1362af7209b2adb1bb8532cea2fb36f \
--hash=sha256:31a046ab040a84a0fc38bc93694876398e62bc9f35eca8ccbf6418b7297f4c00 \
--hash=sha256:3b1a411909c84b2ae9b8283b58b48541654b918e8513c20a400bb946aa9111ae \
--hash=sha256:48c8bc99380575deb39f5d3400ebb6a8a1cb5cc669bbba4d3bb30f904e0a0e7d \
--hash=sha256:540c9caa57a22d0d5d3c69047cc9dd0094d49782603eb03069821b41f9e970e9 \
--hash=sha256:672e418425d957e276c291930a3921b4a6413204f53fe7c37cad7bc57b9a3391 \
--hash=sha256:6ed3b9b3fdc7193ea7aca6f3c20549b377a56f28769783a8f27191903a54170f \
--hash=sha256:9371290aa2cad5ad133e4cdc43892778efd13293406f7340b9ffe99d5ec7c1d9 \
--hash=sha256:ace6ac1d0f87d4072f05b5468a084a45b4eda970e4d26704f201e06d47ab2990 \
--hash=sha256:b428f883d2b3fe1d052c630642cc6afddd07d5cd7873da948644508be3b9d4a7 \
--hash=sha256:d5bf0e6ec8ba346a2cf35cb55bf4adfddbc6b6576fcc9e10863daa523e418dbb \
--hash=sha256:d7574e283f83c08501607586b3167728c58e8442947e027d2d4c7dcd6d82f453 \
--hash=sha256:dc889c84241a857c263a2b1cd1121507db7d5b5f5e87e77147097230f374d10b \
--hash=sha256:f4748697b349f373002656bf32fede706a0e713d67bfdcf04edf39b1f61d46eb
oauthlib==3.1.0 \
--hash=sha256:bee41cc35fcca6e988463cacc3bcb8a96224f470ca547e697b604cc697b2f889 \
--hash=sha256:df884cd6cbe20e32633f1db1072e9356f53638e4361bef4e8b03c9127c9328ea \

View File

@ -2,4 +2,4 @@
# /tools/update-locked-requirements to update requirements/dev.txt
# and requirements/mypy.txt.
# See requirements/README.md for more detail.
mypy==0.730
mypy

View File

@ -11,18 +11,21 @@ mypy-extensions==0.4.3 \
--hash=sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d \
--hash=sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8 \
# via mypy
mypy==0.730 \
--hash=sha256:1d98fd818ad3128a5408148c9e4a5edce6ed6b58cc314283e631dd5d9216527b \
--hash=sha256:22ee018e8fc212fe601aba65d3699689dd29a26410ef0d2cc1943de7bec7e3ac \
--hash=sha256:3a24f80776edc706ec8d05329e854d5b9e464cd332e25cde10c8da2da0a0db6c \
--hash=sha256:42a78944e80770f21609f504ca6c8173f7768043205b5ac51c9144e057dcf879 \
--hash=sha256:4b2b20106973548975f0c0b1112eceb4d77ed0cafe0a231a1318f3b3a22fc795 \
--hash=sha256:591a9625b4d285f3ba69f541c84c0ad9e7bffa7794da3fa0585ef13cf95cb021 \
--hash=sha256:5b4b70da3d8bae73b908a90bb2c387b977e59d484d22c604a2131f6f4397c1a3 \
--hash=sha256:84edda1ffeda0941b2ab38ecf49302326df79947fa33d98cdcfbf8ca9cf0bb23 \
--hash=sha256:b2b83d29babd61b876ae375786960a5374bba0e4aba3c293328ca6ca5dc448dd \
--hash=sha256:cc4502f84c37223a1a5ab700649b5ab1b5e4d2bf2d426907161f20672a21930b \
--hash=sha256:e29e24dd6e7f39f200a5bb55dcaa645d38a397dd5a6674f6042ef02df5795046
mypy==0.740 \
--hash=sha256:1521c186a3d200c399bd5573c828ea2db1362af7209b2adb1bb8532cea2fb36f \
--hash=sha256:31a046ab040a84a0fc38bc93694876398e62bc9f35eca8ccbf6418b7297f4c00 \
--hash=sha256:3b1a411909c84b2ae9b8283b58b48541654b918e8513c20a400bb946aa9111ae \
--hash=sha256:48c8bc99380575deb39f5d3400ebb6a8a1cb5cc669bbba4d3bb30f904e0a0e7d \
--hash=sha256:540c9caa57a22d0d5d3c69047cc9dd0094d49782603eb03069821b41f9e970e9 \
--hash=sha256:672e418425d957e276c291930a3921b4a6413204f53fe7c37cad7bc57b9a3391 \
--hash=sha256:6ed3b9b3fdc7193ea7aca6f3c20549b377a56f28769783a8f27191903a54170f \
--hash=sha256:9371290aa2cad5ad133e4cdc43892778efd13293406f7340b9ffe99d5ec7c1d9 \
--hash=sha256:ace6ac1d0f87d4072f05b5468a084a45b4eda970e4d26704f201e06d47ab2990 \
--hash=sha256:b428f883d2b3fe1d052c630642cc6afddd07d5cd7873da948644508be3b9d4a7 \
--hash=sha256:d5bf0e6ec8ba346a2cf35cb55bf4adfddbc6b6576fcc9e10863daa523e418dbb \
--hash=sha256:d7574e283f83c08501607586b3167728c58e8442947e027d2d4c7dcd6d82f453 \
--hash=sha256:dc889c84241a857c263a2b1cd1121507db7d5b5f5e87e77147097230f374d10b \
--hash=sha256:f4748697b349f373002656bf32fede706a0e713d67bfdcf04edf39b1f61d46eb
typed-ast==1.4.0 \
--hash=sha256:1170afa46a3799e18b4c977777ce137bb53c7485379d9706af8a59f2ea1aa161 \
--hash=sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e \

View File

@ -44,7 +44,7 @@ def overwrite_symlink(src, dst):
while True:
tmp = tempfile.mktemp(
prefix='.' + os.path.basename(dst) + '.',
dir=os.path.dirname(dst))
dir=os.path.dirname(dst)) # type: ignore # https://github.com/python/typeshed/issues/3449
try:
os.symlink(src, tmp)
except FileExistsError:

View File

@ -12,6 +12,7 @@ import scripts.lib.setup_path_on_import
from zproject import settings
url = urlsplit("//" + settings.MEMCACHED_LOCATION)
assert url.port is not None
print("Flushing memcached...")
with socket.create_connection((url.hostname, url.port)) as f:

View File

@ -212,7 +212,7 @@ def notify_bot_owner(event: Dict[str, Any],
notification_message += "\nThe webhook got a response with status code *%s*." % (status_code,)
if response_content:
notification_message += "\nThe response contains the following payload:\n" \
"```\n%s\n```" % (response_content,)
"```\n%s\n```" % (str(response_content),)
if exception:
notification_message += "\nWhen trying to send a request to the webhook service, an exception " \
"of type %s occurred:\n```\n%s\n```" % (

View File

@ -181,8 +181,8 @@ class DecoratorTestCase(TestCase):
def test_REQ_converter_and_validator_invalid(self) -> None:
with self.assertRaisesRegex(AssertionError, "converter and validator are mutually exclusive"):
@has_request_variables
def get_total(request: HttpRequest, # type: ignore # The condition being tested is in fact an error.
numbers: Iterable[int]=REQ(validator=check_list(check_int),
def get_total(request: HttpRequest,
numbers: Iterable[int]=REQ(validator=check_list(check_int), # type: ignore # The condition being tested is in fact an error.
converter=lambda x: [])) -> int:
return sum(numbers) # nocoverage -- isn't intended to be run
@ -263,8 +263,8 @@ class DecoratorTestCase(TestCase):
# Test we properly handle an invalid argument_type.
with self.assertRaises(Exception) as cm:
@has_request_variables
def test(request: HttpRequest, # type: ignore # The condition being tested is in fact an error.
payload: Any=REQ(argument_type="invalid")) -> None:
def test(request: HttpRequest,
payload: Any=REQ(argument_type="invalid")) -> None: # type: ignore # The condition being tested is in fact an error.
# Any is ok; exception should occur in decorator:
pass # nocoverage # this function isn't meant to be called
test(request)

View File

@ -181,18 +181,18 @@ class TornadoTestCase(WebSocketBaseTestCase):
return view_func(request, user_profile)
@staticmethod
def get_cookie_header(cookies: SimpleCookie) -> str:
def get_cookie_header(cookies: "SimpleCookie[str]") -> str:
return ';'.join(
["{}={}".format(name, value.value) for name, value in cookies.items()])
def _get_cookies(self, user_profile: UserProfile) -> SimpleCookie:
def _get_cookies(self, user_profile: UserProfile) -> "SimpleCookie[str]":
resp = self.login_with_return(user_profile.email)
return resp.cookies
@gen.coroutine
def _websocket_auth(self, ws: Any,
queue_events_data: Dict[str, Dict[str, str]],
cookies: SimpleCookie) -> Generator[str, str, None]:
cookies: "SimpleCookie[str]") -> Generator[str, str, None]:
auth_queue_id = ':'.join((queue_events_data['response']['queue_id'], '0'))
message = {
"req_id": auth_queue_id,

View File

@ -164,7 +164,7 @@ class AsyncDjangoHandlerBase(tornado.web.RequestHandler, base.BaseHandler): # n
self.set_header(h[0], h[1])
if not hasattr(self, "_new_cookies"):
self._new_cookies = [] # type: List[http.cookie.SimpleCookie]
self._new_cookies = [] # type: List[http.cookie.SimpleCookie[str]]
self._new_cookies.append(response.cookies)
self.write(response.content)

View File

@ -60,7 +60,7 @@ class WebsocketClient:
@gen.coroutine
def _websocket_auth(self, queue_events_data: Dict[str, Dict[str, str]],
cookies: SimpleCookie) -> Generator[str, str, None]:
cookies: "SimpleCookie[str]") -> Generator[str, str, None]:
message = {
"req_id": self._get_request_id(),
"type": "auth",