Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accounts/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.test import TestCase # noqa
from django.test import TestCase # ruff:ignore[unused-import, missing-required-import]


# Create your tests here.
1 change: 0 additions & 1 deletion course/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from collections.abc import Callable

from course.page.base import PageBase
from course.utils import CoursePageContext


# {{{ flow list
Expand Down
2 changes: 1 addition & 1 deletion course/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CourseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"

def ready(self):
import course.receivers # noqa
import course.receivers # ruff:ignore[unused-import]

# register all checks
register_startup_checks()
Expand Down
4 changes: 2 additions & 2 deletions course/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def reset_password(request: RelateHttpRequest, field: str = "email"):
_("self-registration is not enabled"))

# return form class by string of class name
ResetPasswordForm = globals()["ResetPasswordFormBy" + field.title()] # noqa
ResetPasswordForm = globals()["ResetPasswordFormBy" + field.title()] # ruff:ignore[non-lowercase-variable-in-function]
if request.method == "POST":
form = ResetPasswordForm(request.POST)
user = None
Expand Down Expand Up @@ -617,7 +617,7 @@ def reset_password(request: RelateHttpRequest, field: str = "email"):
"contact site staff."))
else:
if user is None:
FIELD_DICT = { # noqa
FIELD_DICT = { # ruff:ignore[non-lowercase-variable-in-function]
"email": _("email address"),
"instid": _("institutional ID")
}
Expand Down
14 changes: 8 additions & 6 deletions course/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import html.parser as html_parser
import os
import re
from collections.abc import Set as AbstractSet
from collections.abc import (
Set as AbstractSet, # ruff:ignore[typing-only-standard-library-import]
)
from dataclasses import dataclass, field
from itertools import starmap
from pathlib import Path
Expand Down Expand Up @@ -73,8 +75,8 @@
FlowSessionExpirationMode,
GradeAggregationStrategy,
)
from course.datespec import Datespec # noqa: TC001
from course.page.base import PageBase # noqa: TC001
from course.datespec import Datespec # ruff:ignore[typing-only-first-party-import]
from course.page.base import PageBase # ruff:ignore[typing-only-first-party-import]
from course.repo import (
CACHE_KEY_ROOT,
PYTHON_CLASS_REPO_PREFIX,
Expand Down Expand Up @@ -107,7 +109,7 @@


if TYPE_CHECKING:
from collections.abc import Callable, Collection, Mapping, Set as AbstractSet
from collections.abc import Callable, Collection, Mapping

from course.models import Course, Participation
from course.repo import Repo_ish
Expand Down Expand Up @@ -1513,7 +1515,7 @@ def __init__(self,
self.commit_sha = commit_sha
self.reverse_func = reverse_func

def extendMarkdown(self, md): # noqa
def extendMarkdown(self, md): # ruff:ignore[invalid-function-name]
md.treeprocessors.register(
LinkFixerTreeprocessor(md, self.course, self.commit_sha,
reverse_func=self.reverse_func),
Expand Down Expand Up @@ -1857,7 +1859,7 @@ def is_commit_sha_valid(repo: Repo_ish, commit_sha: RevisionID_ish) -> bool:
if repo is not None:
preview_sha_valid = is_commit_sha_valid(repo, preview_sha)
else:
with get_course_repo(course) as repo: # noqa: PLR1704
with get_course_repo(course) as repo: # ruff:ignore[redefined-argument-from-local]
preview_sha_valid = is_commit_sha_valid(repo, preview_sha)

if preview_sha_valid:
Expand Down
12 changes: 8 additions & 4 deletions course/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
from django.core.exceptions import PermissionDenied, SuspiciousOperation
from django.db import IntegrityError, transaction
from django.db.models import Q
from django.shortcuts import get_object_or_404, redirect, render # noqa
from django.shortcuts import ( # ruff:ignore[unused-import]
get_object_or_404,
redirect,
render,
)
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _, pgettext
Expand Down Expand Up @@ -416,13 +420,13 @@ def send_enrollment_decision(
def approve_enrollment(modeladmin, request, queryset):
decide_enrollment(True, modeladmin, request, queryset)

approve_enrollment.short_description = pgettext("Admin", "Approve enrollment") # type:ignore # noqa
approve_enrollment.short_description = pgettext("Admin", "Approve enrollment") # type:ignore # ruff:ignore[blank-lines-after-function-or-class]


def deny_enrollment(modeladmin, request, queryset):
decide_enrollment(False, modeladmin, request, queryset)

deny_enrollment.short_description = _("Deny enrollment") # type:ignore # noqa
deny_enrollment.short_description = _("Deny enrollment") # type:ignore # ruff:ignore[blank-lines-after-function-or-class]

# }}}

Expand Down Expand Up @@ -841,7 +845,7 @@ def query_participations(pctx):
if form.is_valid():
parsed_query = None
try:
for lineno, q in enumerate( # noqa: B007
for lineno, q in enumerate( # ruff:ignore[unused-loop-control-variable]
form.cleaned_data["queries"].split("\n")):
q = q.strip()

Expand Down
2 changes: 1 addition & 1 deletion course/grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ def download_all_submissions(pctx: CoursePageContext, flow_id: str):

access_rules_tags = flow_desc.rules.tags

ALL_SESSION_TAG = string_concat("<<<", _("ALL"), ">>>") # noqa
ALL_SESSION_TAG = string_concat("<<<", _("ALL"), ">>>") # ruff:ignore[non-lowercase-variable-in-function]
session_tag_choices = [
(tag, tag)
for tag in access_rules_tags] + [(ALL_SESSION_TAG,
Expand Down
6 changes: 5 additions & 1 deletion course/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
PermissionDenied,
SuspiciousOperation,
)
from django.shortcuts import get_object_or_404, redirect, render # noqa
from django.shortcuts import ( # ruff:ignore[unused-import]
get_object_or_404,
redirect,
render,
)
from django.utils.translation import gettext as _
from pytools import not_none

Expand Down
8 changes: 6 additions & 2 deletions course/im.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@
from django import forms
from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, redirect, render # noqa
from django.shortcuts import ( # ruff:ignore[unused-import]
get_object_or_404,
redirect,
render,
)
from django.utils.translation import gettext as _, pgettext_lazy

from course.constants import ParticipationPermission as PPerm
from course.models import (
Course, # noqa
Course, # ruff:ignore[unused-import]
InstantMessage,
)
from course.utils import course_view, render_course_page
Expand Down
4 changes: 2 additions & 2 deletions course/migrations/0113_merge_20190919_1408.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 2.2.4 on 2019-09-19 19:08

from typing import Any, List
from typing import Any

from django.db import migrations

Expand All @@ -12,4 +12,4 @@ class Migration(migrations.Migration):
('course', '0112_add_use_git_endpoint_permission'),
]

operations = [] # type: List[Any]
operations: list[Any] = []
4 changes: 2 additions & 2 deletions course/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from pytools import not_none
from typing_extensions import override

from course.constants import ( # noqa
from course.constants import ( # ruff:ignore[unused-import]
COURSE_ID_REGEX,
EVENT_KIND_REGEX,
EXAM_TICKET_STATE_CHOICES,
Expand Down Expand Up @@ -352,7 +352,7 @@ def clean(self) -> None:
super().clean()

try:
self.course # noqa: B018
self.course # ruff:ignore[useless-expression]
except ObjectDoesNotExist:
raise ValidationError(
{"course":
Expand Down
5 changes: 2 additions & 3 deletions course/page/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import builtins
import builtins # ruff:ignore[typing-only-standard-library-import]
from abc import ABC, abstractmethod
from dataclasses import dataclass
from inspect import isabstract
Expand Down Expand Up @@ -73,7 +73,6 @@


if TYPE_CHECKING:
import builtins
from collections.abc import Callable, Sequence, Set as AbstractSet

from course.models import Course, FlowSession
Expand Down Expand Up @@ -445,7 +444,7 @@ def __pydantic_init_subclass__(cls, **kwargs: object):
# The following will create a new type adapter every time a new subclass
# is created. Somewhat suboptimal, but there aren't very many.
PageBase._discriminating_type_adapter = TypeAdapter(
Annotated[Union[tuple(PageBase._subclasses.values())], # noqa: UP007 # pyright: ignore[reportDeprecated]
Annotated[Union[tuple(PageBase._subclasses.values())], # ruff:ignore[non-pep604-annotation-union] # pyright: ignore[reportDeprecated]
Field(discriminator="type")])

# emphasize that this should be fully defined at this point
Expand Down
4 changes: 2 additions & 2 deletions course/page/choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def normalize_from_str(cls, data: Any) -> Any:

try:
data = str(data)
except Exception: # noqa: S110
except Exception: # ruff:ignore[try-except-pass]
pass
else:
choice_mode, choice_text = mode_from_prefix(data)
Expand Down Expand Up @@ -152,7 +152,7 @@ def normalize_from_str(cls, data: Any) -> Any:

try:
data = str(data)
except Exception: # noqa: S110
except Exception: # ruff:ignore[try-except-pass]
pass
else:
choice_mode, choice_text = mode_from_prefix(data)
Expand Down
8 changes: 4 additions & 4 deletions course/page/code_run_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def substitute_correct_code_into_test_code(
return test_code

import re
CORRECT_CODE_TAG = re.compile(r"^(\s*)###CORRECT_CODE###\s*$") # noqa
CORRECT_CODE_TAG = re.compile(r"^(\s*)###CORRECT_CODE###\s*$") # ruff:ignore[non-lowercase-variable-in-function]

new_test_code_lines: list[str] = []
for line in test_code.split("\n"):
Expand Down Expand Up @@ -136,7 +136,7 @@ def user_code_thread(
user_ctx: dict[str, object],
exc_info: list[ExcInfo]) -> None:
try:
exec(user_code, user_ctx) # noqa: S102
exec(user_code, user_ctx) # ruff:ignore[exec-builtin]
except Exception:
tp, val, tb = sys.exc_info()
assert tp is not None
Expand Down Expand Up @@ -214,7 +214,7 @@ def output_html(s: str):

if setup_code is not None:
try:
exec(setup_code, maint_ctx) # noqa: S102
exec(setup_code, maint_ctx) # ruff:ignore[exec-builtin]
except BaseException:
return package_exception("setup_error")

Expand Down Expand Up @@ -293,7 +293,7 @@ def output_html(s: str):

if test_code is not None:
try:
exec(test_code, maint_ctx) # noqa: S102
exec(test_code, maint_ctx) # ruff:ignore[exec-builtin]
except GradingComplete:
pass
except BaseException:
Expand Down
10 changes: 6 additions & 4 deletions course/page/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@
PageData,
markup_to_html,
)
from course.page.choice import SingleChoiceDesc # noqa: TC001
from course.page.text import Matcher # noqa: TC001
from course.page.choice import (
SingleChoiceDesc, # ruff:ignore[typing-only-first-party-import]
)
from course.page.text import Matcher # ruff:ignore[typing-only-first-party-import]
from course.validation import (
CSSDimension,
CSSDimensionMax,
Expand Down Expand Up @@ -146,7 +148,7 @@ def clean(self):
for name in list(cleaned_data.keys()):
answer = self.answers[name]
if isinstance(answer, ShortAnswer):
for i, validator in enumerate(answer.correct_answer): # pragma: no branch # noqa
for i, validator in enumerate(answer.correct_answer): # pragma: no branch # ruff:ignore[line-too-long]
try:
validator.validate_text(cleaned_data[name])
except forms.ValidationError as e:
Expand Down Expand Up @@ -747,7 +749,7 @@ def page_correct_answer(self,
else:
snippets.append(t_or_b)

CA_PATTERN = string_concat(_("A correct answer is"), ": %s") # noqa
CA_PATTERN = string_concat(_("A correct answer is"), ": %s") # ruff:ignore[non-lowercase-variable-in-function]

result = CA_PATTERN % ("".join(snippets))

Expand Down
2 changes: 1 addition & 1 deletion course/page/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
PageData,
markup_to_html,
)
from course.validation import Markup # noqa: TC001
from course.validation import Markup # ruff:ignore[typing-only-first-party-import]


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion course/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.test import TestCase # noqa
from django.test import TestCase # ruff:ignore[unused-import, missing-required-import]


# Create your tests here.
2 changes: 1 addition & 1 deletion course/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def normalize_to_dict(cls, data: Any, info: ValidationInfo) -> Any:
else:
try:
data = float(data)
except Exception: # noqa: S110
except Exception: # ruff:ignore[try-except-pass]
pass

if isinstance(data, (int, float)):
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@


def setup(app):
app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821
app.connect("missing-reference", process_autodoc_missing_reference) # ruff:ignore[undefined-name]
4 changes: 2 additions & 2 deletions local_settings_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

import os # noqa: F401 # pyright: ignore[reportUnusedImport]
import os # ruff:ignore[unused-import]
from os import path


Expand All @@ -20,7 +20,7 @@
# Configure the following as url as above.
RELATE_BASE_URL = "http://YOUR/RELATE/SITE/DOMAIN"

from django.utils.translation import gettext_noop # noqa
from django.utils.translation import gettext_noop # ruff:ignore[unused-import, unsorted-imports]

# Uncomment this to configure the site name of your relate instance.
# If not configured, "RELATE" will be used as default value.
Expand Down
4 changes: 1 addition & 3 deletions prairietest/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@
from django.utils.safestring import mark_safe
from typing_extensions import override

from accounts.models import User
from accounts.models import User # ruff:ignore[typing-only-first-party-import]
from course.constants import ParticipationPermission as PPerm
from prairietest.models import AllowEvent, DenyEvent, Facility, MostRecentDenyEvent


if TYPE_CHECKING:
from django.db.models import QuerySet

from accounts.models import User


class FacilityAdminForm(forms.ModelForm):
class Meta:
Expand Down
Loading
Loading