Replace typing.Text with str.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-08-24 19:50:05 -07:00
parent 189cf48573
commit 626359596e
4 changed files with 12 additions and 12 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
from typing import Any, Dict, Text from typing import Any, Dict
import zulip import zulip
@ -30,7 +30,7 @@ msg = dict(type="stream", to=opts.stream) # type: Dict[str, Any]
# We send PROBLEM and RECOVERY messages to the same subject. # We send PROBLEM and RECOVERY messages to the same subject.
if opts.service is None: if opts.service is None:
# Host notification # Host notification
thing = "host" # type: Text thing = "host"
msg["subject"] = f"host {opts.host}" msg["subject"] = f"host {opts.host}"
else: else:
# Service notification # Service notification
@ -45,7 +45,7 @@ msg["content"] = f"**{opts.type}**: {thing} is {opts.state}"
# The "long output" can contain newlines represented by "\n" escape sequences. # The "long output" can contain newlines represented by "\n" escape sequences.
# The Nagios mail command uses /usr/bin/printf "%b" to expand these. # The Nagios mail command uses /usr/bin/printf "%b" to expand these.
# We will be more conservative and handle just this one escape sequence. # We will be more conservative and handle just this one escape sequence.
output = (opts.output + "\n" + opts.long_output.replace(r"\n", "\n")).strip() # type: Text output = (opts.output + "\n" + opts.long_output.replace(r"\n", "\n")).strip()
if output: if output:
# Put any command output in a code block. # Put any command output in a code block.
msg["content"] += "\n\n~~~~\n" + output + "\n~~~~\n" msg["content"] += "\n\n~~~~\n" + output + "\n~~~~\n"

View file

@ -12,7 +12,7 @@
import os import os
import os.path import os.path
import sys import sys
from typing import Any, Dict, Optional, Text, Tuple from typing import Any, Dict
import pysvn import pysvn
@ -34,19 +34,19 @@ client = zulip.Client(
) # type: zulip.Client ) # type: zulip.Client
svn = pysvn.Client() # type: pysvn.Client svn = pysvn.Client() # type: pysvn.Client
path, rev = sys.argv[1:] # type: Tuple[Text, Text] path, rev = sys.argv[1:]
# since its a local path, prepend "file://" # since its a local path, prepend "file://"
path = "file://" + path path = "file://" + path
entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[ entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[
0 0
] # type: Dict[Text, Any] ] # type: Dict[str, Any]
message = "**{}** committed revision r{} to `{}`.\n\n> {}".format( message = "**{}** committed revision r{} to `{}`.\n\n> {}".format(
entry["author"], rev, path.split("/")[-1], entry["revprops"]["svn:log"] entry["author"], rev, path.split("/")[-1], entry["revprops"]["svn:log"]
) # type: Text )
destination = config.commit_notice_destination(path, rev) # type: Optional[Dict[Text, Text]] destination = config.commit_notice_destination(path, rev)
if destination is not None: if destination is not None:
message_data = { message_data = {

View file

@ -1,4 +1,4 @@
import pkgutil import pkgutil
from typing import Iterable, Text from typing import Iterable
__path__ = pkgutil.extend_path(__path__, __name__) # type: Iterable[Text] __path__ = pkgutil.extend_path(__path__, __name__) # type: Iterable[str]

View file

@ -1,4 +1,4 @@
import pkgutil import pkgutil
from typing import Iterable, Text from typing import Iterable
__path__ = pkgutil.extend_path(__path__, __name__) # type: Iterable[Text] __path__ = pkgutil.extend_path(__path__, __name__) # type: Iterable[str]