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

Upgrade black to the latest. #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
885 changes: 306 additions & 579 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pytest-mypy = "^0.8"
pytest-pydocstyle = "^2.3"
sphinx = "^5.0"
sphinx-readable-theme = "^1.3.0"
ghpusher = "^0.2.2"
black = "^19.10b0"
black = "^24.4.2"
isort = "^5.5.4"
pytest-isort = "^3.1"
flake8 = "^4.0"
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Evergreen API Module."""

# Shortcuts for importing.
from evergreen.api import CachedEvergreenApi, EvergreenApi, Requester, RetryingEvergreenApi
from evergreen.api_requests import IssueLinkRequest
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/alias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Representation of project aliases."""

from typing import TYPE_CHECKING, Any, Dict, List

from evergreen.base import _BaseEvergreenObject, evg_attrib
Expand Down
8 changes: 6 additions & 2 deletions src/evergreen/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ def send_slack_message(
attachment.dict(exclude_none=True, exclude_unset=True) for attachment in attachments
]
self._call_api(
url, data=json.dumps(data), method="POST",
url,
data=json.dumps(data),
method="POST",
)

def send_email(
Expand Down Expand Up @@ -508,7 +510,9 @@ def send_email(
if headers is not None:
data["headers"] = headers
self._call_api(
url, data=json.dumps(data), method="POST",
url,
data=json.dumps(data),
method="POST",
)

def alias_for_version(
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/api_requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Objects for making requests to the API."""

from typing import Any, Dict, List, NamedTuple, Optional

from pydantic import BaseModel
Expand Down
23 changes: 19 additions & 4 deletions src/evergreen/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command line driver for evergreen API."""

from __future__ import absolute_import

import json
Expand Down Expand Up @@ -34,17 +35,26 @@ def fmt_output(fmt, data):

@click.group()
@click.option(
"--json", "display_format", flag_value=DisplayFormat.json, help="Write output in json."
"--json",
"display_format",
flag_value=DisplayFormat.json,
help="Write output in json.",
type=click.UNPROCESSED,
)
@click.option(
"--yaml", "display_format", flag_value=DisplayFormat.yaml, help="Write output in yaml."
"--yaml",
"display_format",
flag_value=DisplayFormat.yaml,
help="Write output in yaml.",
type=click.UNPROCESSED,
)
@click.option(
"--human-readable",
"display_format",
flag_value=DisplayFormat.human,
default=True,
help="Write output in a human readable format.",
type=click.UNPROCESSED,
)
@click.pass_context
def cli(ctx, display_format):
Expand Down Expand Up @@ -490,7 +500,10 @@ def delete_user_permissions(ctx, user_id, resource_type, resource_id):
@click.pass_context
@click.option("--user-id", required=True, help="User to grant roles to.")
@click.option(
"--role", required=True, multiple=True, help="Role to grant the user.",
"--role",
required=True,
multiple=True,
help="Role to grant the user.",
)
def give_roles_to_user(ctx, user_id, role):
"""Grant roles to a user."""
Expand All @@ -502,7 +515,9 @@ def give_roles_to_user(ctx, user_id, role):
@cli.command()
@click.pass_context
@click.option(
"--role", required=True, help="Role to fetch users for.",
"--role",
required=True,
help="Role to fetch users for.",
)
def get_users_for_role(ctx, role):
"""Get users having an evergreen role."""
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/errors/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exceptions for the evergreen module."""

from typing import TYPE_CHECKING, Optional

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Representation of evergreen manifest."""

from __future__ import absolute_import

from typing import TYPE_CHECKING, Any, Dict, Optional
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/patch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Representation of an evergreen patch."""

from __future__ import absolute_import

from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Set
Expand Down
5 changes: 4 additions & 1 deletion src/evergreen/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def stream(
is_binary = self._is_binary()

return self._api._stream_api(
self.url, decode_unicode=decode_unicode, chunk_size=chunk_size, is_binary=is_binary,
self.url,
decode_unicode=decode_unicode,
chunk_size=chunk_size,
is_binary=is_binary,
)

def _is_binary(self) -> bool:
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/task_annotations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Models to working with task annotations."""

from typing import TYPE_CHECKING, Any, Dict, List

from evergreen.base import _BaseEvergreenObject, evg_attrib, evg_datetime_attrib
Expand Down
1 change: 1 addition & 0 deletions src/evergreen/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Useful utilities for interacting with Evergreen."""

from datetime import date, datetime
from typing import Any, Iterable, Optional

Expand Down
1 change: 1 addition & 0 deletions tests/evergreen/cli/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for main.py."""

import json
from datetime import datetime

Expand Down
59 changes: 48 additions & 11 deletions tests/evergreen/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ def test_test_stats_by_project(self, mocked_api):
}

mocked_api.test_stats_by_project(
"project_id", from_iso_format(after_date), from_iso_format(before_date),
"project_id",
from_iso_format(after_date),
from_iso_format(before_date),
)

mocked_api.session.request.assert_called_with(
Expand Down Expand Up @@ -452,7 +454,11 @@ def test_tasks_by_project_and_name_with_data(self, mocked_api):
{"build_variant": "build_variant", "num_versions": 50, "start_at": 10}
)
mocked_api.session.request.assert_called_with(
url=expected_url, params=None, timeout=None, data=expected_data, method="GET",
url=expected_url,
params=None,
timeout=None,
data=expected_data,
method="GET",
)


Expand Down Expand Up @@ -568,7 +574,9 @@ def test_patch_diff_api(self, mocked_api):


class TestCreatePatchDiff:
@patch("evergreen.api.subprocess.run",)
@patch(
"evergreen.api.subprocess.run",
)
def test_patch_from_diff_valid_no_author(self, mock_run, mocked_api):
mock_stdout = MagicMock()
mock_stdout.stderr = b"[evergreen] 2023/04/13 15:05:24 [p=info]: Patch successfully created.\n[evergreen] 2023/04/13 15:05:24 [p=info]: \n ID : 64387ca457e85ac95a3da12f\n Created : 2023-04-13 22:05:24.463 +0000 UTC\n Description : Test enable profiling.\n Build : https://evergreen.mongodb.com/patch/64387ca457e85ac95a3da12f?redirect_spruce_users=true\n Status : created\n\n\n"
Expand All @@ -594,7 +602,9 @@ def test_patch_from_diff_valid_no_author(self, mock_run, mocked_api):
)
assert result.id == "64387ca457e85ac95a3da12f"

@patch("evergreen.api.subprocess.run",)
@patch(
"evergreen.api.subprocess.run",
)
def test_patch_from_diff_valid_with_author(self, mock_run, mocked_api):
mock_stdout = MagicMock()
mock_stdout.stderr = b"[evergreen] 2023/04/13 15:05:24 [p=info]: Patch successfully created.\n[evergreen] 2023/04/13 15:05:24 [p=info]: \n ID : 64387ca457e85ac95a3da12f\n Created : 2023-04-13 22:05:24.463 +0000 UTC\n Description : Test enable profiling.\n Build : https://evergreen.mongodb.com/patch/64387ca457e85ac95a3da12f?redirect_spruce_users=true\n Status : created\n\n\n"
Expand All @@ -605,7 +615,14 @@ def test_patch_from_diff_valid_with_author(self, mock_run, mocked_api):
"reuse_compile_from": "build_id",
}
result = mocked_api.patch_from_diff(
"path", params, "base", "task", "project", "description", "variant", "author",
"path",
params,
"base",
"task",
"project",
"description",
"variant",
"author",
)

command = mock_run.call_args[0][0]
Expand All @@ -620,7 +637,9 @@ def test_patch_from_diff_valid_with_author(self, mock_run, mocked_api):
)
assert result.id == "64387ca457e85ac95a3da12f"

@patch("evergreen.api.subprocess.run",)
@patch(
"evergreen.api.subprocess.run",
)
def test_patch_from_diff_invalid(self, mock_run, mocked_api):
mock_stdout = MagicMock()
mock_stdout.stderr = b"no url here"
Expand All @@ -631,7 +650,9 @@ def test_patch_from_diff_invalid(self, mock_run, mocked_api):
"path", {}, "base", "task", "project", "description", "variant"
)

@patch("evergreen.api.subprocess.run",)
@patch(
"evergreen.api.subprocess.run",
)
def test_patch_from_patch_id(self, mock_run, mocked_api):
mock_stdout = MagicMock()
mock_stdout.stderr = b"[evergreen] 2023/04/13 15:05:24 [p=info]: Patch successfully created.\n[evergreen] 2023/04/13 15:05:24 [p=info]: \n ID : 64387ca457e85ac95a3da12f\n Created : 2023-04-13 22:05:24.463 +0000 UTC\n Description : Test enable profiling.\n Build : https://evergreen.mongodb.com/patch/64387ca457e85ac95a3da12f?redirect_spruce_users=true\n Status : created\n\n\n"
Expand Down Expand Up @@ -975,15 +996,23 @@ def test_give_permissions_to_user(self, mocked_api, mocked_api_response):
"test.user", PermissionableResourceType.PROJECT, resources, permissions
)
mocked_api.session.request.assert_called_with(
url=expected_url, params=None, timeout=None, data=expected_data, method="POST",
url=expected_url,
params=None,
timeout=None,
data=expected_data,
method="POST",
)

def test_delete_user_permissions_all_resources(self, mocked_api):
expected_url = mocked_api._create_url("/users/test.user/permissions")
expected_data = json.dumps({"resource_type": RemovablePermission.PROJECT.value})
mocked_api.delete_user_permissions("test.user", RemovablePermission.PROJECT)
mocked_api.session.request.assert_called_with(
url=expected_url, params=None, timeout=None, data=expected_data, method="DELETE",
url=expected_url,
params=None,
timeout=None,
data=expected_data,
method="DELETE",
)

def test_delete_user_permissions_specific_resource(self, mocked_api):
Expand All @@ -993,7 +1022,11 @@ def test_delete_user_permissions_specific_resource(self, mocked_api):
)
mocked_api.delete_user_permissions("test.user", RemovablePermission.PROJECT, "testresource")
mocked_api.session.request.assert_called_with(
url=expected_url, params=None, timeout=None, data=expected_data, method="DELETE",
url=expected_url,
params=None,
timeout=None,
data=expected_data,
method="DELETE",
)

def test_all_user_permissions_for_resource(self, mocked_api, mocked_api_response):
Expand All @@ -1008,7 +1041,11 @@ def test_all_user_permissions_for_resource(self, mocked_api, mocked_api_response
)
assert returned_permissions == permissions
mocked_api.session.request.assert_called_with(
url=expected_url, params=None, timeout=None, data=expected_data, method="GET",
url=expected_url,
params=None,
timeout=None,
data=expected_data,
method="GET",
)


Expand Down
1 change: 1 addition & 0 deletions tests/evergreen/test_artifact_stream.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Artifact class streams in src/evergreen/task.py"""

from unittest.mock import MagicMock

import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/evergreen/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def test_inactive_task_finished(self, sample_task):
assert not task.is_active()

@pytest.mark.parametrize(
"execution,expected", [(None, 1), (0, 0)],
"execution,expected",
[(None, 1), (0, 0)],
)
def test_get_tests(self, sample_task, execution, expected):
mock_api = MagicMock()
Expand Down