ignore __class__ type checking errors

see https://github.com/astral-sh/ty/issues/3122
This commit is contained in:
Matthias Mair 2026-06-21 23:41:39 +02:00
parent 85a689179b
commit 276102543f
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
25 changed files with 30 additions and 28 deletions

View File

@ -583,7 +583,7 @@ class Order(
This method must be implemented by any subclass, as the 'company' field may be named differently for different order types (e.g. supplier vs customer).
"""
raise NotImplementedError(f'company() method not implemented for {__class__}')
raise NotImplementedError(f'company() method not implemented for {__class__}') # ty:ignore[unresolved-reference]
@property
def order_address(self):
@ -608,7 +608,7 @@ class Order(
@classmethod
def get_status_class(cls):
"""Return the enumeration class which represents the 'status' field for this model."""
raise NotImplementedError(f'get_status_class() not implemented for {__class__}')
raise NotImplementedError(f'get_status_class() not implemented for {__class__}') # ty:ignore[unresolved-reference]
class PurchaseOrder(TotalPriceMixin, Order):

View File

@ -16,7 +16,7 @@ class ActionMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.ACTION, True, __class__)
self.add_mixin(PluginMixinEnum.ACTION, True, __class__) # ty:ignore[unresolved-reference]
def action_name(self):
"""Action name for this plugin.

View File

@ -35,7 +35,7 @@ class BarcodeMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.BARCODE, 'has_barcode', __class__)
self.add_mixin(PluginMixinEnum.BARCODE, 'has_barcode', __class__) # ty:ignore[unresolved-reference]
@property
def has_barcode(self):
@ -105,7 +105,7 @@ class SupplierBarcodeMixin(BarcodeMixin):
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.SUPPLIER_BARCODE, True, __class__)
self.add_mixin(PluginMixinEnum.SUPPLIER_BARCODE, True, __class__) # ty:ignore[unresolved-reference]
def get_field_value(self, key, backup_value=None):
"""Return the value of a barcode field."""

View File

@ -34,4 +34,4 @@ class EventMixin:
def __init__(self):
"""Register the mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.EVENTS, True, __class__)
self.add_mixin(PluginMixinEnum.EVENTS, True, __class__) # ty:ignore[unresolved-reference]

View File

@ -20,7 +20,7 @@ class IconPackMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.ICON_PACK, True, __class__)
self.add_mixin(PluginMixinEnum.ICON_PACK, True, __class__) # ty:ignore[unresolved-reference]
@classmethod
def _activate_mixin(cls, registry, plugins, *args, **kwargs):
@ -31,5 +31,5 @@ class IconPackMixin:
def icon_packs(self) -> list[IconPack]:
"""Return a list of custom icon packs."""
raise MixinNotImplementedError(
f"{__class__} is missing the 'icon_packs' method"
f"{__class__} is missing the 'icon_packs' method" # ty:ignore[unresolved-reference]
)

View File

@ -73,7 +73,7 @@ class APICallMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.API_CALL, 'has_api_call', __class__)
self.add_mixin(PluginMixinEnum.API_CALL, 'has_api_call', __class__) # ty:ignore[unresolved-reference]
@property
def has_api_call(self):

View File

@ -27,7 +27,7 @@ class AppMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.APP, 'has_app', __class__)
self.add_mixin(PluginMixinEnum.APP, 'has_app', __class__) # ty:ignore[unresolved-reference]
@classmethod
def _activate_mixin(

View File

@ -22,7 +22,7 @@ class CurrencyExchangeMixin:
def __init__(self):
"""Register the mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.CURRENCY_EXCHANGE, True, __class__)
self.add_mixin(PluginMixinEnum.CURRENCY_EXCHANGE, True, __class__) # ty:ignore[unresolved-reference]
def update_exchange_rates(self, base_currency: str, symbols: list[str]) -> dict:
"""Update currency exchange rates.

View File

@ -33,7 +33,7 @@ class DataExportMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.EXPORTER, True, __class__)
self.add_mixin(PluginMixinEnum.EXPORTER, True, __class__) # ty:ignore[unresolved-reference]
def supports_export(
self,

View File

@ -30,7 +30,7 @@ class MachineDriverMixin:
def __init__(self):
"""Initialize the mixin and register it."""
super().__init__()
self.add_mixin(PluginMixinEnum.MACHINE, True, __class__)
self.add_mixin(PluginMixinEnum.MACHINE, True, __class__) # ty:ignore[unresolved-reference]
def get_machine_types(self) -> list[BaseMachineType]:
"""Register custom machine types."""

View File

@ -22,7 +22,7 @@ class NavigationMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.NAVIGATION, 'has_navigation', __class__)
self.add_mixin(PluginMixinEnum.NAVIGATION, 'has_navigation', __class__) # ty:ignore[unresolved-reference]
self.navigation = self.setup_navigation()
def setup_navigation(self):

View File

@ -30,7 +30,7 @@ class NotificationMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.NOTIFICATION, True, __class__)
self.add_mixin(PluginMixinEnum.NOTIFICATION, True, __class__) # ty:ignore[unresolved-reference]
def filter_targets(self, targets: list[User]) -> list[User]:
"""Filter notification targets based on the plugin's logic."""

View File

@ -22,7 +22,7 @@ class ReportMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.REPORT, True, __class__)
self.add_mixin(PluginMixinEnum.REPORT, True, __class__) # ty:ignore[unresolved-reference]
def add_report_context(self, report_instance, model_instance, user, context):
"""Add extra context to the provided report instance.

View File

@ -55,7 +55,7 @@ class ScheduleMixin:
self.scheduled_tasks = []
self.add_mixin(PluginMixinEnum.SCHEDULE, 'has_scheduled_tasks', __class__)
self.add_mixin(PluginMixinEnum.SCHEDULE, 'has_scheduled_tasks', __class__) # ty:ignore[unresolved-reference]
@classmethod
def _activate_mixin(cls, registry, plugins, *args, **kwargs):

View File

@ -38,7 +38,7 @@ class SettingsMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.SETTINGS, 'has_settings', __class__)
self.add_mixin(PluginMixinEnum.SETTINGS, 'has_settings', __class__) # ty:ignore[unresolved-reference]
self.settings = getattr(self, 'SETTINGS', {})
self.user_settings = getattr(self, 'USER_SETTINGS', {})

View File

@ -27,7 +27,9 @@ class TransitionMixin:
"""Initialize the mixin and register it."""
super().__init__()
self.add_mixin(
PluginMixinEnum.STATE_TRANSITION, 'has_transition_handlers', __class__
PluginMixinEnum.STATE_TRANSITION,
'has_transition_handlers',
__class__, # ty:ignore[unresolved-reference]
)
@property

View File

@ -22,7 +22,7 @@ class UrlsMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.URLS, 'has_urls', __class__)
self.add_mixin(PluginMixinEnum.URLS, 'has_urls', __class__) # ty:ignore[unresolved-reference]
self.urls = self.setup_urls()
@classmethod

View File

@ -48,7 +48,7 @@ class ValidationMixin:
def __init__(self):
"""Register the mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.VALIDATION, True, __class__)
self.add_mixin(PluginMixinEnum.VALIDATION, True, __class__) # ty:ignore[unresolved-reference]
def raise_error(self, message):
"""Raise a ValidationError with the given message."""

View File

@ -34,7 +34,7 @@ class LabelPrintingMixin:
def __init__(self): # pragma: no cover
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.LABELS, True, __class__)
self.add_mixin(PluginMixinEnum.LABELS, True, __class__) # ty:ignore[unresolved-reference]
BLOCKING_PRINT = True

View File

@ -32,7 +32,7 @@ class LocateMixin:
def __init__(self):
"""Register the mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.LOCATE, True, __class__)
self.add_mixin(PluginMixinEnum.LOCATE, True, __class__) # ty:ignore[unresolved-reference]
def locate_stock_item(self, item_pk):
"""Attempt to locate a particular StockItem.

View File

@ -36,4 +36,4 @@ class MailMixin:
def __init__(self):
"""Register the mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.MAIL, True, __class__)
self.add_mixin(PluginMixinEnum.MAIL, True, __class__) # ty:ignore[unresolved-reference]

View File

@ -28,7 +28,7 @@ class SupplierMixin(SettingsMixin, Generic[PartData]):
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.SUPPLIER, True, __class__)
self.add_mixin(PluginMixinEnum.SUPPLIER, True, __class__) # ty:ignore[unresolved-reference]
self.SETTINGS['SUPPLIER'] = {
'name': 'Supplier',

View File

@ -84,7 +84,7 @@ class UserInterfaceMixin:
def __init__(self):
"""Register mixin."""
super().__init__()
self.add_mixin(PluginMixinEnum.USER_INTERFACE, True, __class__)
self.add_mixin(PluginMixinEnum.USER_INTERFACE, True, __class__) # ty:ignore[unresolved-reference]
def get_ui_features(
self, feature_type: FeatureType, context: dict, request: Request, **kwargs

View File

@ -11,7 +11,7 @@ class BadActorPlugin(InvenTreePlugin):
def __init__(self, *args, **kwargs):
"""Initialize the plugin."""
super().__init__(*args, **kwargs)
self.add_mixin('settings', 'has_settings', __class__)
self.add_mixin('settings', 'has_settings', __class__) # ty:ignore[unresolved-reference]
def plugin_slug(self) -> str:
"""Return the slug of this plugin."""

View File

@ -7,4 +7,4 @@ class BrokenFileIntegrationPlugin(InvenTreePlugin):
"""An very broken plugin."""
aaa = bb # noqa: F821
aaa = bb # noqa: F821 # ty:ignore[unresolved-reference]