pyupgrade: Replace Text
with str
.
We uses `pyupgrade --py3-plus` to automatically replace all occurence of `Text`. But manual fix is required to remove the unused imports. Note that with this configuration pyupgrade also convert string literals to .format(...) style, which is manually not included in the commit as well.
This commit is contained in:
parent
a54cccc012
commit
e27ac0ddbe
11 changed files with 42 additions and 46 deletions
|
@ -13,7 +13,6 @@ import os
|
|||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Text
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
import zulip_git_config as config
|
||||
|
@ -33,7 +32,7 @@ client = zulip.Client(
|
|||
)
|
||||
|
||||
|
||||
def git_repository_name() -> Text:
|
||||
def git_repository_name() -> str:
|
||||
output = subprocess.check_output(["git", "rev-parse", "--is-bare-repository"])
|
||||
if output.strip() == "true":
|
||||
return os.path.basename(os.getcwd())[: -len(".git")]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
from typing import Dict, Optional, Text
|
||||
from typing import Dict, Optional
|
||||
|
||||
# Name of the stream to send notifications to, default is "commits"
|
||||
STREAM_NAME = "commits"
|
||||
|
@ -23,7 +23,7 @@ ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
|||
# * stream "commits"
|
||||
# * topic "master"
|
||||
# And similarly for branch "test-post-receive" (for use when testing).
|
||||
def commit_notice_destination(repo: Text, branch: Text, commit: Text) -> Optional[Dict[Text, Text]]:
|
||||
def commit_notice_destination(repo: str, branch: str, commit: str) -> Optional[Dict[str, str]]:
|
||||
if branch in ["master", "test-post-receive"]:
|
||||
return dict(stream=STREAM_NAME, subject="%s" % (branch,))
|
||||
|
||||
|
@ -36,7 +36,7 @@ def commit_notice_destination(repo: Text, branch: Text, commit: Text) -> Optiona
|
|||
# graphical repository viewer, e.g.
|
||||
#
|
||||
# return '!avatar(%s) [%s](https://example.com/commits/%s)\n' % (author, subject, commit_id)
|
||||
def format_commit_message(author: Text, subject: Text, commit_id: Text) -> Text:
|
||||
def format_commit_message(author: str, subject: str, commit_id: str) -> str:
|
||||
return "!avatar(%s) %s\n" % (author, subject)
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# `hg push`). See https://zulip.com/integrations for installation instructions.
|
||||
|
||||
import sys
|
||||
from typing import Text
|
||||
|
||||
from mercurial import repository as repo
|
||||
from mercurial import ui
|
||||
|
@ -17,8 +16,8 @@ VERSION = "0.9"
|
|||
|
||||
|
||||
def format_summary_line(
|
||||
web_url: str, user: str, base: int, tip: int, branch: str, node: Text
|
||||
) -> Text:
|
||||
web_url: str, user: str, base: int, tip: int, branch: str, node: str
|
||||
) -> str:
|
||||
"""
|
||||
Format the first line of the message, which contains summary
|
||||
information about the changeset and links to the changelog if a
|
||||
|
@ -71,7 +70,7 @@ def format_commit_lines(web_url: str, repo: repo, base: int, tip: int) -> str:
|
|||
|
||||
|
||||
def send_zulip(
|
||||
email: str, api_key: str, site: str, stream: str, subject: str, content: Text
|
||||
email: str, api_key: str, site: str, stream: str, subject: str, content: str
|
||||
) -> None:
|
||||
"""
|
||||
Send a message to Zulip using the provided credentials, which should be for
|
||||
|
@ -100,7 +99,7 @@ def get_config(ui: ui, item: str) -> str:
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def hook(ui: ui, repo: repo, **kwargs: Text) -> None:
|
||||
def hook(ui: ui, repo: repo, **kwargs: str) -> None:
|
||||
"""
|
||||
Invoked by configuring a [hook] entry in .hg/hgrc.
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# https://github.com/python/mypy/issues/1141
|
||||
from typing import Dict, Optional, Text
|
||||
from typing import Dict, Optional
|
||||
|
||||
# Change these values to configure authentication for the plugin
|
||||
ZULIP_USER = "openshift-bot@example.com"
|
||||
|
@ -19,7 +19,7 @@ ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
|||
# * stream "deployments"
|
||||
# * topic "master"
|
||||
# And similarly for branch "test-post-receive" (for use when testing).
|
||||
def deployment_notice_destination(branch: str) -> Optional[Dict[str, Text]]:
|
||||
def deployment_notice_destination(branch: str) -> Optional[Dict[str, str]]:
|
||||
if branch in ["master", "test-post-receive"]:
|
||||
return dict(stream="deployments", subject="%s" % (branch,))
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Dict, Optional, Text
|
||||
from typing import Dict, Optional
|
||||
|
||||
# Change these values to configure authentication for the plugin
|
||||
ZULIP_USER = "p4-bot@example.com"
|
||||
|
@ -28,7 +28,7 @@ P4_WEB: Optional[str] = None
|
|||
# "master-plan" and "secret" subdirectories of //depot/ to:
|
||||
# * stream "depot_subdirectory-commits"
|
||||
# * subject "change_root"
|
||||
def commit_notice_destination(path: Text, changelist: int) -> Optional[Dict[Text, Text]]:
|
||||
def commit_notice_destination(path: str, changelist: int) -> Optional[Dict[str, str]]:
|
||||
dirs = path.split("/")
|
||||
if len(dirs) >= 4 and dirs[3] not in ("*", "..."):
|
||||
directory = dirs[3]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Dict, Optional, Text
|
||||
from typing import Dict, Optional
|
||||
|
||||
# Change these values to configure authentication for the plugin
|
||||
ZULIP_USER = "svn-bot@example.com"
|
||||
|
@ -18,7 +18,7 @@ ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
|||
# and "my-super-secret-repository" repos to
|
||||
# * stream "commits"
|
||||
# * topic "branch_name"
|
||||
def commit_notice_destination(path: Text, commit: Text) -> Optional[Dict[Text, Text]]:
|
||||
def commit_notice_destination(path: str, commit: str) -> Optional[Dict[str, str]]:
|
||||
repo = path.split("/")[-1]
|
||||
if repo not in ["evil-master-plan", "my-super-secret-repository"]:
|
||||
return dict(stream="commits", subject="%s" % (repo,))
|
||||
|
|
|
@ -22,7 +22,6 @@ from typing import (
|
|||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Text,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
@ -313,7 +312,7 @@ def get_default_config_filename() -> Optional[str]:
|
|||
return config_file
|
||||
|
||||
|
||||
def validate_boolean_field(field: Optional[Text]) -> Union[bool, None]:
|
||||
def validate_boolean_field(field: Optional[str]) -> Union[bool, None]:
|
||||
if not isinstance(field, str):
|
||||
return None
|
||||
|
||||
|
@ -563,7 +562,7 @@ class Client:
|
|||
req_files = []
|
||||
|
||||
for (key, val) in orig_request.items():
|
||||
if isinstance(val, str) or isinstance(val, Text):
|
||||
if isinstance(val, str) or isinstance(val, str):
|
||||
request[key] = val
|
||||
else:
|
||||
request[key] = json.dumps(val)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue