"""This module provides persistent global storage for other modules."""

from collections import defaultdict
import threading

from .util import printf
from .settings import Settings


api_ready = False
kill_switch = True

settings = Settings()

# A mapping between buffer ids and errors,
# Dict[buffer_id, [error]]
errors = defaultdict(list)

# A mapping between linter class names and linter classes
linter_classes = {}

# A mapping between buffer ids and a list of linter instances
view_linters = {}

# Dict[buffer_id, [Popen]]
active_procs = defaultdict(list)
active_procs_lock = threading.Lock()


def debug_mode():
    """Return whether the "debug" setting is True."""
    return settings.get('debug', False)


def debug(*args):
    """Print args to the console if the "debug" setting is True."""
    if debug_mode():
        printf(*args)

@@ -178,16 +178,478 @@
 tings%0A%0A%0A
+if False:%0A    from typing import DefaultDict, Dict, List, Type, Optional%0A    from mypy_extensions import TypedDict%0A    import sublime%0A    import subprocess%0A    from .linter import Linter%0A%0A    LintError = TypedDict('LintError', %7B%0A        'line': int,%0A        'start': int,%0A        'end': int,%0A        'region': sublime.Region,%0A        'linter': str,%0A        'error_type': str,%0A        'code': Optional%5Bstr%5D,%0A        'msg': str,%0A        'panel_line': int%0A    %7D)%0A%0A%0A
 api_read
@@ -797,16 +797,72 @@
 ct(list)
+  # type: DefaultDict%5Bsublime.BufferId, List%5BLintError%5D%5D
 %0A%0A# A ma
@@ -928,24 +928,57 @@
 classes = %7B%7D
+  # type: Dict%5Bstr, Type%5BLinter%5D%5D
 %0A%0A# A mappin
@@ -1046,16 +1046,62 @@
 ers = %7B%7D
+  # type: Dict%5Bsublime.BufferId, List%5BLinter%5D%5D
 %0A%0A# Dict
@@ -1153,16 +1153,79 @@
 ct(list)
+  # type: DefaultDict%5Bsublime.BufferId, List%5Bsubprocess.Popen%5D%5D
 %0Aactive_
@@ -1270,24 +1270,47 @@
 bug_mode():%0A
+    # type: () -%3E bool%0A
     %22%22%22Retur
@@ -1411,16 +1411,42 @@
 *args):%0A
+    # type: (...) -%3E None%0A
     %22%22%22P

Add typing to 'persist.py'