Add annotations for modules/__init__.py
This commit is contained in:
		
							parent
							
								
									bcf2a3770d
								
							
						
					
					
						commit
						ca9b4cb596
					
				
					 1 changed files with 12 additions and 9 deletions
				
			
		| 
						 | 
					@ -13,6 +13,9 @@
 | 
				
			||||||
# along with Gajim.  If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with Gajim.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					from typing import List  # noqa
 | 
				
			||||||
 | 
					from typing import Dict  # noqa
 | 
				
			||||||
 | 
					from typing import Any  # noqa
 | 
				
			||||||
from importlib import import_module
 | 
					from importlib import import_module
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
from unittest.mock import MagicMock
 | 
					from unittest.mock import MagicMock
 | 
				
			||||||
| 
						 | 
					@ -21,8 +24,8 @@ log = logging.getLogger('gajim.c.m')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ZEROCONF_MODULES = ['adhoc_commands', 'receipts', 'discovery']
 | 
					ZEROCONF_MODULES = ['adhoc_commands', 'receipts', 'discovery']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
imported_modules = []
 | 
					imported_modules = []  # type: List[tuple]
 | 
				
			||||||
_modules = {}
 | 
					_modules = {}  # type: Dict[str, Dict[str, Any]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for file in Path(__file__).parent.iterdir():
 | 
					for file in Path(__file__).parent.iterdir():
 | 
				
			||||||
    if file.stem == '__init__':
 | 
					    if file.stem == '__init__':
 | 
				
			||||||
| 
						 | 
					@ -40,30 +43,30 @@ for file in Path(__file__).parent.iterdir():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ModuleMock:
 | 
					class ModuleMock:
 | 
				
			||||||
    def __init__(self, name):
 | 
					    def __init__(self, name: str) -> None:
 | 
				
			||||||
        self._name = name
 | 
					        self._name = name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # HTTPUpload, ..
 | 
					        # HTTPUpload, ..
 | 
				
			||||||
        self.available = False
 | 
					        self.available = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Blocking
 | 
					        # Blocking
 | 
				
			||||||
        self.blocked = []
 | 
					        self.blocked = []  # type: List[Any]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Privacy Lists
 | 
					        # Privacy Lists
 | 
				
			||||||
        self.blocked_contacts = []
 | 
					        self.blocked_contacts = []  # type: List[Any]
 | 
				
			||||||
        self.blocked_groups = []
 | 
					        self.blocked_groups = []  # type: List[Any]
 | 
				
			||||||
        self.blocked_all = False
 | 
					        self.blocked_all = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Delimiter
 | 
					        # Delimiter
 | 
				
			||||||
        self.delimiter = '::'
 | 
					        self.delimiter = '::'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Bookmarks
 | 
					        # Bookmarks
 | 
				
			||||||
        self.bookmarks = {}
 | 
					        self.bookmarks = {}  # type: Dict[Any, Any]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Various Modules
 | 
					        # Various Modules
 | 
				
			||||||
        self.supported = False
 | 
					        self.supported = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __getattr__(self, key):
 | 
					    def __getattr__(self, key: str) -> MagicMock:
 | 
				
			||||||
        return MagicMock()
 | 
					        return MagicMock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,7 +104,7 @@ def unregister_single(con, name):
 | 
				
			||||||
    del _modules[con.name][name]
 | 
					    del _modules[con.name][name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get(account, name):
 | 
					def get(account: str, name: str) -> Any:
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        return _modules[account][name]
 | 
					        return _modules[account][name]
 | 
				
			||||||
    except KeyError:
 | 
					    except KeyError:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue