Changeset - 05406c312342
[Not reviewed]
default
0 5 0
Mads Kiilerich (mads) - 5 years ago 2021-01-14 21:44:53
mads@kiilerich.com
Grafted from: 060202bcf691
pytype: add Python type annotations where necessary to guide pytype

Mute pytype warnings:

File "kallithea/lib/auth.py", line 142, in _cached_perms_data: No attribute 'DEFAULT_USER_ID' on module 'kallithea' [module-attr]
File "kallithea/lib/vcs/backends/base.py", line 73, in ...: No attribute '...' on BaseRepository [attribute-error]
File "kallithea/lib/vcs/backends/base.py", line 405, in ...: No attribute '...' on BaseChangeset [attribute-error]
File "kallithea/tests/api/api_base.py", line 2397, in test_api_get_changeset: No attribute 'TEST_REVISION' on _BaseTestApi [attribute-error]
File "kallithea/tests/api/api_base.py", line 2445, in test_api_get_pullrequest: No attribute 'TEST_PR_DST' on _BaseTestApi [attribute-error]
File "kallithea/tests/api/api_base.py", line 2445, in test_api_get_pullrequest: No attribute 'TEST_PR_SRC' on _BaseTestApi [attribute-error]
File "kallithea/tests/api/api_base.py", line 2467, in test_api_get_pullrequest: No attribute 'TEST_PR_REVISIONS' on _BaseTestApi [attribute-error]
File "kallithea/tests/api/api_base.py", line 67, in api_call: No attribute 'app' on _BaseTestApi [attribute-error]
File "kallithea/tests/base.py", line 154, in log_user: No attribute 'app' on TestController [attribute-error]
File "kallithea/tests/base.py", line 169, in _get_logged_user: No attribute '_logged_username' on TestController [attribute-error]
5 files changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -41,12 +41,13 @@ BACKENDS = {
 
    'hg': 'Mercurial repository',
 
    'git': 'Git repository',
 
}
 

	
 
CELERY_APP = celery.Celery()  # needed at import time but is lazy and can be configured later
 

	
 
DEFAULT_USER_ID: int  # set by setup_configuration
 
CONFIG = {}  # set to tg.config when TG app is initialized and calls app_cfg
 

	
 
# URL prefix for non repository related links - must start with `/`
 
ADMIN_PREFIX = '/_admin'
 
URL_SEP = '/'
 

	
kallithea/lib/vcs/backends/base.py
Show inline comments
 
@@ -8,12 +8,13 @@
 
    :created_on: Apr 8, 2010
 
    :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
 
"""
 

	
 
import datetime
 
import itertools
 
from typing import Sequence
 

	
 
from kallithea.lib.vcs.backends import get_backend
 
from kallithea.lib.vcs.conf import settings
 
from kallithea.lib.vcs.exceptions import (ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError,
 
                                          NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError, RepositoryError)
 
from kallithea.lib.vcs.utils import author_email, author_name
 
@@ -48,14 +49,18 @@ class BaseRepository(object):
 
        ``branches``
 
            branches as list of changesets
 

	
 
        ``tags``
 
            tags as list of changesets
 
    """
 
    scm = None
 
    DEFAULT_BRANCH_NAME = None
 
    DEFAULT_BRANCH_NAME: str  # assigned in subclass
 
    scm: str  # assigned in subclass
 
    path: str  # assigned in subclass __init__
 
    revisions: Sequence[str]  # LazyProperty in subclass
 
    _empty: bool  # property in subclass
 

	
 
    EMPTY_CHANGESET = '0' * 40
 

	
 
    def __init__(self, repo_path, create=False, **kwargs):
 
        """
 
        Initializes repository. Raises RepositoryError if repository could
 
        not be find at the given ``repo_path`` or directory at ``repo_path``
 
@@ -364,12 +369,15 @@ class BaseChangeset(object):
 

	
 
        ``last``
 
            ``True`` if this is last changeset in repository, ``False``
 
            otherwise; trying to access this attribute while there is no
 
            changesets would raise ``EmptyRepositoryError``
 
    """
 
    message: str  # LazyProperty in subclass
 
    date: datetime.datetime  # LazyProperty in subclass
 

	
 
    def __str__(self):
 
        return '<%s at %s:%s>' % (self.__class__.__name__, self.revision,
 
            self.short_id)
 

	
 
    def __repr__(self):
 
        return self.__str__()
kallithea/tests/api/api_base.py
Show inline comments
 
@@ -17,15 +17,17 @@ Tests for the JSON-RPC web api.
 
"""
 

	
 
import os
 
import random
 
import re
 
import string
 
from typing import Sized
 

	
 
import mock
 
import pytest
 
from webtest import TestApp
 

	
 
from kallithea.lib import ext_json
 
from kallithea.lib.auth import AuthUser
 
from kallithea.lib.utils2 import ascii_bytes
 
from kallithea.model import db, meta
 
from kallithea.model.changeset_status import ChangesetStatusModel
 
@@ -83,14 +85,20 @@ def make_repo_group(name=TEST_REPO_GROUP
 
    gr = fixture.create_repo_group(name, cur_user=base.TEST_USER_ADMIN_LOGIN)
 
    meta.Session().commit()
 
    return gr
 

	
 

	
 
class _BaseTestApi(object):
 
    REPO = None
 
    REPO_TYPE = None
 
    app: TestApp  # assigned by app_fixture in subclass TestController mixin
 
    # assigned in subclass:
 
    REPO: str
 
    REPO_TYPE: str
 
    TEST_REVISION: str
 
    TEST_PR_SRC: str
 
    TEST_PR_DST: str
 
    TEST_PR_REVISIONS: Sized
 

	
 
    @classmethod
 
    def setup_class(cls):
 
        cls.usr = db.User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
 
        cls.apikey = cls.usr.api_key
 
        cls.test_user = UserModel().create_or_update(
kallithea/tests/base.py
Show inline comments
 
@@ -135,12 +135,14 @@ class NullHandler(logging.Handler):
 
    def emit(self, record):
 
        pass
 

	
 

	
 
class TestController(object):
 
    """Pytest-style test controller"""
 
    app: TestApp  # assigned by app_fixture
 
    _logged_username: str  # assigned by log_user
 

	
 
    # Note: pytest base classes cannot have an __init__ method
 

	
 
    @pytest.fixture(autouse=True)
 
    def app_fixture(self):
 
        h = NullHandler()
scripts/deps.py
Show inline comments
 
@@ -90,12 +90,13 @@ textwrap
 
tgext
 
threading
 
time
 
traceback
 
traitlets
 
types
 
typing
 
urllib
 
urlobject
 
uuid
 
warnings
 
webhelpers2
 
webob
0 comments (0 inline, 0 general)