mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
chore: bump pre commit (#8904)
* bump pre-commit * auto-fixes * ignore error * fix a few more issues * fix pattern
This commit is contained in:
parent
3d2f800c73
commit
64b9365947
@ -17,7 +17,7 @@ repos:
|
|||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.7.3
|
rev: v0.9.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
args: [--preview]
|
args: [--preview]
|
||||||
@ -28,7 +28,7 @@ repos:
|
|||||||
--preview
|
--preview
|
||||||
]
|
]
|
||||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||||
rev: 0.5.1
|
rev: 0.5.20
|
||||||
hooks:
|
hooks:
|
||||||
- id: pip-compile
|
- id: pip-compile
|
||||||
name: pip-compile requirements-dev.in
|
name: pip-compile requirements-dev.in
|
||||||
@ -51,7 +51,7 @@ repos:
|
|||||||
args: [contrib/container/requirements.in, -o, contrib/container/requirements.txt, --python-version=3.11, --no-strip-extras, --generate-hashes]
|
args: [contrib/container/requirements.in, -o, contrib/container/requirements.txt, --python-version=3.11, --no-strip-extras, --generate-hashes]
|
||||||
files: contrib/container/requirements\.(in|txt)$
|
files: contrib/container/requirements\.(in|txt)$
|
||||||
- repo: https://github.com/Riverside-Healthcare/djLint
|
- repo: https://github.com/Riverside-Healthcare/djLint
|
||||||
rev: v1.36.1
|
rev: v1.36.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: djlint-django
|
- id: djlint-django
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
@ -70,13 +70,13 @@ repos:
|
|||||||
src/frontend/vite.config.ts |
|
src/frontend/vite.config.ts |
|
||||||
)$
|
)$
|
||||||
- repo: https://github.com/biomejs/pre-commit
|
- repo: https://github.com/biomejs/pre-commit
|
||||||
rev: "v0.5.0"
|
rev: "v0.6.1"
|
||||||
hooks:
|
hooks:
|
||||||
- id: biome-check
|
- id: biome-check
|
||||||
additional_dependencies: ["@biomejs/biome@1.9.4"]
|
additional_dependencies: ["@biomejs/biome@1.9.4"]
|
||||||
files: ^src/frontend/.*\.(js|ts|tsx)$
|
files: ^src/frontend/.*\.(js|ts|tsx)$
|
||||||
- repo: https://github.com/gitleaks/gitleaks
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
rev: v8.21.2
|
rev: v8.23.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
#- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
#- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||||
|
@ -19,7 +19,7 @@ threads = 4
|
|||||||
|
|
||||||
|
|
||||||
# Worker timeout (default = 90 seconds)
|
# Worker timeout (default = 90 seconds)
|
||||||
timeout = os.environ.get('INVENTREE_GUNICORN_TIMEOUT', 90)
|
timeout = os.environ.get('INVENTREE_GUNICORN_TIMEOUT', '90')
|
||||||
|
|
||||||
# Number of worker processes
|
# Number of worker processes
|
||||||
workers = os.environ.get('INVENTREE_GUNICORN_WORKERS', None)
|
workers = os.environ.get('INVENTREE_GUNICORN_WORKERS', None)
|
||||||
|
@ -150,7 +150,7 @@ def on_config(config, *args, **kwargs):
|
|||||||
|
|
||||||
We can use these to determine (at run time) where we are hosting
|
We can use these to determine (at run time) where we are hosting
|
||||||
"""
|
"""
|
||||||
rtd = os.environ.get('READTHEDOCS', False)
|
rtd = os.environ.get('READTHEDOCS', 'False')
|
||||||
|
|
||||||
# Note: version selection is handled by RTD internally
|
# Note: version selection is handled by RTD internally
|
||||||
# Check for 'versions.json' file
|
# Check for 'versions.json' file
|
||||||
|
@ -34,6 +34,8 @@ ignore = [
|
|||||||
# - RUF015 - Prefer next({iterable}) over single element slice
|
# - RUF015 - Prefer next({iterable}) over single element slice
|
||||||
"RUF012",
|
"RUF012",
|
||||||
# - RUF012 - Mutable class attributes should be annotated with typing.ClassVar
|
# - RUF012 - Mutable class attributes should be annotated with typing.ClassVar
|
||||||
|
"RUF052",
|
||||||
|
# - RUF052 - Local dummy variable is accessed
|
||||||
"SIM117",
|
"SIM117",
|
||||||
# - SIM117 - Use a single with statement with multiple contexts instead of nested with statements
|
# - SIM117 - Use a single with statement with multiple contexts instead of nested with statements
|
||||||
"SIM102",
|
"SIM102",
|
||||||
|
@ -11,6 +11,7 @@ from decimal import Decimal, InvalidOperation
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, TypeVar, Union
|
from typing import Optional, TypeVar, Union
|
||||||
from wsgiref.util import FileWrapper
|
from wsgiref.util import FileWrapper
|
||||||
|
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.storage import StaticFilesStorage
|
from django.contrib.staticfiles.storage import StaticFilesStorage
|
||||||
@ -25,7 +26,6 @@ import structlog
|
|||||||
from bleach import clean
|
from bleach import clean
|
||||||
from djmoney.money import Money
|
from djmoney.money import Money
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
|
||||||
|
|
||||||
from common.currency import currency_code_default
|
from common.currency import currency_code_default
|
||||||
|
|
||||||
|
@ -762,8 +762,7 @@ class InvenTreeTree(MetadataMixin, PluginValidationMixin, MPTTModel):
|
|||||||
pathstring = self.construct_pathstring()
|
pathstring = self.construct_pathstring()
|
||||||
|
|
||||||
if pathstring != self.pathstring:
|
if pathstring != self.pathstring:
|
||||||
if 'force_insert' in kwargs:
|
kwargs.pop('force_insert', None)
|
||||||
del kwargs['force_insert']
|
|
||||||
|
|
||||||
kwargs['force_update'] = True
|
kwargs['force_update'] = True
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||||
|
|
||||||
import django.conf.locale
|
import django.conf.locale
|
||||||
import django.core.exceptions
|
import django.core.exceptions
|
||||||
@ -21,7 +22,6 @@ from django.http import Http404
|
|||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
|
||||||
|
|
||||||
from InvenTree.cache import get_cache_config, is_global_cache_enabled
|
from InvenTree.cache import get_cache_config, is_global_cache_enabled
|
||||||
from InvenTree.config import get_boolean_setting, get_custom_file, get_setting
|
from InvenTree.config import get_boolean_setting, get_custom_file, get_setting
|
||||||
|
@ -5,6 +5,7 @@ import time
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
import django.core.exceptions as django_exceptions
|
import django.core.exceptions as django_exceptions
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -21,7 +22,6 @@ from djmoney.contrib.exchange.models import Rate, convert_money
|
|||||||
from djmoney.money import Money
|
from djmoney.money import Money
|
||||||
from maintenance_mode.core import get_maintenance_mode, set_maintenance_mode
|
from maintenance_mode.core import get_maintenance_mode, set_maintenance_mode
|
||||||
from sesame.utils import get_user
|
from sesame.utils import get_user
|
||||||
from zoneinfo import ZoneInfo
|
|
||||||
|
|
||||||
import InvenTree.conversion
|
import InvenTree.conversion
|
||||||
import InvenTree.format
|
import InvenTree.format
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Provides a JSON API for common components."""
|
"""Provides a JSON API for common components."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Type
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@ -557,7 +556,7 @@ class AllUnitList(ListAPI):
|
|||||||
"""Parse a unit from the registry."""
|
"""Parse a unit from the registry."""
|
||||||
if not hasattr(reg, k):
|
if not hasattr(reg, k):
|
||||||
return None
|
return None
|
||||||
unit: Type[UnitLike] = getattr(reg, k)
|
unit: type[UnitLike] = getattr(reg, k)
|
||||||
return {
|
return {
|
||||||
'name': k,
|
'name': k,
|
||||||
'is_alias': reg.get_name(k) == k,
|
'is_alias': reg.get_name(k) == k,
|
||||||
|
@ -29,8 +29,8 @@ def validate_part_name_format(value):
|
|||||||
# Make sure that the field_name exists in Part model
|
# Make sure that the field_name exists in Part model
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
|
|
||||||
jinja_template_regex = re.compile('{{.*?}}')
|
jinja_template_regex = re.compile(r'{{.*?}}')
|
||||||
field_name_regex = re.compile('(?<=part\\.)[A-z]+')
|
field_name_regex = re.compile(r'(?<=part\.)[A-z]+')
|
||||||
|
|
||||||
for jinja_template in jinja_template_regex.findall(str(value)):
|
for jinja_template in jinja_template_regex.findall(str(value)):
|
||||||
# make sure at least one and only one field is present inside the parser
|
# make sure at least one and only one field is present inside the parser
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Custom model/serializer fields for InvenTree models that support custom states."""
|
"""Custom model/serializer fields for InvenTree models that support custom states."""
|
||||||
|
|
||||||
from typing import Any, Iterable, Optional
|
from collections.abc import Iterable
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -59,7 +59,7 @@ class LabelPrinterBaseDriver(BaseDriver):
|
|||||||
label: LabelTemplate,
|
label: LabelTemplate,
|
||||||
items: QuerySet[models.Model],
|
items: QuerySet[models.Model],
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> Union[None, JsonResponse]:
|
) -> Union[JsonResponse, None]:
|
||||||
"""Print one or more labels with the provided template and items.
|
"""Print one or more labels with the provided template and items.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Helper functions for barcode generation."""
|
"""Helper functions for barcode generation."""
|
||||||
|
|
||||||
from typing import Type, cast
|
from typing import cast
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ def generate_barcode(model_instance: InvenTreeBarcodeMixin):
|
|||||||
|
|
||||||
|
|
||||||
@cache
|
@cache
|
||||||
def get_supported_barcode_models() -> list[Type[InvenTreeBarcodeMixin]]:
|
def get_supported_barcode_models() -> list[type[InvenTreeBarcodeMixin]]:
|
||||||
"""Returns a list of database models which support barcode functionality."""
|
"""Returns a list of database models which support barcode functionality."""
|
||||||
return InvenTree.helpers_model.getModelsWithMixin(InvenTreeBarcodeMixin)
|
return InvenTree.helpers_model.getModelsWithMixin(InvenTreeBarcodeMixin)
|
||||||
|
|
||||||
|
@ -426,10 +426,10 @@ def render_html_text(text: str, **kwargs):
|
|||||||
"""
|
"""
|
||||||
tags = []
|
tags = []
|
||||||
|
|
||||||
if kwargs.get('bold', False):
|
if kwargs.get('bold'):
|
||||||
tags.append('strong')
|
tags.append('strong')
|
||||||
|
|
||||||
if kwargs.get('italic', False):
|
if kwargs.get('italic'):
|
||||||
tags.append('em')
|
tags.append('em')
|
||||||
|
|
||||||
if heading := kwargs.get('heading', ''):
|
if heading := kwargs.get('heading', ''):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Unit testing for the various report models."""
|
"""Unit testing for the various report models."""
|
||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -11,7 +12,6 @@ from django.utils import timezone
|
|||||||
from django.utils.safestring import SafeString
|
from django.utils.safestring import SafeString
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from zoneinfo import ZoneInfo
|
|
||||||
|
|
||||||
import report.models as report_models
|
import report.models as report_models
|
||||||
from build.models import Build
|
from build.models import Build
|
||||||
|
@ -472,7 +472,7 @@ class StockItem(
|
|||||||
Returns:
|
Returns:
|
||||||
QuerySet: The created StockItem objects
|
QuerySet: The created StockItem objects
|
||||||
|
|
||||||
raises:
|
Raises:
|
||||||
ValidationError: If any of the provided serial numbers are invalid
|
ValidationError: If any of the provided serial numbers are invalid
|
||||||
|
|
||||||
This method uses bulk_create to create multiple StockItem objects in a single query,
|
This method uses bulk_create to create multiple StockItem objects in a single query,
|
||||||
|
15
tasks.py
15
tasks.py
@ -614,7 +614,7 @@ def update(
|
|||||||
# If:
|
# If:
|
||||||
# - INVENTREE_DOCKER is set (by the docker image eg.) and not overridden by `--frontend` flag
|
# - INVENTREE_DOCKER is set (by the docker image eg.) and not overridden by `--frontend` flag
|
||||||
# - `--no-frontend` flag is set
|
# - `--no-frontend` flag is set
|
||||||
if (os.environ.get('INVENTREE_DOCKER', False) and not frontend) or no_frontend:
|
if (os.environ.get('INVENTREE_DOCKER', 'False') and not frontend) or no_frontend:
|
||||||
if no_frontend:
|
if no_frontend:
|
||||||
info('Skipping frontend update (no_frontend flag set)')
|
info('Skipping frontend update (no_frontend flag set)')
|
||||||
else:
|
else:
|
||||||
@ -1041,7 +1041,7 @@ def test(
|
|||||||
|
|
||||||
pty = not disable_pty
|
pty = not disable_pty
|
||||||
|
|
||||||
_apps = ' '.join(apps())
|
tested_apps = ' '.join(apps())
|
||||||
|
|
||||||
cmd = 'test'
|
cmd = 'test'
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ def test(
|
|||||||
cmd += f' {runtest}'
|
cmd += f' {runtest}'
|
||||||
else:
|
else:
|
||||||
# Run all tests
|
# Run all tests
|
||||||
cmd += f' {_apps}'
|
cmd += f' {tested_apps}'
|
||||||
|
|
||||||
if report:
|
if report:
|
||||||
cmd += ' --slowreport'
|
cmd += ' --slowreport'
|
||||||
@ -1351,9 +1351,12 @@ def frontend_download(
|
|||||||
|
|
||||||
def handle_download(url):
|
def handle_download(url):
|
||||||
# download frontend-build.zip to temporary file
|
# download frontend-build.zip to temporary file
|
||||||
with requests.get(
|
with (
|
||||||
url, headers=default_headers, stream=True, allow_redirects=True
|
requests.get(
|
||||||
) as response, NamedTemporaryFile(suffix='.zip') as dst:
|
url, headers=default_headers, stream=True, allow_redirects=True
|
||||||
|
) as response,
|
||||||
|
NamedTemporaryFile(suffix='.zip') as dst,
|
||||||
|
):
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
# auto decode the gzipped raw data
|
# auto decode the gzipped raw data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user