Skip to content

Commit ed1b70f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bd16d2b commit ed1b70f

File tree

10 files changed

+34
-42
lines changed

10 files changed

+34
-42
lines changed

ckeditor/serializers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import math
22
from time import time
3-
from typing import Optional
43

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

1312
token = serializers.SerializerMethodField()
1413

15-
def get_token(self, _value) -> Optional[str]:
14+
def get_token(self, _value) -> str | None:
1615
"""Get the JWT token"""
1716
if settings.CKEDITOR_SECRET_KEY and settings.CKEDITOR_ENVIRONMENT_ID:
1817
payload = {

learning_resources/content_summarizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Annotated, Optional
2+
from typing import Annotated
33

44
from django.conf import settings
55
from django.db import transaction
@@ -67,8 +67,8 @@ def _can_process_content_file(self, content_file: ContentFile) -> bool:
6767
def get_unprocessed_content_file_ids(
6868
self,
6969
overwrite,
70-
learning_resource_ids: Optional[list[int]] = None,
71-
content_file_ids: Optional[list[int]] = None,
70+
learning_resource_ids: list[int] | None = None,
71+
content_file_ids: list[int] | None = None,
7272
) -> list[int]:
7373
"""
7474
Get Ids of unprocessed content files with applied filters.

learning_resources/etl/posthog.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from collections.abc import Generator
77
from datetime import UTC, datetime
88
from http import HTTPStatus
9-
from typing import Optional
109
from urllib.parse import urljoin
1110

1211
import requests
@@ -32,16 +31,16 @@ class PostHogEvent:
3231
event: str
3332
properties: str
3433
timestamp: datetime
35-
distinct_id: Optional[str] = None
36-
elements_chain: Optional[str] = None
37-
created_at: Optional[datetime] = None
38-
dollar_session_id: Optional[str] = None
39-
dollar_window_id: Optional[str] = None
40-
dollar_group_0: Optional[str] = None
41-
dollar_group_1: Optional[str] = None
42-
dollar_group_2: Optional[str] = None
43-
dollar_group_3: Optional[str] = None
44-
dollar_group_4: Optional[str] = None
34+
distinct_id: str | None = None
35+
elements_chain: str | None = None
36+
created_at: datetime | None = None
37+
dollar_session_id: str | None = None
38+
dollar_window_id: str | None = None
39+
dollar_group_0: str | None = None
40+
dollar_group_1: str | None = None
41+
dollar_group_2: str | None = None
42+
dollar_group_3: str | None = None
43+
dollar_group_4: str | None = None
4544

4645

4746
@dataclasses.dataclass

learning_resources/etl/utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_olx_test_docs():
6363
],
6464
cwd=temp,
6565
)
66-
check_call( # noqa: S603
66+
check_call(
6767
["tar", "xf", "content-devops-0001.tar.gz"], # noqa: S607
6868
cwd=temp,
6969
)

learning_resources/etl/youtube.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
from collections.abc import Generator
55
from datetime import timedelta
6-
from typing import Optional
76

87
import googleapiclient.errors
98
import requests
@@ -351,7 +350,7 @@ def validate_channel_configs(channel_configs: dict) -> list[str]:
351350
return errors
352351

353352

354-
def get_youtube_channel_configs(*, channel_ids: Optional[str] = None) -> list[dict]:
353+
def get_youtube_channel_configs(*, channel_ids: str | None = None) -> list[dict]:
355354
"""
356355
Fetch youtube channel configs from github
357356
@@ -382,7 +381,7 @@ def get_youtube_channel_configs(*, channel_ids: Optional[str] = None) -> list[di
382381
return channel_configs
383382

384383

385-
def extract(*, channel_ids: Optional[str] = None) -> Generator[tuple, None, None]:
384+
def extract(*, channel_ids: str | None = None) -> Generator[tuple, None, None]:
386385
"""
387386
Return video data for all videos in channels' playlists
388387
@@ -496,8 +495,8 @@ def transform(extracted_channels: iter) -> Generator[dict, None, None]:
496495

497496
def get_youtube_videos_for_transcripts_job(
498497
*,
499-
created_after: Optional[str] = None,
500-
created_minutes: Optional[str] = None,
498+
created_after: str | None = None,
499+
created_minutes: str | None = None,
501500
overwrite: bool = False,
502501
) -> list[LearningResource]:
503502
"""

learning_resources/tasks.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import logging
66
from datetime import UTC, datetime
7-
from typing import Optional
87

98
import boto3
109
import celery
@@ -306,11 +305,11 @@ def get_ocw_courses(
306305
def get_ocw_data( # noqa: PLR0913
307306
self,
308307
*,
309-
force_overwrite: Optional[bool] = False,
310-
course_url_substring: Optional[str] = None,
311-
utc_start_timestamp: Optional[datetime] = None,
312-
prefix: Optional[str] = None,
313-
skip_content_files: Optional[bool] = settings.OCW_SKIP_CONTENT_FILES,
308+
force_overwrite: bool | None = False,
309+
course_url_substring: str | None = None,
310+
utc_start_timestamp: datetime | None = None,
311+
prefix: str | None = None,
312+
skip_content_files: bool | None = settings.OCW_SKIP_CONTENT_FILES,
314313
):
315314
"""
316315
Task to sync OCW Next course data with database

main/features.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import logging
66
from enum import StrEnum
77
from functools import wraps
8-
from typing import Optional
98

109
import posthog
1110
from django.conf import settings
@@ -76,7 +75,7 @@ def generate_cache_key(key: str, unique_id: str, person_properties: dict) -> str
7675
)
7776

7877

79-
def get_all_feature_flags(opt_unique_id: Optional[str] = None):
78+
def get_all_feature_flags(opt_unique_id: str | None = None):
8079
"""
8180
Get the set of all feature flags
8281
"""
@@ -98,8 +97,8 @@ def get_all_feature_flags(opt_unique_id: Optional[str] = None):
9897

9998
def is_enabled(
10099
name: str,
101-
default: Optional[bool] = None,
102-
opt_unique_id: Optional[str] = None,
100+
default: bool | None = None,
101+
opt_unique_id: str | None = None,
103102
) -> bool:
104103
"""
105104
Return True if the feature flag is enabled
@@ -149,7 +148,7 @@ def is_enabled(
149148
)
150149

151150

152-
def if_feature_enabled(name: str, default: Optional[bool] = None):
151+
def if_feature_enabled(name: str, default: bool | None = None):
153152
"""
154153
Wrapper that results in a no-op if the given feature isn't enabled, and otherwise
155154
runs the wrapped function as normal.

main/telemetry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""OpenTelemetry initialization and configuration for Learn AI."""
22

33
import logging
4-
from typing import Optional
54

65
from django.conf import settings
76
from opentelemetry import trace
@@ -21,7 +20,7 @@
2120
log = logging.getLogger(__name__)
2221

2322

24-
def configure_opentelemetry() -> Optional[TracerProvider]:
23+
def configure_opentelemetry() -> TracerProvider | None:
2524
"""
2625
Configure OpenTelemetry with appropriate instrumentations and exporters.
2726
Returns the tracer provider if configured, None otherwise.

news_events/etl/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from dataclasses import dataclass
66
from datetime import UTC, datetime
77
from time import mktime, struct_time
8-
from typing import Optional
98
from zoneinfo import ZoneInfo
109

1110
import dateparser
@@ -22,10 +21,10 @@
2221

2322
@dataclass
2423
class FormattedTime:
25-
hour: Optional[str]
26-
minute: Optional[str]
27-
ampm: Optional[str]
28-
tz: Optional[str]
24+
hour: str | None
25+
minute: str | None
26+
ampm: str | None
27+
tz: str | None
2928

3029

3130
def get_soup(url: str) -> Soup:

widgets/serializers/widget_instance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""WidgetInstnace serializer"""
22

3-
from typing import Optional
43

54
from rest_framework import serializers
65

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

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

0 commit comments

Comments
 (0)