Skip to content

Commit

Permalink
Fix linters deprecation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vrigal committed Oct 3, 2024
1 parent 4607b46 commit de353ca
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from django.conf import settings
from typing import Callable
from collections.abc import Callable

from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE
from treeherder.config.settings import BZ_DATETIME_FORMAT
Expand Down
3 changes: 1 addition & 2 deletions treeherder/etl/perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
from datetime import datetime
from hashlib import sha1
from typing import Optional

import simplejson as json

Expand Down Expand Up @@ -119,7 +118,7 @@ def _test_should_alert_based_on(


def _test_should_gather_replicates_based_on(
repository: Repository, suite_name: str, replicates: Optional[list] = None
repository: Repository, suite_name: str, replicates: list | None
) -> bool:
"""
Determine if we should gather/ingest replicates. Currently, it's
Expand Down
3 changes: 1 addition & 2 deletions treeherder/perf/auto_perf_sheriffing/backfill_reports.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from datetime import timedelta, datetime
from itertools import zip_longest, groupby
from typing import Optional

import simplejson as json
from django.db.models import QuerySet, Q, F
Expand Down Expand Up @@ -87,7 +86,7 @@ def initial_culprit_job(alert):

def parent_or_sibling_from(
alert_group: list[PerformanceAlert],
) -> Optional[PerformanceAlert]:
) -> PerformanceAlert | None:
if len(alert_group) == 0:
return None

Expand Down
3 changes: 1 addition & 2 deletions treeherder/perf/auto_perf_sheriffing/backfill_tool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from django.core.exceptions import ObjectDoesNotExist
from typing import Union

from treeherder.model.models import Job
from treeherder.perf.exceptions import CannotBackfillError
Expand All @@ -14,7 +13,7 @@ class BackfillTool:
def __init__(self, taskcluster_model: TaskclusterModel):
self.__taskcluster = taskcluster_model

def backfill_job(self, job: Union[Job, str]) -> str:
def backfill_job(self, job: Job | str) -> str:
if not isinstance(job, Job):
job = self._fetch_job_by_id(job)

Expand Down
6 changes: 2 additions & 4 deletions treeherder/perf/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from abc import ABC, abstractmethod
import urllib.parse

from typing import Union, Optional

from django.conf import settings
from treeherder.perf.models import (
BackfillRecord,
Expand Down Expand Up @@ -40,7 +38,7 @@ class EmailWriter(ABC):
def __init__(self):
self._email = Email()

def prepare_new_email(self, must_mention: Union[list[object], object]) -> dict:
def prepare_new_email(self, must_mention: list[object] | object) -> dict:
"""
Template method
"""
Expand Down Expand Up @@ -192,7 +190,7 @@ def __build_push_range_cell_text(alert: PerformanceAlert) -> str:
return f"{repository_name}:{previous_push}:{push}"

@staticmethod
def __escape_markdown(text: str) -> Optional[str]:
def __escape_markdown(text: str) -> str | None:
"""
Mostly copied "Example 2" from https://www.programcreek.com/python/?CodeExample=escape+markdown
"""
Expand Down
7 changes: 3 additions & 4 deletions treeherder/perf/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from datetime import datetime
import json
from typing import Optional
from functools import reduce

from django.contrib.auth.models import User
Expand Down Expand Up @@ -521,7 +520,7 @@ class PerformanceAlert(models.Model):
manually_created = models.BooleanField(default=False)

@property
def initial_culprit_job(self) -> Optional[Job]:
def initial_culprit_job(self) -> Job | None:
if hasattr(self, "__initial_culprit_job"):
return self.__initial_culprit_job

Expand Down Expand Up @@ -720,7 +719,7 @@ def platform(self) -> MachinePlatform:
return self.alert.series_signature.platform

@property
def job_symbol(self) -> Optional[str]:
def job_symbol(self) -> str | None:
if not all([self.job_tier, self.job_group, self.job_type]):
return None

Expand Down Expand Up @@ -845,7 +844,7 @@ class Meta:
db_table = "performance_settings"


def deepgetattr(obj: object, attr_chain: str) -> Optional[object]:
def deepgetattr(obj: object, attr_chain: str) -> object | None:
"""Recursively follow an attribute chain to get the final value.
@param attr_chain: e.g. 'repository.name', 'job_type', 'record.platform.architecture' etc
Expand Down
5 changes: 2 additions & 3 deletions treeherder/perf/sheriffing_criteria/criteria_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from multiprocessing import cpu_count
from multiprocessing.pool import Pool, ThreadPool, AsyncResult
import time
from typing import Union

from datetime import datetime, timedelta

Expand All @@ -22,8 +21,8 @@ class CriteriaRecord:
Framework: str
Suite: str
Test: str
EngineerTraction: Union[float, str]
FixRatio: Union[float, str]
EngineerTraction: float | str
FixRatio: float | str
TotalAlerts: int
LastUpdatedOn: datetime
AllowSync: bool
Expand Down

0 comments on commit de353ca

Please sign in to comment.