Skip to content
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

chore(deps): Bump ruff from 0.7.1 to 0.8.0 in /experimenter #11843

Merged
merged 2 commits into from
Nov 26, 2024
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
4 changes: 2 additions & 2 deletions experimenter/experimenter/experiments/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any

from django import forms
from django.contrib import admin
Expand Down Expand Up @@ -129,7 +129,7 @@ def dehydrate_status_next(self, experiment):
return None
return experiment.status_next

def before_import_row(self, row: Dict[str, Any], row_number=None, **kwargs):
def before_import_row(self, row: dict[str, Any], row_number=None, **kwargs):
owner_id = row.get("owner")

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_features(self, obj):
features = []
for fv in obj.feature_values.all():
feature_value = {
"featureId": fv.feature_config and fv.feature_config.slug or "",
"featureId": (fv.feature_config and fv.feature_config.slug) or "",
"enabled": True, # TODO: Remove after Desktop 104 is no longer supported
"value": {},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_features(self, obj):
features = []
for fv in obj.feature_values.all():
feature_value = {
"featureId": fv.feature_config and fv.feature_config.slug or "",
"featureId": (fv.feature_config and fv.feature_config.slug) or "",
"value": {},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_features(self, obj):
features = []
for fv in obj.feature_values.all():
feature_value = {
"featureId": fv.feature_config and fv.feature_config.slug or "",
"featureId": (fv.feature_config and fv.feature_config.slug) or "",
"enabled": True, # TODO: Remove after Desktop 104 is no longer supported
"value": {},
}
Expand Down
4 changes: 2 additions & 2 deletions experimenter/experimenter/experiments/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass, field
from enum import Enum
from typing import TYPE_CHECKING, Dict, Optional
from typing import TYPE_CHECKING, Optional

from django.conf import settings
from django.db import models
Expand Down Expand Up @@ -65,7 +65,7 @@ class ApplicationConfig:
name: str
slug: str
app_name: str
channel_app_id: Dict[str, str]
channel_app_id: dict[str, str]
default_kinto_collection: str
randomization_unit: str
is_web: bool
Expand Down
17 changes: 8 additions & 9 deletions experimenter/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from decimal import Decimal
from pathlib import Path
from typing import Any, Dict, Optional
from typing import Any, Optional
from urllib.parse import urlencode, urljoin
from uuid import uuid4

Expand Down Expand Up @@ -285,10 +285,10 @@ class NimbusExperiment(NimbusConstants, TargetingConstants, FilterMixin, models.
on_delete=models.SET_NULL,
verbose_name="Reference Branch",
)
published_dto = models.JSONField[Dict[str, Any]](
published_dto = models.JSONField[dict[str, Any]](
"Published DTO", encoder=DjangoJSONEncoder, blank=True, null=True
)
results_data = models.JSONField[Dict[str, Any]](
results_data = models.JSONField[dict[str, Any]](
"Results Data", encoder=DjangoJSONEncoder, blank=True, null=True
)
risk_partner_related = models.BooleanField(
Expand Down Expand Up @@ -1088,11 +1088,10 @@ def live_experiments_in_namespace(self):
@property
def can_edit(self):
return (
self.status == self.Status.DRAFT
and self.publish_status == self.PublishStatus.IDLE
) or (
(
self.status == self.Status.DRAFT
and self.publish_status == self.PublishStatus.IDLE
)
or (
self.is_rollout
and self.status == self.Status.LIVE
and self.publish_status == self.PublishStatus.IDLE
Expand Down Expand Up @@ -1871,7 +1870,7 @@ class NimbusVersionedSchema(models.Model):
schema = models.TextField(blank=True, null=True)

# Desktop-only
set_pref_vars = models.JSONField[Dict[str, str]](null=False, default=dict)
set_pref_vars = models.JSONField[dict[str, str]](null=False, default=dict)
is_early_startup = models.BooleanField(null=False, default=False)

class Meta:
Expand Down Expand Up @@ -1955,7 +1954,7 @@ def current_datetime():
max_length=255, choices=NimbusExperiment.PublishStatus.choices
)
message = models.TextField(blank=True, null=True)
experiment_data = models.JSONField[Dict[str, Any]](
experiment_data = models.JSONField[dict[str, Any]](
encoder=DjangoJSONEncoder, blank=True, null=True
)
published_dto_changed = models.BooleanField(default=False)
Expand Down
3 changes: 2 additions & 1 deletion experimenter/experimenter/features/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import re
from collections.abc import Iterable
from dataclasses import dataclass
from pathlib import Path
from typing import Iterable, Optional
from typing import Optional

import yaml
from django.conf import settings
Expand Down
40 changes: 20 additions & 20 deletions experimenter/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion experimenter/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mozilla-nimbus-schemas = "2024.11.5"
mozilla-metric-config-parser = "^2024.11.1"
django-redis = "^5.4.0"
fontawesomefree = "6.6.0"
ruff = "^0.7.1"
ruff = "^0.8.0"
django = "^5.1"
dockerflow = "^2024.4.1"
django-filter = "^23.5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional
from typing import Optional


class BaseExperimentApplications(Enum):
Expand Down Expand Up @@ -39,8 +39,8 @@ class BaseExperimentAudienceDataClass:

@dataclass
class BaseExperimentMetricsDataClass:
primary_outcomes: Optional[List[str]]
secondary_outcomes: Optional[List[str]]
primary_outcomes: Optional[list[str]]
secondary_outcomes: Optional[list[str]]


@dataclass
Expand All @@ -49,7 +49,7 @@ class BaseExperimentDataClass:
hypothesis: str
application: BaseExperimentApplications
public_description: str
branches: Optional[List[BaseExperimentBranchDataClass]]
branches: Optional[list[BaseExperimentBranchDataClass]]
metrics: BaseExperimentMetricsDataClass
audience: BaseExperimentAudienceDataClass
feature_config_id: str
Expand Down
19 changes: 12 additions & 7 deletions experimenter/tests/integration/nimbus/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import os
import time
from functools import lru_cache
from functools import cache

import requests

Expand Down Expand Up @@ -29,7 +29,7 @@ def load_graphql_data(query):
time.sleep(LOAD_DATA_RETRY_DELAY)


@lru_cache(maxsize=None)
@cache
def load_config_data():
return load_graphql_data(
{
Expand Down Expand Up @@ -146,11 +146,16 @@ def load_targeting_configs(app=BaseExperimentApplications.FIREFOX_DESKTOP.value)
return [
item["value"]
for item in config_data["targetingConfigs"]
if BaseExperimentApplications.FIREFOX_DESKTOP.value in app
and BaseExperimentApplications.FIREFOX_DESKTOP.value in item["applicationValues"]
or BaseExperimentApplications.FIREFOX_DESKTOP.value not in app
and BaseExperimentApplications.FIREFOX_DESKTOP.value
not in item["applicationValues"]
if (
BaseExperimentApplications.FIREFOX_DESKTOP.value in app
and BaseExperimentApplications.FIREFOX_DESKTOP.value
in item["applicationValues"]
)
or (
BaseExperimentApplications.FIREFOX_DESKTOP.value not in app
and BaseExperimentApplications.FIREFOX_DESKTOP.value
not in item["applicationValues"]
)
]


Expand Down