Skip to content

Commit d317078

Browse files
[pre-commit.ci] pre-commit autoupdate (#1820)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/scop/pre-commit-shfmt: v3.10.0-1 → v3.10.0-2](scop/pre-commit-shfmt@v3.10.0-1...v3.10.0-2) - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.9.1](astral-sh/ruff-pre-commit@v0.7.2...v0.9.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix some linting errors * fixing format specifiers * fixing format specifiers --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: shankar ambady <[email protected]>
1 parent a4802a1 commit d317078

37 files changed

+95
-103
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
html,
4242
]
4343
- repo: https://github.com/scop/pre-commit-shfmt
44-
rev: v3.10.0-1
44+
rev: v3.10.0-2
4545
hooks:
4646
- id: shfmt
4747
- repo: https://github.com/adrienverge/yamllint.git
@@ -74,7 +74,7 @@ repos:
7474
- ".*/generated/"
7575
additional_dependencies: ["gibberish-detector"]
7676
- repo: https://github.com/astral-sh/ruff-pre-commit
77-
rev: "v0.7.2"
77+
rev: "v0.9.1"
7878
hooks:
7979
- id: ruff-format
8080
- id: ruff

ai_chat/factories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ChatMessageFactory(factory.Factory):
1111

1212
role = FuzzyChoice(MessageRole.USER, MessageRole.ASSISTANT)
1313
content = factory.Faker("sentence")
14-
id = name = factory.Sequence(lambda n: "%d" % n)
15-
index = factory.Sequence(lambda n: "%d" % n)
14+
id = name = factory.Sequence(lambda n: str(n))
15+
index = factory.Sequence(lambda n: str(n))
1616

1717
class Meta:
1818
model = ChatMessage

authentication/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def process_exception(self, request, exception):
3838

3939
if url:
4040
url += (
41-
"?" in url and "&" or "?"
41+
("?" in url and "&") or "?"
4242
) + f"message={quote(message)}&backend={backend_name}"
4343
return redirect(url)
4444
return None

channels/serializers_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_create_channel(base_channel_data, channel_detail, channel_type):
155155
"""
156156
paths = sorted(
157157
(p.learning_resource for p in LearningPathFactory.create_batch(2)),
158-
key=lambda list: list.id, # noqa: A002
158+
key=lambda lst: lst.id,
159159
reverse=True,
160160
)
161161

conftest.py

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

1212

1313
@pytest.fixture(autouse=True)
14-
def prevent_requests(mocker, request): # noqa: PT004
14+
def prevent_requests(mocker, request):
1515
"""Patch requests to error on request by default"""
1616
if "mocked_responses" in request.fixturenames:
1717
return

fixtures/aws.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111

1212
@pytest.fixture(autouse=True)
13-
def silence_s3_logging(): # noqa: PT004
13+
def silence_s3_logging():
1414
"""Only show S3 errors"""
1515
logging.getLogger("botocore").setLevel(logging.ERROR)
1616

1717

1818
@pytest.fixture
19-
def mock_s3_fixture(): # noqa: PT004
19+
def mock_s3_fixture():
2020
"""Mock the S3 fixture for the duration of the test"""
2121
with mock_aws():
2222
yield

fixtures/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323

2424
@pytest.fixture(autouse=True)
25-
def silence_factory_logging(): # noqa: PT004
25+
def silence_factory_logging():
2626
"""Only show factory errors"""
2727
logging.getLogger("factory").setLevel(logging.ERROR)
2828

2929

3030
@pytest.fixture(autouse=True)
31-
def warnings_as_errors(): # noqa: PT004
31+
def warnings_as_errors():
3232
"""
3333
Convert warnings to errors. This should only affect unit tests, letting pylint and other plugins
3434
raise DeprecationWarnings without erroring.
@@ -53,7 +53,7 @@ def warnings_as_errors(): # noqa: PT004
5353

5454

5555
@pytest.fixture
56-
def randomness(): # noqa: PT004
56+
def randomness():
5757
"""Ensure a fixed seed for factoryboy"""
5858
factory.fuzzy.reseed_random("happy little clouds")
5959

@@ -95,7 +95,7 @@ def mocked_responses():
9595

9696

9797
@pytest.fixture
98-
def offeror_featured_lists(): # noqa: PT004
98+
def offeror_featured_lists():
9999
"""Generate featured offeror lists for testing"""
100100
for offered_by in OfferedBy.names():
101101
offeror = LearningResourceOfferorFactory.create(code=offered_by)

learning_resources/etl/loaders_test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ def test_load_course( # noqa: PLR0913,PLR0912,PLR0915
374374
"start_date": old_run.start_date,
375375
"end_date": old_run.end_date,
376376
"prices": [
377-
{"amount": Decimal(30.00), "currency": CURRENCY_USD},
378-
{"amount": Decimal(120.00), "currency": CURRENCY_USD},
377+
{"amount": Decimal("30.00"), "currency": CURRENCY_USD},
378+
{"amount": Decimal("120.00"), "currency": CURRENCY_USD},
379379
],
380380
},
381381
{
@@ -384,8 +384,8 @@ def test_load_course( # noqa: PLR0913,PLR0912,PLR0915
384384
"start_date": start_date,
385385
"end_date": run.end_date,
386386
"prices": [
387-
{"amount": Decimal(0.00), "currency": CURRENCY_USD},
388-
{"amount": Decimal(49.00), "currency": CURRENCY_USD},
387+
{"amount": Decimal("0.00"), "currency": CURRENCY_USD},
388+
{"amount": Decimal("49.00"), "currency": CURRENCY_USD},
389389
],
390390
},
391391
]
@@ -403,12 +403,12 @@ def test_load_course( # noqa: PLR0913,PLR0912,PLR0915
403403
)
404404
assert result.next_start_date == expected_next_start_date
405405
assert result.prices == (
406-
[Decimal(0.00), Decimal(49.00)]
406+
[Decimal("0.00"), Decimal("49.00")]
407407
if is_run_published and result.certification
408408
else []
409409
)
410410
assert [price.amount for price in result.resource_prices.all()] == (
411-
[Decimal(0.00), Decimal(49.00)]
411+
[Decimal("0.00"), Decimal("49.00")]
412412
if is_run_published and result.certification
413413
else []
414414
)
@@ -563,9 +563,9 @@ def test_load_duplicate_course(
563563

564564
for key, value in props.items():
565565
assert getattr(result, key) == value, f"Property {key} should equal {value}"
566-
assert (
567-
getattr(saved_course, key) == value
568-
), f"Property {key} should be updated to {value} in the database"
566+
assert getattr(saved_course, key) == value, (
567+
f"Property {key} should be updated to {value} in the database"
568+
)
569569

570570

571571
@pytest.mark.parametrize("unique_url", [True, False])
@@ -695,7 +695,7 @@ def test_load_run(run_exists, status, certification):
695695
if run_exists
696696
else LearningResourceRunFactory.build()
697697
)
698-
prices = [Decimal(70.00), Decimal(20.00)]
698+
prices = [Decimal("70.00"), Decimal("20.00")]
699699
props = model_to_dict(
700700
LearningResourceRunFactory.build(
701701
run_id=learning_resource_run.run_id,
@@ -964,9 +964,9 @@ def test_load_content_file():
964964
assert loaded_file.run == learning_resource_run
965965

966966
for key, value in props.items():
967-
assert (
968-
getattr(loaded_file, key) == value
969-
), f"Property {key} should equal {value}"
967+
assert getattr(loaded_file, key) == value, (
968+
f"Property {key} should equal {value}"
969+
)
970970

971971

972972
def test_load_image():

learning_resources/etl/mitpe_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
2123, 4, 25, 4, 0, tzinfo=datetime.UTC
5656
),
5757
"published": True,
58-
"prices": [{"amount": Decimal(1870), "currency": "USD"}],
58+
"prices": [{"amount": Decimal("1870"), "currency": "USD"}],
5959
"url": "https://professional.mit.edu/course-catalog/comunicacao-persuasiva-pensamento-critico-para-aprimorar-mensagem-portuguese",
6060
"instructors": [{"full_name": "Edward Schiappa"}, {"full_name": ""}],
6161
"format": [Format.asynchronous.name],
@@ -102,7 +102,7 @@
102102
2123, 6, 17, 4, 0, tzinfo=datetime.UTC
103103
),
104104
"published": True,
105-
"prices": [{"amount": Decimal(3600), "currency": "USD"}],
105+
"prices": [{"amount": Decimal("3600"), "currency": "USD"}],
106106
"url": "https://professional.mit.edu/course-catalog/design-thinking-and-innovation-technical-leaders",
107107
"instructors": [
108108
{"full_name": "Blade Kotelly"},
@@ -154,7 +154,7 @@
154154
2123, 7, 6, 4, 0, tzinfo=datetime.UTC
155155
),
156156
"published": True,
157-
"prices": [{"amount": Decimal(1870), "currency": "USD"}],
157+
"prices": [{"amount": Decimal("1870"), "currency": "USD"}],
158158
"url": "https://professional.mit.edu/course-catalog/manufatura-inteligente-producao-na-industria-40-portuguese",
159159
"instructors": [{"full_name": ""}, {"full_name": "Brian Anthony"}],
160160
"format": [Format.asynchronous.name],

learning_resources/etl/mitxonline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def _transform_run(course_run: dict, course: dict) -> dict:
225225
transform_price(price)
226226
for price in sorted(
227227
{
228-
Decimal(0.00),
228+
Decimal("0.00"),
229229
*[
230230
Decimal(price)
231231
for price in [

0 commit comments

Comments
 (0)