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

ref(bot): replace linters with ruff #863

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
661 changes: 0 additions & 661 deletions bot/.pylintrc

This file was deleted.

7 changes: 5 additions & 2 deletions bot/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"python.testing.pytestArgs": ["kodiak"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": true
"python.linting.flake8Enabled": false,
"evenBetterToml.schema.enabled": false,
"[toml]": {
"editor.formatOnSave": false
}
}
3 changes: 2 additions & 1 deletion bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The follow shows how to run commands for testing and development. For informatio
poetry config virtualenvs.in-project true
poetry install

# format and lint using black, isort, mypy, flake8, pylint
# format and lint
s/lint

# run tests using pytest
Expand All @@ -36,6 +36,7 @@ s/dev-workers
```

If you have made any changes concerning the config, run the following command to update the schema:

```shell
poetry run kodiak gen-conf-json-schema > kodiak/test/fixtures/config/config-schema.json
```
8 changes: 4 additions & 4 deletions bot/kodiak/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def list_installs() -> None:
private_key=conf.PRIVATE_KEY, app_identifier=conf.GITHUB_APP_ID
)
results: List[Dict[str, Any]] = []
headers = dict(
Accept="application/vnd.github.machine-man-preview+json",
Authorization=f"Bearer {app_token}",
)
headers = {
"Accept": "application/vnd.github.machine-man-preview+json",
"Authorization": f"Bearer {app_token}",
}
url = conf.v3_url("/app/installations")
while True:
res = requests.get(url, headers=headers)
Expand Down
2 changes: 1 addition & 1 deletion bot/kodiak/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Approve(BaseModel):
auto_approve_labels: List[str] = []


class InvalidVersion(ValueError):
class InvalidVersion(ValueError): # noqa: N818
pass


Expand Down
2 changes: 1 addition & 1 deletion bot/kodiak/entrypoints/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


async def get_redis() -> asyncio_redis.Pool:
global _redis # pylint: disable=global-statement
global _redis
if _redis is None:
_redis = await asyncio_redis.Pool.create(
host=conf.REDIS_URL.hostname or "localhost",
Expand Down
2 changes: 1 addition & 1 deletion bot/kodiak/entrypoints/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def main() -> NoReturn:
queue = RedisWebhookQueue()
await queue.create()

ingest_workers = dict()
ingest_workers = {}

redis = await redis_client.create_connection()
ingest_queue_names = await redis.smembers(INGEST_QUEUE_NAMES)
Expand Down
6 changes: 3 additions & 3 deletions bot/kodiak/errors.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class RetryForSkippableChecks(Exception):
class RetryForSkippableChecks(Exception): # noqa: N818
pass


class PollForever(Exception):
class PollForever(Exception): # noqa: N818
pass


class ApiCallException(Exception):
class ApiCallException(Exception): # noqa: N818
def __init__(self, method: str, http_status_code: int, response: bytes) -> None:
self.method = method
self.status_code = http_status_code
Expand Down
1 change: 1 addition & 0 deletions bot/kodiak/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_body_content(
if body_type is BodyText.html:
return pull_request.bodyHTML
assert_never(body_type)
return None


EMPTY_STRING = ""
Expand Down
4 changes: 2 additions & 2 deletions bot/kodiak/events/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from kodiak.events.check_run import CheckRunEvent # noqa: F401
from kodiak.events.pull_request import PullRequestEvent # noqa: F401
from kodiak.events.pull_request_review import PullRequestReviewEvent # noqa: F401
from kodiak.events.pull_request_review_thread import ( # noqa: F401
PullRequestReviewThreadEvent,
from kodiak.events.pull_request_review_thread import (
PullRequestReviewThreadEvent, # noqa: F401
)
from kodiak.events.push import PushEvent # noqa: F401
from kodiak.events.status import StatusEvent # noqa: F401
6 changes: 3 additions & 3 deletions bot/kodiak/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import ssl

from httpx import ( # noqa: I251
from httpx import ( # noqa: TID251
AsyncClient,
HTTPError,
HTTPStatusError,
Request,
Response,
)
from httpx._config import DEFAULT_TIMEOUT_CONFIG # noqa: I251
from httpx._types import TimeoutTypes # noqa: I251
from httpx._config import DEFAULT_TIMEOUT_CONFIG # noqa: TID251
from httpx._types import TimeoutTypes # noqa: TID251

__all__ = ["Response", "Request", "HTTPError", "HttpClient", "HTTPStatusError"]

Expand Down
12 changes: 6 additions & 6 deletions bot/kodiak/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async def update_branch(self) -> None:
except HTTPError:
self.log.warning("failed to update branch", res=res, exc_info=True)
# we raise an exception to retry this request.
raise ApiCallException(
raise ApiCallException( # noqa: B904
method="pull_request/update_branch",
http_status_code=res.status_code,
response=res.content,
Expand Down Expand Up @@ -329,9 +329,9 @@ async def merge(
"failed to merge pull request", res=res, exc_info=True
)
if e.response is not None and e.response.status_code == 500:
raise GitHubApiInternalServerError
raise GitHubApiInternalServerError # noqa: B904
# we raise an exception to retry this request.
raise ApiCallException(
raise ApiCallException( # noqa: B904
method="pull_request/merge",
http_status_code=res.status_code,
response=res.content,
Expand All @@ -351,7 +351,7 @@ async def update_ref(self, ref: str, sha: str) -> None:
else:
self.log.warning("failed to update ref", res=res, exc_info=True)
# we raise an exception to retry this request.
raise ApiCallException(
raise ApiCallException( # noqa: B904
method="pull_request/update_ref",
http_status_code=res.status_code,
response=res.content,
Expand All @@ -376,7 +376,7 @@ async def add_label(self, label: str) -> None:
self.log.warning(
"failed to add label", label=label, res=res, exc_info=True
)
raise ApiCallException(
raise ApiCallException( # noqa: B904
method="pull_request/add_label",
http_status_code=res.status_code,
response=res.content,
Expand All @@ -398,7 +398,7 @@ async def remove_label(self, label: str) -> None:
"failed to delete label", label=label, res=res, exc_info=True
)
# we raise an exception to retry this request.
raise ApiCallException(
raise ApiCallException( # noqa: B904
method="pull_request/delete_label",
http_status_code=res.status_code,
response=res.content,
Expand Down
Loading