2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-18 00:21:31 +00:00

feat(backend): add typechecking with ty (#9664)

* Add ty for type checking

* fix various typing issues

* fix req

* more fixes

* and more types

* and more typing

* fix imports

* more fixes

* fix types and optional statements

* ensure patch only runs if it is installed

* add type check to qc

* more fixes

* install all reqs

* fix more types

* more fixes

* disable container stuff for now

* move typecheck to seperate job

* try to use putput for path

* use env instead

* fix typo

* add missing install

* remove unclear imports - not sure why this was done

* add kwarg names

* fix introduced issue in url call

* ignore import

* fix broken typing changes

* fix filter import

* reduce change set

* remove api-change

* fix dict

* ignore typing errors

* fix more type issues

* ignore errors

* style fix

* fix type

* bump ty

* fix more

* type fixes

* update ignores

* fix import

* fix defaults

* fix ignore

* fix some issues

* fix type
This commit is contained in:
Matthias Mair
2025-09-17 13:30:02 +02:00
committed by GitHub
parent f057247fc1
commit 21cb488eef
100 changed files with 524 additions and 267 deletions

View File

@@ -77,7 +77,7 @@ def is_pkg_installer_by_path():
def get_installer(content: Optional[dict] = None):
"""Get the installer for the current environment or a content dict."""
if content is None:
content = os.environ
content = dict(os.environ)
return content.get('INVENTREE_PKG_INSTALLER', None)
@@ -461,7 +461,9 @@ def check_file_existence(filename: Path, overwrite: bool = False):
@state_logger('TASK01')
def plugins(c, uv=False):
"""Installs all plugins as specified in 'plugins.txt'."""
from src.backend.InvenTree.InvenTree.config import get_plugin_file
from src.backend.InvenTree.InvenTree.config import ( # type: ignore[import]
get_plugin_file,
)
plugin_file = get_plugin_file()
@@ -573,7 +575,9 @@ def rebuild_models(c):
@task
def rebuild_thumbnails(c):
"""Rebuild missing image thumbnails."""
from src.backend.InvenTree.InvenTree.config import get_media_dir
from src.backend.InvenTree.InvenTree.config import ( # type: ignore[import]
get_media_dir,
)
info(f'Rebuilding image thumbnails in {get_media_dir()}')
manage(c, 'rebuild_thumbnails', pty=True)
@@ -1165,7 +1169,7 @@ def test_translations(c):
info('Fill in dummy translations...')
file_path = pathlib.Path(settings.LOCALE_PATHS[0], 'xx', 'LC_MESSAGES', 'django.po')
new_file_path = str(file_path) + '_new'
new_file_path = Path(str(file_path) + '_new')
# compile regex
reg = re.compile(
@@ -1303,7 +1307,9 @@ def setup_test(
path='inventree-demo-dataset',
):
"""Setup a testing environment."""
from src.backend.InvenTree.InvenTree.config import get_media_dir
from src.backend.InvenTree.InvenTree.config import ( # type: ignore[import]
get_media_dir,
)
if not ignore_update:
update(c)
@@ -1453,8 +1459,8 @@ def export_definitions(c, basedir: str = ''):
@task(default=True)
def version(c):
"""Show the current version of InvenTree."""
import src.backend.InvenTree.InvenTree.version as InvenTreeVersion
from src.backend.InvenTree.InvenTree.config import (
import src.backend.InvenTree.InvenTree.version as InvenTreeVersion # type: ignore[import]
from src.backend.InvenTree.InvenTree.config import ( # type: ignore[import]
get_backup_dir,
get_config_file,
get_media_dir,