mypy: Amend code & typing of integrations, to pass with strict-optional.
This commit is contained in:
parent
08bfe9d8c7
commit
33ccc04a32
|
@ -286,10 +286,10 @@ def run_mirror():
|
||||||
try:
|
try:
|
||||||
sleepInterval = 1
|
sleepInterval = 1
|
||||||
while True:
|
while True:
|
||||||
events = make_api_call("activity")[::-1]
|
events = make_api_call("activity")
|
||||||
if events is not None:
|
if events is not None:
|
||||||
sleepInterval = 1
|
sleepInterval = 1
|
||||||
for event in events:
|
for event in events[::-1]:
|
||||||
timestamp = event.get('event', {}).get('timestamp', '')
|
timestamp = event.get('event', {}).get('timestamp', '')
|
||||||
event_date = dateutil.parser.parse(timestamp)
|
event_date = dateutil.parser.parse(timestamp)
|
||||||
if event_date > since:
|
if event_date > since:
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
from typing import Dict, Text
|
from typing import Dict, Text, Optional
|
||||||
|
|
||||||
# Change these values to configure authentication for the plugin
|
# Change these values to configure authentication for the plugin
|
||||||
ZULIP_USER = "git-bot@example.com"
|
ZULIP_USER = "git-bot@example.com"
|
||||||
|
@ -42,7 +42,7 @@ ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
||||||
# * topic "master"
|
# * topic "master"
|
||||||
# And similarly for branch "test-post-receive" (for use when testing).
|
# And similarly for branch "test-post-receive" (for use when testing).
|
||||||
def commit_notice_destination(repo, branch, commit):
|
def commit_notice_destination(repo, branch, commit):
|
||||||
# type: (Text, Text, Text) -> Dict[Text, Text]
|
# type: (Text, Text, Text) -> Optional[Dict[Text, Text]]
|
||||||
if branch in ["master", "test-post-receive"]:
|
if branch in ["master", "test-post-receive"]:
|
||||||
return dict(stream = "commits",
|
return dict(stream = "commits",
|
||||||
subject = u"%s" % (branch,))
|
subject = u"%s" % (branch,))
|
||||||
|
|
|
@ -8,9 +8,11 @@ from oauth2client import client
|
||||||
from oauth2client import tools
|
from oauth2client import tools
|
||||||
from oauth2client.file import Storage
|
from oauth2client.file import Storage
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import argparse
|
import argparse
|
||||||
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
|
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() # type: Optional[argparse.Namespace]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
flags = None
|
flags = None
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
# https://github.com/python/mypy/issues/1141
|
# https://github.com/python/mypy/issues/1141
|
||||||
from typing import Dict, Text
|
from typing import Dict, Text, Optional
|
||||||
|
|
||||||
# Change these values to configure authentication for the plugin
|
# Change these values to configure authentication for the plugin
|
||||||
ZULIP_USER = 'openshift-bot@example.com'
|
ZULIP_USER = 'openshift-bot@example.com'
|
||||||
|
@ -42,7 +42,7 @@ ZULIP_API_KEY = '0123456789abcdef0123456789abcdef'
|
||||||
# * topic "master"
|
# * topic "master"
|
||||||
# And similarly for branch "test-post-receive" (for use when testing).
|
# And similarly for branch "test-post-receive" (for use when testing).
|
||||||
def deployment_notice_destination(branch):
|
def deployment_notice_destination(branch):
|
||||||
# type: (str) -> Dict[str, Text]
|
# type: (str) -> Optional[Dict[str, Text]]
|
||||||
if branch in ['master', 'test-post-receive']:
|
if branch in ['master', 'test-post-receive']:
|
||||||
return dict(stream = 'deployments',
|
return dict(stream = 'deployments',
|
||||||
subject = u'%s' % (branch,))
|
subject = u'%s' % (branch,))
|
||||||
|
@ -69,7 +69,7 @@ def format_deployment_message(
|
||||||
|
|
||||||
## If properly installed, the Zulip API should be in your import
|
## If properly installed, the Zulip API should be in your import
|
||||||
## path, but if not, set a custom path below
|
## path, but if not, set a custom path below
|
||||||
ZULIP_API_PATH = None # type: str
|
ZULIP_API_PATH = None # type: Optional[str]
|
||||||
|
|
||||||
# Set this to your Zulip server's API URI
|
# Set this to your Zulip server's API URI
|
||||||
ZULIP_SITE = 'https://zulip.example.com'
|
ZULIP_SITE = 'https://zulip.example.com'
|
||||||
|
|
|
@ -11,10 +11,10 @@ import unicodedata
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
|
||||||
import zulip
|
import zulip
|
||||||
|
|
||||||
from typing import Set
|
from typing import Set, Optional
|
||||||
|
|
||||||
def fetch_public_streams():
|
def fetch_public_streams():
|
||||||
# type: () -> Set[bytes]
|
# type: () -> Optional[Set[bytes]]
|
||||||
public_streams = set()
|
public_streams = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from typing import IO, Any, Dict, List, Text, Union, Set, Tuple
|
from typing import IO, Any, Dict, List, Text, Union, Set, Tuple, Optional
|
||||||
from types import FrameType
|
from types import FrameType
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -309,7 +309,7 @@ def parse_zephyr_body(zephyr_data, notice_format):
|
||||||
return (zsig, body)
|
return (zsig, body)
|
||||||
|
|
||||||
def parse_crypt_table(zephyr_class, instance):
|
def parse_crypt_table(zephyr_class, instance):
|
||||||
# type: (Text, str) -> str
|
# type: (Text, str) -> Optional[str]
|
||||||
try:
|
try:
|
||||||
crypt_table = open(os.path.join(os.environ["HOME"], ".crypt-table"))
|
crypt_table = open(os.path.join(os.environ["HOME"], ".crypt-table"))
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -604,7 +604,7 @@ def send_unauthed_zephyr(zwrite_args, content):
|
||||||
return send_zephyr(zwrite_args + ["-d"], content)
|
return send_zephyr(zwrite_args + ["-d"], content)
|
||||||
|
|
||||||
def zcrypt_encrypt_content(zephyr_class, instance, content):
|
def zcrypt_encrypt_content(zephyr_class, instance, content):
|
||||||
# type: (str, str, str) -> str
|
# type: (str, str, str) -> Optional[str]
|
||||||
keypath = parse_crypt_table(zephyr_class, instance)
|
keypath = parse_crypt_table(zephyr_class, instance)
|
||||||
if keypath is None:
|
if keypath is None:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue