* Enable pyupgrade

* Generated fixes

* Use yield from
This commit is contained in:
Bastien Abadie 2024-07-24 13:05:16 +02:00 коммит произвёл GitHub
Родитель 960c7f4eba
Коммит fe6df07223
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
105 изменённых файлов: 109 добавлений и 243 удалений

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -40,7 +39,7 @@ from code_review_backend.issues.serializers import (
)
class CachedView(object):
class CachedView:
"""Helper to bring DRF caching to GET methods"""
@method_decorator(cache_page(1800))

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -73,9 +72,7 @@ def process_diff(diff: Diff):
issues = [detect_in_patch(issue, lines) for issue in diff.issues.all()]
logging.info(
"Found {} issues in patch for {}".format(
len([i for i in issues if i.in_patch]), diff.id
)
f"Found {len([i for i in issues if i.in_patch])} issues in patch for {diff.id}"
)
Issue.objects.bulk_update(issues, ["in_patch"])
except Exception as e:
@ -98,7 +95,7 @@ class Command(BaseCommand):
diffs = (
Diff.objects.filter(issues__in_patch__isnull=True).order_by("id").distinct()
)
logger.debug("Will process {} diffs".format(diffs.count()))
logger.debug(f"Will process {diffs.count()} diffs")
# Close all DB connection so each process get its own
db.connections.close_all()

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -46,14 +45,12 @@ def generate_issue_links(apps, schema_editor):
)
issues = qs[index * ISSUES_INSERT_SIZE : (index + 1) * ISSUES_INSERT_SIZE]
IssueLink.objects.bulk_create(
(
IssueLink(
issue_id=issue["id"],
diff_id=issue["diff_id"],
revision_id=issue["diff__revision_id"],
)
for issue in issues
IssueLink(
issue_id=issue["id"],
diff_id=issue["diff_id"],
revision_id=issue["diff__revision_id"],
)
for issue in issues
)

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 4.0.5 on 2023-04-14 15:37
from django.db import migrations, models

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -40,7 +39,7 @@ class CompareAPITestCase(APITestCase):
id=i + 1,
phid=f"PHID-DIFF-{i+1}",
review_task_id=f"task-{i}",
mercurial_hash=hashlib.sha1(f"hg {i}".encode("utf-8")).hexdigest(),
mercurial_hash=hashlib.sha1(f"hg {i}".encode()).hexdigest(),
repository=self.repo_try,
)

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -41,7 +40,7 @@ class DiffAPITestCase(APITestCase):
phid=f"PHID-DIFF-{i+1}",
revision_id=(i % 2) + 1,
review_task_id=f"task-{i}",
mercurial_hash=hashlib.sha1(f"hg {i}".encode("utf-8")).hexdigest(),
mercurial_hash=hashlib.sha1(f"hg {i}".encode()).hexdigest(),
repository=self.repo_try,
)

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -20,7 +19,7 @@ class DockerflowEndpointsTestCase(TestCase):
response = self.client.get("/__version__")
self.assertEqual(response.status_code, 200)
with open(f"{settings.BASE_DIR}/version.json", "r") as version_file:
with open(f"{settings.BASE_DIR}/version.json") as version_file:
self.assertEqual(response.json(), json.loads(version_file.read()))
def test_get_heartbeat_debug(self):

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -43,7 +42,7 @@ class StatsAPITestCase(APITestCase):
id=i + 1,
phid=f"PHID-DIFF-{i+1}",
review_task_id=f"task-{i}",
mercurial_hash=hashlib.sha1(f"hg {i}".encode("utf-8")).hexdigest(),
mercurial_hash=hashlib.sha1(f"hg {i}".encode()).hexdigest(),
repository=self.repo_try,
)

Просмотреть файл

@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -14,7 +13,7 @@ from code_review_bot.config import GetAppUserAgent, settings
logger = structlog.get_logger(__name__)
class BackendAPI(object):
class BackendAPI:
"""
API client for our own code-review backend
"""
@ -81,7 +80,7 @@ class BackendAPI(object):
url_post, headers=GetAppUserAgent(), json=data, auth=auth
)
if not response.ok:
logger.warn("Backend rejected the payload: {}".format(response.content))
logger.warn(f"Backend rejected the payload: {response.content}")
return
backend_revision = response.json()
@ -212,8 +211,7 @@ class BackendAPI(object):
resp = requests.get(next_url, auth=auth, headers=GetAppUserAgent())
resp.raise_for_status()
data = resp.json()
for result in data.get("results", []):
yield result
yield from data.get("results", [])
next_url = data.get("next")
def create(self, url_path, data):
@ -239,7 +237,7 @@ class BackendAPI(object):
url_post, headers=GetAppUserAgent(), json=data, auth=auth
)
if not response.ok:
logger.warn("Backend rejected the payload: {}".format(response.content))
logger.warn(f"Backend rejected the payload: {response.content}")
return None
out = response.json()
logger.info("Created item on backend", url=url_post, id=out.get("id"))

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import atexit
import collections
@ -31,10 +29,10 @@ RepositoryConf = collections.namedtuple(
def GetAppUserAgent():
return {"user-agent": "code-review-bot/{}".format(settings.version)}
return {"user-agent": f"code-review-bot/{settings.version}"}
class Settings(object):
class Settings:
def __init__(self):
self.config = {
"cpp_extensions": frozenset([".c", ".cpp", ".cc", ".cxx", ".m", ".mm"]),

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -30,7 +29,7 @@ def hg_run(cmd):
return
text = filter(None, out.decode("utf-8").splitlines())
for line in text:
logger.info("{}: {}".format(name, line))
logger.info(f"{name}: {line}")
# Start process
main_cmd = cmd[0]
@ -46,14 +45,12 @@ def hg_run(cmd):
while proc.poll() is None:
_log_process(proc.stdout, main_cmd)
_log_process(proc.stderr, "{} (err)".format(main_cmd))
_log_process(proc.stderr, f"{main_cmd} (err)")
time.sleep(2)
out, err = proc.communicate()
if proc.returncode != 0:
logger.error(
"Mercurial {} failure".format(main_cmd), out=out, err=err, exc_info=True
)
logger.error(f"Mercurial {main_cmd} failure", out=out, err=err, exc_info=True)
raise hglib.error.CommandError(cmd, proc.returncode, out, err)
return out

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -36,6 +35,6 @@ def get_reporters(configuration):
raise Exception("Missing reporter class {}".format(conf["reporter"]))
out[name] = cls(conf)
except Exception as e:
logger.warning("Failed to create reporter: {}".format(e))
logger.warning(f"Failed to create reporter: {e}")
return out

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -8,7 +7,7 @@ import itertools
from code_review_bot import Level
class Reporter(object):
class Reporter:
"""
Common interface to post reports on a website
Will configure & build reports
@ -34,9 +33,7 @@ class Reporter(object):
out = []
for key in keys:
assert key in configuration, "Missing {} {}".format(
self.__class__.__name__, key
)
assert key in configuration, f"Missing {self.__class__.__name__} {key}"
out.append(configuration[key])
return out

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -40,7 +39,7 @@ class DebugReporter(Reporter):
for task in task_failures:
logger.info("Task failure detected", name=task.name, task=task.id)
for patch in revision.improvement_patches:
logger.info("Patch {}".format(patch))
logger.info(f"Patch {patch}")
# Output json report in public directory
report = {

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -45,9 +44,7 @@ class LandoReporter(Reporter):
nb_publishable_warnings = nb_publishable - nb_publishable_errors
logger.info(
"Publishing warnings to lando for {0} errors and {1} warnings".format(
nb_publishable_errors, nb_publishable_warnings
),
f"Publishing warnings to lando for {nb_publishable_errors} errors and {nb_publishable_warnings} warnings",
revision=revision.phabricator_id,
diff=revision.diff["id"],
)

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -78,7 +77,7 @@ class MailReporter(Reporter):
if len(content) > 102400:
# Content is 102400 chars max
content = content[:102000] + "\n\n... Content max limit reached!"
subject = "[{}] New Static Analysis {}".format(settings.app_channel, revision)
subject = f"[{settings.app_channel}] New Static Analysis {revision}"
for email in self.emails:
self.notify.email(
{

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -40,17 +39,13 @@ class BuildErrorsReporter(Reporter):
), "Revision must have a Phabricator ID and PHID"
assert (
"attachments" in revision.diff
), "Unable to find the commits for revision with phid {}.".format(
revision.phabricator_phid
)
), f"Unable to find the commits for revision with phid {revision.phabricator_phid}."
attachments = revision.diff["attachments"]
if "commits" not in attachments and "commits" not in attachments["commits"]:
logger.info(
"Unable to find the commits for revision with phid {}.".format(
revision.phabricator_phid
)
f"Unable to find the commits for revision with phid {revision.phabricator_phid}."
)
return

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -46,17 +45,15 @@ def main(env):
print("Triggering {} > {}".format(phid, task["title"]))
if phid in skip_phids:
print(">> Skipping, phid {} has already a non-erroneous task".format(phid))
print(f">> Skipping, phid {phid} has already a non-erroneous task")
continue
extra_env = {"ANALYSIS_SOURCE": "phabricator", "ANALYSIS_ID": phid}
task = hooks.triggerHook(
"project-relman", "code-review-{}".format(env), extra_env
)
task = hooks.triggerHook("project-relman", f"code-review-{env}", extra_env)
print(">> New task {}".format(task["status"]["taskId"]))
total += 1
print("Triggered {} tasks".format(total))
print(f"Triggered {total} tasks")
if __name__ == "__main__":

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -26,7 +25,7 @@ from code_review_bot.tasks.base import AnalysisTask
logger = structlog.get_logger(__name__)
class ImprovementPatch(object):
class ImprovementPatch:
"""
An improvement patch built by the bot
"""
@ -36,13 +35,13 @@ class ImprovementPatch(object):
# Build name from analyzer and revision
self.analyzer = analyzer
self.name = "{}-{}.diff".format(self.analyzer.name, patch_name)
self.name = f"{self.analyzer.name}-{patch_name}.diff"
self.content = content
self.url = None
self.path = None
def __str__(self):
return "{}: {}".format(self.analyzer.name, self.url or self.path or self.name)
return f"{self.analyzer.name}: {self.url or self.path or self.name}"
def write(self):
"""
@ -62,7 +61,7 @@ class ImprovementPatch(object):
not settings.taskcluster.local
), "Only publish on online Taskcluster tasks"
self.url = taskcluster.upload_artifact(
"public/patch/{}".format(self.name),
f"public/patch/{self.name}",
self.content.encode(),
content_type="text/plain; charset=utf-8", # Displays instead of download
ttl=timedelta(days=days_ttl - 1),
@ -70,7 +69,7 @@ class ImprovementPatch(object):
logger.info("Improvement patch published", url=self.url)
class Revision(object):
class Revision:
"""
A Phabricator revision to analyze and report on
"""
@ -133,10 +132,10 @@ class Revision(object):
@property
def namespaces(self):
return [
"phabricator.{}".format(self.phabricator_id),
"phabricator.diff.{}".format(self.diff_id),
"phabricator.phabricator_phid.{}".format(self.phabricator_phid),
"phabricator.diffphid.{}".format(self.diff_phid),
f"phabricator.{self.phabricator_id}",
f"phabricator.diff.{self.diff_id}",
f"phabricator.phabricator_phid.{self.phabricator_phid}",
f"phabricator.diffphid.{self.diff_phid}",
]
@property
@ -161,7 +160,7 @@ class Revision(object):
return self.diff_phid
def __str__(self):
return "Phabricator #{} - {}".format(self.diff_id, self.diff_phid)
return f"Phabricator #{self.diff_id} - {self.diff_phid}"
@staticmethod
def from_try_task(try_task: dict, decision_task: dict, phabricator: PhabricatorAPI):
@ -190,7 +189,7 @@ class Revision(object):
diffs = phabricator.search_diffs(
diff_phid=diff_phid, attachments={"commits": True}
)
assert len(diffs) == 1, "No diff available for {}".format(diff_phid)
assert len(diffs) == 1, f"No diff available for {diff_phid}"
diff = diffs[0]
diff_id = diff["id"]
phid = diff["revisionPHID"]

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -17,7 +16,7 @@ from code_review_bot.tasks.base import AnalysisTask
logger = structlog.get_logger(__name__)
class InfluxDb(object):
class InfluxDb:
"""
Log metrics using InfluxDb REST api
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -20,8 +19,8 @@ class BaseTask:
def __init__(self, task_id, task_status):
self.id = task_id
assert "task" in task_status, "No task data for {}".format(self.id)
assert "status" in task_status, "No status data for {}".format(self.id)
assert "task" in task_status, f"No task data for {self.id}"
assert "status" in task_status, f"No status data for {self.id}"
self.task = task_status["task"]
self.status = task_status["status"]
@ -51,7 +50,7 @@ class BaseTask:
"""
Build the task instance from a configured Taskcluster route
"""
assert cls.route is not None, "Missing route on {}".format(cls)
assert cls.route is not None, f"Missing route on {cls}"
# Load its task id
try:

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import rs_parsepatch
import structlog
@ -65,7 +64,7 @@ class ClangFormatIssue(Issue):
According to diff mode
"""
if self.patch:
return "Replace with :\n\n```{}```".format(self.patch)
return f"Replace with :\n\n```{self.patch}```"
return "Incorrect coding style [clang-format]"
def as_markdown(self):

Просмотреть файл

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -90,7 +88,7 @@ class ClangTidyIssue(Issue):
assert self.is_build_error(), "ClangTidyIssue is not a build error."
return ERROR_MARKDOWN.format(
message=self.message, location="{}:{}".format(self.path, self.line)
message=self.message, location=f"{self.path}:{self.line}"
)
@property
@ -133,23 +131,21 @@ class ClangTidyIssue(Issue):
message = self.message
if len(message) > 0:
message = message[0].capitalize() + message[1:]
body = "{}: {} [clang-tidy: {}]".format(self.level.name, message, self.check)
body = f"{self.level.name}: {message} [clang-tidy: {self.check}]"
# Always add body as it's been cleaned up
if self.reason:
body += "\n{}".format(self.reason)
body += f"\n{self.reason}"
# Also add the reliability of the checker
if self.reliability != Reliability.Unknown:
body += "\nChecker reliability is {0}, meaning that the false positive ratio is {1}.".format(
self.reliability.value, self.reliability.invert
)
body += f"\nChecker reliability is {self.reliability.value}, meaning that the false positive ratio is {self.reliability.invert}."
return body
def as_markdown(self):
return ISSUE_MARKDOWN.format(
level=self.level.value,
message=self.message,
location="{}:{}:{}".format(self.path, self.line, self.column),
location=f"{self.path}:{self.line}:{self.column}",
reason=self.reason,
check=self.check,
in_patch="yes" if self.revision.contains(self) else "no",
@ -161,7 +157,7 @@ class ClangTidyIssue(Issue):
[
ISSUE_NOTE_MARKDOWN.format(
message=n.message,
location="{}:{}:{}".format(n.path, n.line, n.column),
location=f"{n.path}:{n.line}:{n.column}",
body=n.body,
)
for n in self.notes

Просмотреть файл

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -55,7 +53,7 @@ class ExternalTidyIssue(ClangTidyIssue):
assert self.is_build_error(), "ExternalTidyIssue is not a build error."
return ERROR_MARKDOWN.format(
message=self.message, location="{}:{}".format(self.path, self.line)
message=self.message, location=f"{self.path}:{self.line}"
)
def is_expanded_macro(self):
@ -76,11 +74,11 @@ class ExternalTidyIssue(ClangTidyIssue):
message = self.message
if len(message) > 0:
message = message[0].capitalize() + message[1:]
body = "{}: {} [external-tidy: {}]".format(self.level.name, message, self.check)
body = f"{self.level.name}: {message} [external-tidy: {self.check}]"
# Always add body as it's been cleaned up
if self.reason:
body += "\n{}".format(self.reason)
body += f"\n{self.reason}"
return body
def as_markdown_for_phab(self):
@ -91,14 +89,14 @@ class ExternalTidyIssue(ClangTidyIssue):
return ISSUE_MARKDOWN.format(
level=self.level.value,
message=self.message,
location="{}:{}:{}".format(self.path, self.line, self.column),
location=f"{self.path}:{self.line}:{self.column}",
check=self.check,
expanded_macro="yes" if self.is_expanded_macro() else "no",
notes="\n".join(
[
ISSUE_NOTE_MARKDOWN.format(
message=n.message,
location="{}:{}:{}".format(n.path, n.line, n.column),
location=f"{n.path}:{n.line}:{n.column}",
body=n.body,
)
for n in self.notes
@ -110,7 +108,7 @@ class ExternalTidyIssue(ClangTidyIssue):
return ISSUE_MARKDOWN.format(
level=self.level.value,
message=self.message,
location="{}:{}:{}".format(self.path, self.line, self.column),
location=f"{self.path}:{self.line}:{self.column}",
reason=self.reason,
check=self.check,
in_patch="yes" if self.revision.contains(self) else "no",
@ -122,7 +120,7 @@ class ExternalTidyIssue(ClangTidyIssue):
[
ISSUE_NOTE_MARKDOWN.format(
message=n.message,
location="{}:{}:{}".format(n.path, n.line, n.column),
location=f"{n.path}:{n.line}:{n.column}",
body=n.body,
)
for n in self.notes

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import structlog

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import structlog
from code_review_bot import Issue, Level, taskcluster
@ -32,7 +31,7 @@ class DefaultIssue(Issue):
"""
Build the text content for reporters
"""
return "{}: {} [{}]".format(self.level.name, self.message, self.check)
return f"{self.level.name}: {self.message} [{self.check}]"
def as_markdown(self):
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import structlog

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import structlog
from code_review_bot import Issue, Level
@ -80,8 +79,8 @@ class MozLintIssue(Issue):
message = self.message
if len(message) > 0:
message = message[0].capitalize() + message[1:]
linter = "{}: {}".format(self.linter, self.check) if self.check else self.linter
return "{}: {} [{}]".format(self.level.name, message, linter)
linter = f"{self.linter}: {self.check}" if self.check else self.linter
return f"{self.level.name}: {message} [{linter}]"
def as_markdown(self):
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -35,7 +34,7 @@ TASKCLUSTER_INDEX_TTL = 7 # in days
BULK_ISSUE_CHUNKS = 100
class Workflow(object):
class Workflow:
"""
Full static analysis workflow
- setup remote analysis workflow
@ -195,7 +194,7 @@ class Workflow(object):
if artifacts is not None:
task_issues = task.parse_issues(artifacts, revision)
logger.info(
"Found {} issues".format(len(task_issues)),
f"Found {len(task_issues)} issues",
task=task.name,
id=task.id,
)
@ -330,7 +329,7 @@ class Workflow(object):
# Add a sub namespace with the task id to be able to list
# tasks from the parent namespace
namespaces = revision.namespaces + [
"{}.{}".format(namespace, settings.taskcluster.task_id)
f"{namespace}.{settings.taskcluster.task_id}"
for namespace in revision.namespaces
]
@ -405,7 +404,7 @@ class Workflow(object):
# Load task description
task = tasks.get(settings.try_task_id)
assert task is not None, "Missing task {}".format(settings.try_task_id)
assert task is not None, f"Missing task {settings.try_task_id}"
dependencies = task["task"]["dependencies"]
assert len(dependencies) > 0, "No task dependencies to analyze"
@ -454,7 +453,7 @@ class Workflow(object):
if isinstance(task, AnalysisTask):
task_issues = task.parse_issues(artifacts, revision)
logger.info(
"Found {} issues".format(len(task_issues)),
f"Found {len(task_issues)} issues",
task=task.name,
id=task.id,
)
@ -508,11 +507,11 @@ class Workflow(object):
try:
task_id = task_status["status"]["taskId"]
except KeyError:
raise Exception("Cannot read task name {}".format(task_id))
raise Exception(f"Cannot read task name {task_id}")
try:
name = task_status["task"]["metadata"]["name"]
except KeyError:
raise Exception("Cannot read task name {}".format(task_id))
raise Exception(f"Cannot read task name {task_id}")
# Default format is used first when the correct artifact is available
if DefaultTask.matches(task_id):

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -67,7 +66,7 @@ def mock_issues(mock_task):
"""
task = mock_task(DefaultTask, "mock-analyzer")
class MockIssue(object):
class MockIssue:
def __init__(self, nb):
self.nb = nb
self.path = "/path/to/file"
@ -75,7 +74,7 @@ def mock_issues(mock_task):
self.level = Level.Error if self.nb % 2 else Level.Warning
def as_markdown(self):
return "This is the mock issue n°{}".format(self.nb)
return f"This is the mock issue n°{self.nb}"
def as_text(self):
return str(self.nb)
@ -134,7 +133,7 @@ def mock_phabricator(mock_config):
"""
def _response(name):
path = os.path.join(MOCK_DIR, "phabricator_{}.json".format(name))
path = os.path.join(MOCK_DIR, f"phabricator_{name}.json")
assert os.path.exists(path)
return open(path).read()
@ -305,7 +304,7 @@ def mock_revision(mock_phabricator, mock_try_task, mock_decision_task, mock_conf
return Revision.from_try_task(mock_try_task, mock_decision_task, api)
class Response(object):
class Response:
"A simple response encoded as JSON"
def __init__(self, body=None, code=200):
@ -326,7 +325,7 @@ class Response(object):
return self.body
class SessionMock(object):
class SessionMock:
"""
Basic mock of a request session, that returns a JSON body
"""
@ -350,7 +349,7 @@ class SessionMock(object):
return Response(self._callable[("get", url)])
class MockQueue(object):
class MockQueue:
"""
Mock the Taskcluster queue, by using fake tasks descriptions, relations and artifacts
"""
@ -369,7 +368,7 @@ class MockQueue(object):
task_id: {
"dependencies": desc.get("dependencies", []),
"metadata": {
"name": desc.get("name", "source-test-mozlint-{}".format(task_id))
"name": desc.get("name", f"source-test-mozlint-{task_id}")
},
"payload": {
"image": desc.get("image", "alpine"),
@ -445,12 +444,12 @@ class MockQueue(object):
self._artifacts[task_id]["artifacts"].append(payload)
return {
"storageType": "s3",
"putUrl": "http://storage.test/{}".format(name),
"putUrl": f"http://storage.test/{name}",
"contentType": payload["contentType"],
}
class MockIndex(object):
class MockIndex:
def configure(self, tasks):
self.tasks = tasks
@ -469,11 +468,11 @@ class MockIndex(object):
None,
)
if task_id is None:
raise Exception("Task {} not found".format(route))
raise Exception(f"Task {route} not found")
return {"taskId": task_id}
class MockNotify(object):
class MockNotify:
emails = []
def email(self, payload):
@ -746,7 +745,7 @@ def mock_backend(mock_backend_secret):
return revisions, diffs, issues
class MockPhabricator(object):
class MockPhabricator:
"""
A Mock Phabricator API server using responses
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os.path
import pytest

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from code_review_bot.tasks.coverage import ZeroCoverageTask

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
from code_review_bot.tasks.docupload import MAX_LINKS, DocUploadTask

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -9,7 +8,7 @@ MOCK_LANDO_API_URL = "http://api.lando.test"
MOCK_LANDO_TOKEN = "Some Test Token"
class MockLandoWarnings(object):
class MockLandoWarnings:
"""
LandoWarnings Mock class
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -8,7 +7,7 @@ from datetime import datetime
from code_review_bot import stats
class MockInflux(object):
class MockInflux:
"""
Mock the InfluxDb python client to retrieve data sent
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
from code_review_bot.tasks.tgdiff import TaskGraphDiffTask

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -20,7 +19,7 @@ def validate_path(value):
assert isinstance(value, str), "Path should be a string"
assert len(value) > 0, "Path should not be empty"
assert not os.path.isabs(value), "Path should not be absolute"
logger.debug("Path {} is valid".format(value))
logger.debug(f"Path {value} is valid")
def validate_all_types(iterable, t):
@ -80,16 +79,16 @@ def validate_issue(payload):
# Validate all fields one by one
for field in FIELDS:
if field.name in payload:
logger.debug("Validating field {}".format(field.name))
logger.debug(f"Validating field {field.name}")
for validator in field.validators:
try:
validator(payload[field.name])
except Exception as e:
raise Exception("{} {}".format(field.name, e))
raise Exception(f"{field.name} {e}")
else:
if field.required is True:
raise Exception("Missing required field {}".format(field.name))
logger.debug("Missing optional field {}".format(field.name))
raise Exception(f"Missing required field {field.name}")
logger.debug(f"Missing optional field {field.name}")
return True
@ -107,17 +106,15 @@ def validate(payload):
assert validate_all_types(payload.values(), list), "All top values must be lists"
for path, issues in payload.items():
logger.debug("Validating section {}".format(path))
logger.debug(f"Validating section {path}")
validate_path(path)
# All issues must be dicts
assert validate_all_types(
issues, dict
), "All issues for {} must be dicts".format(path)
assert validate_all_types(issues, dict), f"All issues for {path} must be dicts"
# Validate all issues
for i, issue in enumerate(issues):
logger.debug("Validating issue n°{} for {}".format(i + 1, path))
logger.debug(f"Validating issue n°{i + 1} for {path}")
try:
validate_issue(issue)
@ -128,7 +125,7 @@ def validate(payload):
path, issue["path"]
)
except Exception as e:
raise Exception("Invalid issue n°{} for {} : {}".format(i + 1, path, e))
raise Exception(f"Invalid issue n°{i + 1} for {path} : {e}")
return True
@ -157,10 +154,10 @@ if __name__ == "__main__":
payload = json.load(args.issues_file)
validate(payload)
except json.decoder.JSONDecodeError as e:
logger.error("Invalid JSON payload: {}".format(e), exc_info=True)
logger.error(f"Invalid JSON payload: {e}", exc_info=True)
sys.exit(1)
except Exception as e:
logger.error("Invalid issues format: {}".format(e), exc_info=True)
logger.error(f"Invalid issues format: {e}", exc_info=True)
sys.exit(1)
logger.info("Your file is valid !")

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from taskcluster.helper import TaskclusterConfig
taskcluster_config = TaskclusterConfig("https://firefox-ci-tc.services.mozilla.com")

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import asyncio
import random
@ -249,7 +248,7 @@ class BugbugUtils:
# Get the decision task of the push to try.
decision_task_index = self.index_service.findTask(
"gecko.v2.try.revision.{}.taskgraph.decision".format(revision)
f"gecko.v2.try.revision.{revision}.taskgraph.decision"
)
decision_task_id = decision_task_index["taskId"]

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import os
import tempfile

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import asyncio
import os
@ -248,9 +247,7 @@ class CodeReview(PhabricatorActions):
elif mode == "fail:mercurial":
extra_content = ""
if build.missing_base_revision:
extra_content = " because the parent revision ({}) does not exist on mozilla-unified. If possible, you should publish that revision".format(
build.base_revision
)
extra_content = f" because the parent revision ({build.base_revision}) does not exist on mozilla-unified. If possible, you should publish that revision"
failure = UnitResult(
namespace="code-review",
@ -299,9 +296,7 @@ class CodeReview(PhabricatorActions):
namespace="code-review",
name="mercurial",
result=UnitResultState.Unsound,
details="WARNING: The base revision of your patch is not available in the current repository.\nYour patch has been rebased on central (revision {}): issues may be positioned on the wrong lines.".format(
build.actual_base_revision
),
details=f"WARNING: The base revision of your patch is not available in the current repository.\nYour patch has been rebased on central (revision {build.actual_base_revision}): issues may be positioned on the wrong lines.",
)
self.api.update_build_target(
build.target_phid, BuildState.Work, unit=[warning]
@ -368,7 +363,7 @@ class CodeReview(PhabricatorActions):
)
class Events(object):
class Events:
"""
Listen to HTTP notifications from phabricator and trigger new try jobs
"""

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -26,8 +25,8 @@ def PhabricatorMock():
json_headers = {"Content-Type": "application/json"}
def _response(name):
path = os.path.join(FIXTURES_DIR, "phabricator", "{}.json".format(name))
assert os.path.exists(path), "Missing mock {}".format(path)
path = os.path.join(FIXTURES_DIR, "phabricator", f"{name}.json")
assert os.path.exists(path), f"Missing mock {path}"
return open(path).read()
def _phab_params(request):
@ -43,12 +42,12 @@ def PhabricatorMock():
elif "phids" in params["constraints"]:
# Search from diffs
diffs = "-".join(params["constraints"]["phids"])
mock_name = "search-{}".format(diffs)
mock_name = f"search-{diffs}"
elif "ids" in params["constraints"]:
assert len(params["constraints"]["ids"]) == 1
mock_name = "search-{}".format(params["constraints"]["ids"][0])
else:
raise Exception("Unsupported diff mock {}".format(params))
raise Exception(f"Unsupported diff mock {params}")
return (200, json_headers, _response(mock_name))
def _diff_raw(request):
@ -196,7 +195,7 @@ def mock_taskcluster():
def _response(name):
path = os.path.join(FIXTURES_DIR, "taskcluster", name)
assert os.path.exists(path), "Missing mock {}".format(path)
assert os.path.exists(path), f"Missing mock {path}"
return open(path).read()
responses.add(
@ -212,7 +211,7 @@ def mock_taskcluster():
def mock_treeherder():
def _response(name):
path = os.path.join(FIXTURES_DIR, "treeherder", name)
assert os.path.exists(path), "Missing mock {}".format(path)
assert os.path.exists(path), f"Missing mock {path}"
return open(path).read()
return _response

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import asyncio
import json
import os

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@ -32,7 +31,7 @@ async def test_get_version(aiohttp_client, webserver):
response = await client.get("/__version__")
assert response.status == 200
with open(VERSION_PATH, "r") as version_file:
with open(VERSION_PATH) as version_file:
assert await response.json() == json.loads(version_file.read())

Просмотреть файл

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
from libmozdata.phabricator import BuildState, ConduitError, UnitResultState
from libmozevent.bus import MessageBus
@ -18,7 +16,7 @@ MOCK_LANDO_API_URL = "http://api.lando.test"
MOCK_LANDO_TOKEN = "Some Test Token"
class MockLandoWarnings(object):
class MockLandoWarnings:
"""
LandoWarnings Mock class
"""

Просмотреть файл

@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше