Skip to content

Commit 07417ac

Browse files
committed
Add migration for MEvent ID, remove Centrifugo hook and livefeed files, and update type hints and configurations
- Add migration 0002_alter_mevent_id to change MEvent ID to BigAutoField - Remove centrifugo hook implementation and livefeed frontend code (store.js) - Update type hints in admin.py, hooks/redis/serializer.py, and tracking.py - Fix string formatting typo in redis/__init__.py - Update pyrightconfig.json to exclude tests directory - Adjust setup.cfg for flake8, mypy, and coverage configurations - Simplify type annotation formatting in apps.py
1 parent 07d247c commit 07417ac

11 files changed

Lines changed: 48 additions & 157 deletions

File tree

mqueue/admin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class MEventAdmin(admin.ModelAdmin):
4646
"scope",
4747
)
4848
search_fields = ["name", "user__username", "event_class", "bucket"]
49-
link_to_object.allow_tags = True
50-
link_to_object.short_description = _("See on site")
51-
link_to_object_admin.allow_tags = True
52-
link_to_object_admin.short_description = _("See in admin")
53-
format_event_class.allow_tags = True
54-
format_event_class.short_description = _("Class")
49+
link_to_object.allow_tags = True # type: ignore
50+
link_to_object.short_description = _("See on site") # type: ignore
51+
link_to_object_admin.allow_tags = True # type: ignore
52+
link_to_object_admin.short_description = _("See in admin") # type: ignore
53+
format_event_class.allow_tags = True # type: ignore
54+
format_event_class.short_description = _("Class") # type: ignore
5555
filters_on_top = True
5656
list_select_related = (
5757
"user",

mqueue/apps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def ready(self):
1414
from django.conf import settings
1515
from .tracking import mqueue_tracker
1616

17-
registered_models: Union[
18-
Tuple[str, List[str]], List[Union[str, List[str]]]
19-
] = getattr(settings, "MQUEUE_AUTOREGISTER", [])
17+
registered_models: Union[Tuple[str, List[str]], List[Union[str, List[str]]]] = (
18+
getattr(settings, "MQUEUE_AUTOREGISTER", [])
19+
)
2020
for modtup in registered_models:
2121
modpath = modtup[0]
2222
level = modtup[1]

mqueue/hooks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ def dispatch(event):
66
for name in HOOKS:
77
hook = HOOKS[name]
88
path = hook["path"]
9-
module = importlib.import_module(path)
9+
module = importlib.import_module(f"{path}")
1010
func = getattr(module, "save")
1111
func(event, hook)

mqueue/hooks/centrifugo/__init__.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

mqueue/hooks/redis/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import time
42
from typing import Dict
53

@@ -23,8 +21,7 @@
2321

2422

2523
def save(event: MEvent, conf: Dict[str, str]):
26-
global EVENT_NUM, R, DOMAIN
27-
name = DOMAIN + "_event" + str(EVENT_NUM)
24+
name = DOMAIN + "_event" + str(EVENT_NUM) # type: ignore
2825
data = serializer.Pack(event)
2926
R.set(name, data)
30-
EVENT_NUM += 1
27+
EVENT_NUM += 1 # type: ignore

mqueue/hooks/redis/serializer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
def Pack(event):
1+
from ...models import MEvent
2+
3+
4+
def Pack(event: MEvent):
25
sep = "#!#"
36
data = ["name:;" + event.name]
47
if event.event_class:
@@ -16,11 +19,11 @@ def Pack(event):
1619
if event.notes:
1720
data.append("notes:;" + str(event.notes))
1821
if event.request:
19-
request = event.request.replace("\n", "//")
22+
request = event.request.replace("\n", "//") # type: ignore
2023
data.append("request:;" + request)
2124
if event.bucket:
2225
data.append("bucket:;" + event.bucket)
23-
if event.data or event.data != {}:
26+
if bool(event.data):
2427
data.append("data:;" + str(event.data))
2528
d = str.join(sep, data)
2629
return d
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.1 on 2025-06-06 10:52
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('mqueue', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='mevent',
15+
name='id',
16+
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
17+
),
18+
]

mqueue/static/mqueue/livefeed/store.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

mqueue/tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class MTracker(object):
8-
def register(self, model: Model, monitoring_level: List[str]):
8+
def register(self, model: type[Model], monitoring_level: List[str]):
99
if "c" in monitoring_level:
1010
post_save.connect(mmessage_create, sender=model)
1111
if "u" in monitoring_level:

pyrightconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"enableTypeIgnoreComments": true,
1818
"useLibraryCodeForTypes": true,
1919
"exclude": [
20-
"docsite"
20+
"docsite",
21+
"tests"
2122
]
2223
}

0 commit comments

Comments
 (0)