Skip to content

[pre-commit.ci] pre-commit autoupdate #2315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ repos:
- "config/keycloak/realms/ol-local-realm.json"
additional_dependencies: ["gibberish-detector"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.13"
rev: "v0.12.2"
hooks:
- id: ruff-format
- id: ruff
Expand Down
3 changes: 1 addition & 2 deletions ckeditor/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import math
from time import time
from typing import Optional

import jwt
from django.conf import settings
Expand All @@ -12,7 +11,7 @@ class CKEditorSettingsSerializer(serializers.Serializer):

token = serializers.SerializerMethodField()

def get_token(self, _value) -> Optional[str]:
def get_token(self, _value) -> str | None:
"""Get the JWT token"""
if settings.CKEDITOR_SECRET_KEY and settings.CKEDITOR_ENVIRONMENT_ID:
payload = {
Expand Down
6 changes: 3 additions & 3 deletions learning_resources/content_summarizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Annotated, Optional
from typing import Annotated

from django.conf import settings
from django.db import transaction
Expand Down Expand Up @@ -67,8 +67,8 @@ def _can_process_content_file(self, content_file: ContentFile) -> bool:
def get_unprocessed_content_file_ids(
self,
overwrite,
learning_resource_ids: Optional[list[int]] = None,
content_file_ids: Optional[list[int]] = None,
learning_resource_ids: list[int] | None = None,
content_file_ids: list[int] | None = None,
) -> list[int]:
"""
Get Ids of unprocessed content files with applied filters.
Expand Down
21 changes: 10 additions & 11 deletions learning_resources/etl/posthog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections.abc import Generator
from datetime import UTC, datetime
from http import HTTPStatus
from typing import Optional
from urllib.parse import urljoin

import requests
Expand All @@ -32,16 +31,16 @@ class PostHogEvent:
event: str
properties: str
timestamp: datetime
distinct_id: Optional[str] = None
elements_chain: Optional[str] = None
created_at: Optional[datetime] = None
dollar_session_id: Optional[str] = None
dollar_window_id: Optional[str] = None
dollar_group_0: Optional[str] = None
dollar_group_1: Optional[str] = None
dollar_group_2: Optional[str] = None
dollar_group_3: Optional[str] = None
dollar_group_4: Optional[str] = None
distinct_id: str | None = None
elements_chain: str | None = None
created_at: datetime | None = None
dollar_session_id: str | None = None
dollar_window_id: str | None = None
dollar_group_0: str | None = None
dollar_group_1: str | None = None
dollar_group_2: str | None = None
dollar_group_3: str | None = None
dollar_group_4: str | None = None


@dataclasses.dataclass
Expand Down
2 changes: 1 addition & 1 deletion learning_resources/etl/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_olx_test_docs():
],
cwd=temp,
)
check_call( # noqa: S603
check_call(
["tar", "xf", "content-devops-0001.tar.gz"], # noqa: S607
cwd=temp,
)
Expand Down
9 changes: 4 additions & 5 deletions learning_resources/etl/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
from collections.abc import Generator
from datetime import timedelta
from typing import Optional

import googleapiclient.errors
import requests
Expand Down Expand Up @@ -351,7 +350,7 @@ def validate_channel_configs(channel_configs: dict) -> list[str]:
return errors


def get_youtube_channel_configs(*, channel_ids: Optional[str] = None) -> list[dict]:
def get_youtube_channel_configs(*, channel_ids: str | None = None) -> list[dict]:
"""
Fetch youtube channel configs from github

Expand Down Expand Up @@ -382,7 +381,7 @@ def get_youtube_channel_configs(*, channel_ids: Optional[str] = None) -> list[di
return channel_configs


def extract(*, channel_ids: Optional[str] = None) -> Generator[tuple, None, None]:
def extract(*, channel_ids: str | None = None) -> Generator[tuple, None, None]:
"""
Return video data for all videos in channels' playlists

Expand Down Expand Up @@ -496,8 +495,8 @@ def transform(extracted_channels: iter) -> Generator[dict, None, None]:

def get_youtube_videos_for_transcripts_job(
*,
created_after: Optional[str] = None,
created_minutes: Optional[str] = None,
created_after: str | None = None,
created_minutes: str | None = None,
overwrite: bool = False,
) -> list[LearningResource]:
"""
Expand Down
11 changes: 5 additions & 6 deletions learning_resources/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
from datetime import UTC, datetime
from typing import Optional

import boto3
import celery
Expand Down Expand Up @@ -306,11 +305,11 @@ def get_ocw_courses(
def get_ocw_data( # noqa: PLR0913
self,
*,
force_overwrite: Optional[bool] = False,
course_url_substring: Optional[str] = None,
utc_start_timestamp: Optional[datetime] = None,
prefix: Optional[str] = None,
skip_content_files: Optional[bool] = settings.OCW_SKIP_CONTENT_FILES,
force_overwrite: bool | None = False,
course_url_substring: str | None = None,
utc_start_timestamp: datetime | None = None,
prefix: str | None = None,
skip_content_files: bool | None = settings.OCW_SKIP_CONTENT_FILES,
):
"""
Task to sync OCW Next course data with database
Expand Down
9 changes: 4 additions & 5 deletions main/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
from enum import StrEnum
from functools import wraps
from typing import Optional

import posthog
from django.conf import settings
Expand Down Expand Up @@ -76,7 +75,7 @@ def generate_cache_key(key: str, unique_id: str, person_properties: dict) -> str
)


def get_all_feature_flags(opt_unique_id: Optional[str] = None):
def get_all_feature_flags(opt_unique_id: str | None = None):
"""
Get the set of all feature flags
"""
Expand All @@ -98,8 +97,8 @@ def get_all_feature_flags(opt_unique_id: Optional[str] = None):

def is_enabled(
name: str,
default: Optional[bool] = None,
opt_unique_id: Optional[str] = None,
default: bool | None = None,
opt_unique_id: str | None = None,
) -> bool:
"""
Return True if the feature flag is enabled
Expand Down Expand Up @@ -149,7 +148,7 @@ def is_enabled(
)


def if_feature_enabled(name: str, default: Optional[bool] = None):
def if_feature_enabled(name: str, default: bool | None = None):
"""
Wrapper that results in a no-op if the given feature isn't enabled, and otherwise
runs the wrapped function as normal.
Expand Down
3 changes: 1 addition & 2 deletions main/telemetry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""OpenTelemetry initialization and configuration for Learn AI."""

import logging
from typing import Optional

from django.conf import settings
from opentelemetry import trace
Expand All @@ -21,7 +20,7 @@
log = logging.getLogger(__name__)


def configure_opentelemetry() -> Optional[TracerProvider]:
def configure_opentelemetry() -> TracerProvider | None:
"""
Configure OpenTelemetry with appropriate instrumentations and exporters.
Returns the tracer provider if configured, None otherwise.
Expand Down
9 changes: 4 additions & 5 deletions news_events/etl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dataclasses import dataclass
from datetime import UTC, datetime
from time import mktime, struct_time
from typing import Optional
from zoneinfo import ZoneInfo

import dateparser
Expand All @@ -22,10 +21,10 @@

@dataclass
class FormattedTime:
hour: Optional[str]
minute: Optional[str]
ampm: Optional[str]
tz: Optional[str]
hour: str | None
minute: str | None
ampm: str | None
tz: str | None


def get_soup(url: str) -> Soup:
Expand Down
3 changes: 1 addition & 2 deletions widgets/serializers/widget_instance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""WidgetInstnace serializer"""

from typing import Optional

from rest_framework import serializers

Expand Down Expand Up @@ -67,7 +66,7 @@ def get_configuration(self, instance) -> dict:
"""Returns the configuration to serialize""" # noqa: D401
return instance.configuration

def get_json(self, instance) -> Optional[dict]: # pylint: disable=unused-argument # noqa: ARG002
def get_json(self, instance) -> dict | None: # pylint: disable=unused-argument # noqa: ARG002
"""Renders the widget to json based on configuration""" # noqa: D401
return None

Expand Down
Loading