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

@@ -17,6 +17,7 @@ import os
import re
import sys
from pathlib import Path
from typing import Optional
import requests
@@ -183,7 +184,8 @@ def check_version_number(version_string, allow_duplicate=False):
return highest_release
if __name__ == '__main__':
def main() -> bool:
"""Run the version check."""
parser = argparse.ArgumentParser(description='InvenTree Version Check')
parser.add_argument(
'--show-version',
@@ -220,7 +222,7 @@ if __name__ == '__main__':
# Ensure that we are running in GH Actions
if os.environ.get('GITHUB_ACTIONS', '') != 'true':
print('This script is intended to be run within a GitHub Action!')
sys.exit(1)
return False
print('Running InvenTree version check...')
@@ -261,11 +263,11 @@ if __name__ == '__main__':
)
# Determine which docker tag we are going to use
docker_tags = None
docker_tags: Optional[list[str]] = None
if GITHUB_REF_TYPE == 'tag':
# GITHUB_REF should be of the form /refs/heads/<tag>
version_tag = GITHUB_REF.split('/')[-1]
version_tag: str = GITHUB_REF.split('/')[-1]
print(f"Checking requirements for tagged release - '{version_tag}':")
if version_tag != inventree_version:
@@ -287,11 +289,11 @@ if __name__ == '__main__':
print('GITHUB_REF_TYPE:', GITHUB_REF_TYPE)
print('GITHUB_BASE_REF:', GITHUB_BASE_REF)
print('GITHUB_REF:', GITHUB_REF)
sys.exit(1)
return False
if docker_tags is None:
print('Docker tags could not be determined')
sys.exit(1)
return False
print(f"Version check passed for '{inventree_version}'!")
print(f"Docker tags: '{docker_tags}'")
@@ -308,3 +310,11 @@ if __name__ == '__main__':
if GITHUB_REF_TYPE == 'tag' and highest_release:
env_file.write('stable_release=true\n')
return True
if __name__ == '__main__':
rslt = main()
if rslt is not True:
print('Version check failed!')
sys.exit(1)