It was made mandatory in 9685f50a69d0. At that time it seemed like it always were present due to indirect dependencies, but apparently that is no longer the case.
pytype: add assertion to guide pytype through Whoosh usage
Mute pytype warnings:
File "kallithea/controllers/admin/admin.py", line 105, in _journal_filter: No attribute 'fieldname' on None [attribute-error] In Optional[Any] File "kallithea/controllers/admin/admin.py", line 106, in _journal_filter: No attribute 'text' on None [attribute-error] In Optional[Any] File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'startdate' on None [attribute-error] In Optional[Any] File "kallithea/controllers/admin/admin.py", line 107, in _journal_filter: No attribute 'enddate' on None [attribute-error] In Optional[Any]
pytype: add some assertions to guide pytype through const dict with tricky typing structure
These assertions also make the code more explicit and slightly more readable.
Mute pytype warnings:
File "kallithea/tests/vcs/base.py", line 76, in setup_repo: No attribute 'path' on str [attribute-error] In Union[kallithea.lib.vcs.nodes.FileNode, nothing, str] File "kallithea/tests/vcs/base.py", line 76, in setup_repo: No attribute 'content' on str [attribute-error] In Union[kallithea.lib.vcs.nodes.FileNode, nothing, str]
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]
pytype: mute errors from import of optional or platform specific modules
Mute pytype warnings:
File "kallithea/bin/kallithea_cli_iis.py", line 69, in iis_install: Can't find module 'isapi_wsgi'. [import-error] File "kallithea/config/post_receive_tmpl.py", line 24, in <module>: No attribute 'setmode' on module 'msvcrt' [module-attr] File "kallithea/config/pre_receive_tmpl.py", line 24, in <module>: No attribute 'setmode' on module 'msvcrt' [module-attr] File "kallithea/lib/compat.py", line 59, in kill: No attribute 'windll' on module 'ctypes' [module-attr] File "kallithea/lib/utils.py", line 242, in is_valid_repo_uri: Can't find module 'hgsubversion.svnrepo'. [import-error] File "kallithea/tests/scripts/manual_test_concurrency.py", line 203, in <module>: No attribute '_RandomNameSequence' on module 'tempfile' [module-attr]
Spotted by pytype --strict-import: File "kallithea/bin/kallithea_cli_db.py", line 73, in db_create: No attribute 'utils' on module 'kallithea.lib' [module-attr] File "kallithea/bin/kallithea_cli_db.py", line 73, in db_create: No attribute 'scm' on module 'kallithea.model' [module-attr]
It happened to work anyway due to the import chain ... but it is better to be explicit.
hooks: when overwriting non-Kallithea hooks, move the old hook to .bak
Note: This will only happen when actually overwriting an unknown hook. Repeated hook installation will thus not clobber the existing .bak file until a non-Kallithea hook is found again.
hooks: be more consistent in only using active Ui entries
There is no UI to control or display the ui_active value for custom hooks, but *if* they are inactive, they will be ignored in make_ui, and it will be misleading and confusing to show them in the list of active custom hooks.
There *should* never be any inactive hooks entries, but let's be consistent in handling the case *if* it should happen. (It happened for me while hacking around.)
celery: upgrade to Celery 5.0 ... and adjust for Click API
Celery 5 has apparently no relevant API or config changes.
Celery is however switching to click. run_from_argv goes away, and there is no simple way to do as before and start the worker with our Celery app but still use Celery's own command line parser.
Apply hacks to make sure it still is possible to run like:
celery: celery-run should only initialize app and sqlalchemy after workers have been forked
If app and SqlAlchemy were initialized before launching celery, the forked workers would inherit the database connection ... and that doesn't work.
This could be handled by disposing the engine after forking the worker or before each task ... but it remains unnecessary and wrong to initialize the engine early when it isn't used, and then fork it.
celery: drop tracking of task_id - we use ignore_result=True and will never get anything back
There is thus no need for configuration of celery.result_backend .
The alternative would be to fix it. That could give better error reporting from failing repo creations, but would require quite a bit of additional changes before it actually works reliably.
celery: use explicit task names - avoid automatic naming with "kallithea.lib.celerylib." prefix
We wrap async functions in a local f_async wrapper, defined in kallithea/lib/celerylib/__init__.py . For a function Foo.X, even though we changed the wrapper's __name__ to X, the tasks would be named kallithea.lib.celerylib.X , without using the actual module name of X for namespacing.
Drop modifying __name__, and just specify the name explicitly, without trying to namespace it.
api: fix repo group permission check for repo creation
hg.create.repository is only controlling whether all users have write access at top level. For other repo locations, check for write permission to the repo group.
Note: This also covers "repo creation" by forking or by moving another repo.
model: simplify how get_commits_stats task group on author
Avoid using the caching h.person . We want to get rid of the model dependency on helpers.
The stats are persisted, and any temporary incorrectness in the long term cached h.person will thus remain forever. It is thus arguably better to avoid using it in this place.
get_commits_stats is also a long running task, so speed is not *that* critical. And generally, processing commits in order will have a lot of the same committers, so a local cache will have a good hit rate.
(Alternatively, h.person could perhaps be in user model ... but that's not how it is now.)
lib: move some template filter functions from utils2 to webutils
While quite Kallithea specific, we prefer to have these functions in webutils where they soon can be exposed when templates don't need the whole helpers module.
The original comment in b153a51b1d3b was "to get the pylons_app import" ... which seems like a bad workaround for not having installed the app properly before running.
Passing a whole User wouldn't work if actually using celery and thus serializing the parameters. The test scenario was thus different from actual runtime.
tests: fix create_fork to actually pass a repo id as fork_parent_id
Passing a whole repo wouldn't work if actually using celery and thus serializing the parameters. The test scenario was thus different from actual runtime.