Skip to content
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
4 changes: 2 additions & 2 deletions api/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ def add_project(self): # type: ignore[no-untyped-def]
if self.environment and self.project is None:
self.project = self.environment.project

@hook(BEFORE_CREATE) # type: ignore[misc]
@hook(BEFORE_CREATE)
def add_created_date(self) -> None:
if not self.created_date:
self.created_date = timezone.now()

@hook( # type: ignore[misc]
@hook(
AFTER_CREATE,
priority=priority.HIGHEST_PRIORITY,
when="environment_document_updated",
Expand Down
16 changes: 8 additions & 8 deletions api/environments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,30 @@ class Environment(
class Meta:
ordering = ["id"]

@hook(AFTER_CREATE) # type: ignore[misc]
@hook(AFTER_CREATE)
def create_feature_states(self) -> None:
FeatureState.create_initial_feature_states_for_environment(environment=self)

@hook(AFTER_UPDATE) # type: ignore[misc]
@hook(AFTER_UPDATE)
def clear_environment_cache(self) -> None:
# TODO: this could rebuild the cache itself (using an async task)
environment_cache.delete_many(
[self.initial_value("api_key"), *[eak.key for eak in self.api_keys.all()]]
)

@hook(AFTER_UPDATE, when="api_key", has_changed=True) # type: ignore[misc]
@hook(AFTER_UPDATE, when="api_key", has_changed=True)
def update_environment_document_cache(self) -> None:
environment_document_cache.delete(self.initial_value("api_key"))
self.write_environment_documents(self.id)

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def delete_from_dynamo(self) -> None:
if self.project.enable_dynamo_db and environment_wrapper.is_enabled:
from environments.tasks import delete_environment_from_dynamo

delete_environment_from_dynamo.delay(args=(self.api_key, self.id))

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def delete_environment_document_from_cache(self) -> None:
if (
settings.CACHE_ENVIRONMENT_DOCUMENT_MODE
Expand All @@ -199,7 +199,7 @@ def delete_environment_document_from_cache(self) -> None:

# Use the BEFORE_SAVE hook instead of BEFORE_CREATE to account for the logic in the
# Environment.clone() method
@hook(BEFORE_SAVE, when="pk", is_now=None) # type: ignore[misc]
@hook(BEFORE_SAVE, when="pk", is_now=None)
def enable_v2_versioning(self) -> None:
if self.use_v2_feature_versioning:
# if the environment has already been created with versioning enabled,
Expand Down Expand Up @@ -727,7 +727,7 @@ def send_to_dynamo(self): # type: ignore[no-untyped-def]
def delete_from_dynamo(self): # type: ignore[no-untyped-def]
environment_api_key_wrapper.delete_api_key(self.key)

@hook(AFTER_SAVE) # type: ignore[misc]
@hook(AFTER_SAVE)
def sync_to_ingestion_on_save(self) -> None:
from experimentation.models import WarehouseConnection
from experimentation.tasks import write_environment_ingestion_key
Expand All @@ -740,7 +740,7 @@ def sync_to_ingestion_on_save(self) -> None:
kwargs={"environment_api_key_id": self.id},
)

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def remove_from_ingestion_on_delete(self) -> None:
from experimentation.models import WarehouseConnection
from experimentation.tasks import remove_environment_ingestion_key
Expand Down
4 changes: 2 additions & 2 deletions api/experimentation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class Meta:
),
]

@hook(AFTER_CREATE) # type: ignore[misc]
@hook(AFTER_CREATE)
def sync_to_ingestion_on_create(self) -> None:
from experimentation.tasks import write_environment_ingestion_keys

write_environment_ingestion_keys.delay(
kwargs={"environment_id": self.environment_id},
)

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def sync_to_ingestion_on_delete(self) -> None:
from experimentation.tasks import remove_environment_ingestion_keys

Expand Down
4 changes: 2 additions & 2 deletions api/features/feature_external_resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def notify_github_on_link(self): # type: ignore[no-untyped-def]
feature_states=feature_states,
)

@hook(BEFORE_DELETE, when="type", is_now="GITHUB_ISSUE") # type: ignore[misc]
@hook(BEFORE_DELETE, when="type", is_now="GITHUB_PR") # type: ignore[misc]
@hook(BEFORE_DELETE, when="type", is_now="GITHUB_ISSUE")
@hook(BEFORE_DELETE, when="type", is_now="GITHUB_PR")
def notify_github_on_unlink(self) -> None:
# Add a comment to GitHub Issue/PR when feature is unlinked to the GH external resource
if (
Expand Down
8 changes: 4 additions & 4 deletions api/features/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Meta:
# TODO: after upgrade to Django 4.0 use UniqueConstraint()
ordering = ("id",) # explicit ordering to prevent pagination warnings

@hook(AFTER_SAVE) # type: ignore[misc]
@hook(AFTER_SAVE)
def create_github_comment(self) -> None:
from integrations.github.github import call_github_task

Expand All @@ -159,7 +159,7 @@ def create_github_comment(self) -> None:
feature_states=None,
)

@hook(AFTER_SAVE) # type: ignore[misc]
@hook(AFTER_SAVE)
def create_gitlab_comment(self) -> None:
from features.feature_external_resources.models import (
GITLAB_RESOURCE_TYPES,
Expand All @@ -182,7 +182,7 @@ def create_gitlab_comment(self) -> None:
def create_feature_states(self): # type: ignore[no-untyped-def]
FeatureState.create_initial_feature_states_for_feature(feature=self)

@hook(AFTER_SAVE) # type: ignore[misc]
@hook(AFTER_SAVE)
def delete_identity_overrides(self) -> None:
# Note that we have to use conditional logic on self.deleted_at inside
# the hook method because the django-lifecycle logic for when / was / is_not
Expand Down Expand Up @@ -439,7 +439,7 @@ def get_delete_log_message(self, history_instance) -> typing.Optional[str]: # t
def _get_environment(self) -> "Environment":
return self.environment

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def create_github_comment(self) -> None:
from integrations.github.github import call_github_task

Expand Down
2 changes: 1 addition & 1 deletion api/features/release_pipelines/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class PhasedRolloutState(LifecycleModelMixin, models.Model): # type: ignore[mis
is_rollout_complete = models.BooleanField(default=False)
last_updated_at = models.DateTimeField(auto_now=True)

@hook(BEFORE_CREATE) # type: ignore[misc]
@hook(BEFORE_CREATE)
def set_initial_split(self) -> None:
if self.current_split is None:
self.current_split = self.initial_split
Expand Down
2 changes: 1 addition & 1 deletion api/features/workflows/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_audit_log_for_related_feature_state(self): # type: ignore[no-untyped
args=(feature_state.id,),
)

@hook(BEFORE_DELETE) # type: ignore[misc]
@hook(BEFORE_DELETE)
def prevent_change_request_delete_if_committed(self) -> None:
# In the workflows-logic module, we prevent change requests from being
# deleted but, since this can have unexpected effects on published
Expand Down
6 changes: 3 additions & 3 deletions api/integrations/github/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Meta:
]
ordering = ("id",)

@hook(BEFORE_DELETE) # type: ignore[misc]
@hook(BEFORE_DELETE)
def delete_feature_external_resources(
self,
) -> None:
Expand All @@ -93,8 +93,8 @@ def delete_feature_external_resources(
url__regex=pattern,
).delete()

@hook(AFTER_CREATE) # type: ignore[misc]
@hook(AFTER_UPDATE, when="tagging_enabled", has_changed=True, was=False) # type: ignore[misc]
@hook(AFTER_CREATE)
@hook(AFTER_UPDATE, when="tagging_enabled", has_changed=True, was=False)
def create_github_tags(
self,
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions api/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def clear_environments_cache(self): # type: ignore[no-untyped-def]
list(self.environments.values_list("api_key", flat=True))
)

@hook( # type: ignore[misc]
@hook(
AFTER_SAVE,
when="edge_v2_migration_status",
has_changed=True,
Expand All @@ -181,7 +181,7 @@ def write_to_dynamo(self): # type: ignore[no-untyped-def]
def clean_up_dynamo(self): # type: ignore[no-untyped-def]
DynamoProjectMetadata(self.id).delete() # type: ignore[no-untyped-call]

@hook(AFTER_DELETE) # type: ignore[misc]
@hook(AFTER_DELETE)
def handle_cascade_delete(self) -> None:
handle_cascade_delete.delay(kwargs={"project_id": self.id})

Expand Down
4 changes: 2 additions & 2 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies = [
"drf-spectacular>=0.28.0,<0.29.0",
"sentry-sdk>=2.24.1,<3",
"environs>=14.1.1,<15.0.0",
"django-lifecycle>=1.2.4,<1.3.0",
"django-lifecycle>=1.2.5,<1.3.0",
"drf-writable-nested>=0.6.2,<0.7.0",
"django-filter>=2.4.0,<2.5.0",
"flagsmith-flag-engine>=10.1.0,<11.0.0",
Expand Down Expand Up @@ -212,7 +212,7 @@ override-dependencies = [
"django-extensions==3.2.3",
"django-filter==2.4.0",
"django-health-check==3.18.2",
"django-lifecycle==1.2.4",
"django-lifecycle==1.2.5",
"django-multiselectfield==1.0.1",
"django-oauth-toolkit==3.1.0",
"django-ordered-model==3.4.3",
Expand Down
2 changes: 1 addition & 1 deletion api/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def superuser(self, value: bool) -> None:
self.is_staff = value
self.is_superuser = value

@hook(AFTER_SAVE, condition=(WhenFieldHasChanged("email", has_changed=True))) # type: ignore[misc]
@hook(AFTER_SAVE, condition=(WhenFieldHasChanged("email", has_changed=True)))
def send_warning_email(self) -> None:
from users.tasks import send_email_changed_notification_email

Expand Down
Loading