typing: Convert function type annotations to Python 3 style.
Generated by com2ann (slightly patched to avoid also converting assignment type annotations, which require Python 3.6), followed by some manual whitespace adjustment, and two fixes for use-before-define issues: - def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None: + def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None: -def init_from_options(options: Any, client: Optional[str] = None) -> Client: +def init_from_options(options: Any, client: Optional[str] = None) -> 'Client': Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
7c5f73dce9
commit
5428c5f296
42 changed files with 311 additions and 577 deletions
|
@ -50,8 +50,7 @@ while len(json_implementations):
|
|||
except ImportError:
|
||||
continue
|
||||
|
||||
def make_api_call(path):
|
||||
# type: (str) -> Optional[List[Dict[str, Any]]]
|
||||
def make_api_call(path: str) -> Optional[List[Dict[str, Any]]]:
|
||||
response = requests.get("https://api3.codebasehq.com/%s" % (path,),
|
||||
auth=(config.CODEBASE_API_USERNAME, config.CODEBASE_API_KEY),
|
||||
params={'raw': 'True'},
|
||||
|
@ -71,12 +70,10 @@ def make_api_call(path):
|
|||
logging.warn("Found non-success response status code: %s %s" % (response.status_code, response.text))
|
||||
return None
|
||||
|
||||
def make_url(path):
|
||||
# type: (str) -> str
|
||||
def make_url(path: str) -> str:
|
||||
return "%s/%s" % (config.CODEBASE_ROOT_URL, path)
|
||||
|
||||
def handle_event(event):
|
||||
# type: (Dict[str, Any]) -> None
|
||||
def handle_event(event: Dict[str, Any]) -> None:
|
||||
event = event['event']
|
||||
event_type = event['type']
|
||||
actor_name = event['actor_name']
|
||||
|
@ -240,12 +237,10 @@ def handle_event(event):
|
|||
|
||||
|
||||
# the main run loop for this mirror script
|
||||
def run_mirror():
|
||||
# type: () -> None
|
||||
def run_mirror() -> None:
|
||||
# we should have the right (write) permissions on the resume file, as seen
|
||||
# in check_permissions, but it may still be empty or corrupted
|
||||
def default_since():
|
||||
# type: () -> datetime
|
||||
def default_since() -> datetime:
|
||||
return datetime.now(tz=pytz.utc) - timedelta(hours=config.CODEBASE_INITIAL_HISTORY_HOURS)
|
||||
|
||||
try:
|
||||
|
@ -282,8 +277,7 @@ def run_mirror():
|
|||
logging.info("Shutting down Codebase mirror")
|
||||
|
||||
# void function that checks the permissions of the files this script needs.
|
||||
def check_permissions():
|
||||
# type: () -> None
|
||||
def check_permissions() -> None:
|
||||
# check that the log file can be written
|
||||
if config.LOG_FILE:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue