Skip to content

Commit e13e77f

Browse files
committed
fixup! chore: add support for Python 3.11 + 3.12 and Django 4.2 + 5.2
1 parent 4ec375b commit e13e77f

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

completion_aggregator/api/v1/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,16 @@ def get(self, request, course_key):
563563
course_key=course_key,
564564
aggregation_name='course',
565565
user_id__in=[enrollment.user_id for enrollment in enrollments])
566-
completion_stats = aggregator_qs.aggregate(
567-
possible=Avg('possible'),
568-
earned=Sum('earned') / len(enrollments),
569-
percent=Sum('earned') / (Avg('possible') * len(enrollments)))
570-
completion_stats['course_key'] = course_key
566+
num_enrollments = len(enrollments)
567+
aggregates = aggregator_qs.aggregate(avg_possible=Avg("possible"), total_earned=Sum("earned"))
568+
avg_possible = aggregates["avg_possible"] or 0
569+
total_earned = aggregates["total_earned"] or 0
570+
completion_stats = {
571+
"course_key": course_key,
572+
"possible": avg_possible,
573+
"earned": total_earned / num_enrollments if num_enrollments else 0,
574+
"percent": total_earned / (avg_possible * num_enrollments) if avg_possible and num_enrollments else 0,
575+
}
571576

572577
serializer = self.get_serializer_class()(
573578
instance=completion_stats,

completion_aggregator/management/commands/migrate_progress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ def _configure_logging(self, options):
7272

7373
if options.get('verbosity') == 0:
7474
log_level = logging.WARNING
75-
elif options.get('verbosity') >= 1:
75+
else:
7676
log_level = logging.INFO
7777
log.setLevel(log_level)

completion_aggregator/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""
22
Various utility functionality.
33
"""
4+
from datetime import timezone
5+
46
import django
57
from django.contrib.auth import get_user_model
6-
from django.utils import timezone
78
from django.utils.translation import gettext as _
89

910
WAFFLE_AGGREGATE_STALE_FROM_SCRATCH = 'completion_aggregator.aggregate_stale_from_scratch'

pylintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
# SERIOUSLY.
6565
#
6666
# ------------------------------
67-
# Generated by edx-lint version: 5.3.2
67+
# Generated by edx-lint version: 5.6.0
6868
# ------------------------------
6969
[MASTER]
7070
ignore = migrations
@@ -260,6 +260,7 @@ enable =
260260
disable =
261261
import-outside-toplevel,
262262
too-many-arguments,
263+
too-many-positional-arguments,
263264
too-many-instance-attributes,
264265
too-many-locals,
265266
invalid-name,
@@ -366,6 +367,6 @@ ext-import-graph =
366367
int-import-graph =
367368

368369
[EXCEPTIONS]
369-
overgeneral-exceptions = Exception
370+
overgeneral-exceptions = builtins.Exception
370371

371-
# 63e94d8b98e89cb5ced90a5c57c522c6889d2f1e
372+
# 893b2dd614b484d9379a0604462f727e63fe557c

pylintrc_tweaks

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ load-plugins = edx_lint.pylint,pylint_django,pylint_celery
88
disable =
99
import-outside-toplevel,
1010
too-many-arguments,
11+
too-many-positional-arguments,
1112
too-many-instance-attributes,
1213
too-many-locals,
1314
invalid-name,
@@ -20,3 +21,6 @@ disable =
2021
superfluous-parens,
2122
unnecessary-pass,
2223
too-many-branches,
24+
25+
[EXCEPTIONS]
26+
overgeneral-exceptions = builtins.Exception

test_settings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ def root(*args):
9191
},
9292
]
9393
USE_TZ = True
94+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
95+
96+
# Suppress noisy import errors from event_routing_backends when running outside LMS.
97+
LOGGING = {
98+
'version': 1,
99+
'disable_existing_loggers': False,
100+
'loggers': {
101+
'event_routing_backends.helpers': {
102+
'level': 'CRITICAL',
103+
},
104+
},
105+
}
94106

95107
# Enables event tracking in the tests, see https://github.com/openedx/event-tracking
96108
EVENT_TRACKING_ENABLED = True

tox.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ match-dir = (?!migrations)
1919

2020
[pytest]
2121
DJANGO_SETTINGS_MODULE = test_settings
22-
addopts = --cov completion_aggregator --cov-report term-missing --cov-report xml -W error
22+
addopts = --cov completion_aggregator --cov-report term-missing --cov-report xml
2323
norecursedirs = .* docs requirements
24+
filterwarnings =
25+
error
26+
ignore:'cgi' is deprecated:DeprecationWarning:webob
2427

2528
[testenv]
2629
deps =

0 commit comments

Comments
 (0)