Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.14"]
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
found = True
break
except URLError as e:
if e.reason.errno == errno.ECONNREFUSED: # type:ignore
if e.reason.errno == errno.ECONNREFUSED: # type: ignore
time.sleep(1)
continue
raise
Expand Down
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
- id: check-case-conflict
Expand All @@ -19,59 +19,59 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 26.10.1
hooks:
- id: black
args: ["--line-length", "100"]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 9.0.2
hooks:
- id: isort
files: \.py$
args: [--profile=black]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v2.4.1
hooks:
- id: mypy
args: ["--config-file", ".mypy.ini"]
additional_dependencies: [types-requests, types-PyYAML, types-mock, tornado, black, pytest, gitpython, pyjwt]
additional_dependencies: [types-requests, types-PyYAML, types-mock, tornado, black, pytest, gitpython, pyjwt, httpx]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.10.1
rev: v0.27
hooks:
- id: validate-pyproject
stages: [manual]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 1.0.0
hooks:
- id: mdformat

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.22.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
rev: v2.0.0
hooks:
- id: doc8
args: [--max-line-length=200]
exclude: docs/source/other/full-config.rst
stages: [manual]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.5.0
hooks:
- id: flake8
additional_dependencies:
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"]
["flake8-bugbear==26.10.27", "flake8-implicit-str-concat==0.7.0"]
stages: [manual]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.19.2
rev: 0.39.0
hooks:
- id: check-github-workflows
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ users:
```

This will allow `<username>` to ask `@meeseeksdev` to perform above commands.
The conf file is the one that sits on the repository default branch (usually
The conf file is the one that sits on the repository default branch (usually
`master`).

## What can a MeeseeksBox do ?
Expand All @@ -74,9 +74,9 @@ Respond with

To test whether a Meeseeks understand you.

### @MeeseeksDev backport \[to\] {branch}
### @MeeseeksDev backport [to] {branch}

If issued from a PR which is merged, attempt to backport (cherry-pick the
If issued from a PR which is merged, attempt to backport (cherry-pick the
merge commit) on an older branch and submit a PR with this backport (on said branch)

Apply origin-pr labels and milestone to backport.
Expand Down Expand Up @@ -106,7 +106,7 @@ If it's not it will ask you to do so.
### @MeeseeksDev pre-commit

If issued from a PR, will apply pre-commit to this PR and push
a commit with the changes made. If no changes are made, or the changes
a commit with the changes made. If no changes are made, or the changes
cannot be automatically fixed, it will show a comment in the PR and bail.

You can also use "precommit" as an alias.
Expand All @@ -131,7 +131,7 @@ Repo admins only, plan to make it available to PR author as well.
MeeseeksDev Bot need to be installed on the PR source repository for this to work.
If it's not it will ask you to do so.

### @MeeseeksDev migrate \[to\] {target org/repo}
### @MeeseeksDev migrate [to] {target org/repo}

Needs MeeseeksBox to be installed on both current and target repo. Command
issuer to be admin on both.
Expand All @@ -155,7 +155,7 @@ Tag with said tags if availlable (comma separated, need to be exact match)

Remove said tags if present (comma separated, need to be exact match)

### @MeeseeksDev merge \[merge|squash|rebase\]
### @MeeseeksDev merge [merge|squash|rebase]

Issuer needs at least write permission.

Expand Down
1 change: 1 addition & 0 deletions meeseeksdev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Meeseeksbox main app module
"""

import base64
import os
import signal
Expand Down
8 changes: 2 additions & 6 deletions meeseeksdev/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ def help(*, session, payload, arguments):
comment_url = payload["issue"]["comments_url"]
session.post_comment(
comment_url,
dedent(
"""The following commands are available:\n\n{}
""".format(
data
)
),
dedent("""The following commands are available:\n\n{}
""".format(data)),
)

return help
Expand Down
67 changes: 20 additions & 47 deletions meeseeksdev/meeseeksbox/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""

import os
import shlex
import random
import re
import shlex
import sys
import time
import traceback
Expand Down Expand Up @@ -69,8 +69,7 @@ def zen(*, session, payload, arguments, local_config=None):
comment_url = payload.get("issue", payload.get("pull_request"))["comments_url"]
session.post_comment(
comment_url,
dedent(
"""
dedent("""
Zen of Python ([pep 20](https://www.python.org/dev/peps/pep-0020/))
```
>>> import this
Expand All @@ -94,8 +93,7 @@ def zen(*, session, payload, arguments, local_config=None):
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
```
"""
),
"""),
)


Expand Down Expand Up @@ -166,9 +164,7 @@ def _pr_head_repo(pr_data: dict) -> Optional[dict]:
return (pr_data.get("head") or {}).get("repo")


def _bail_on_deleted_fork(
session: Session, comment_url: str, pr_data: dict, name: str
) -> bool:
def _bail_on_deleted_fork(session: Session, comment_url: str, pr_data: dict, name: str) -> bool:
"""Post an explanation and return True if the PR's fork is gone."""
if _pr_head_repo(pr_data) is not None:
return False
Expand Down Expand Up @@ -495,12 +491,10 @@ def precommit(
# Alert the caller and bail.
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I was unable to fix pre-commit errors because there is no
".pre-commit-config.yaml" file.
"""
),
"""),
)
return

Expand All @@ -519,11 +513,9 @@ def precommit(
# Alert the caller and bail.
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I was unable to run "pre-commit" because there was nothing to do.
"""
),
"""),
)
return

Expand All @@ -541,22 +533,18 @@ def precommit(
# Alert the caller and bail.
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I was unable to fix pre-commit errors automatically.
Try running `pre-commit run --all-files` locally.
"""
),
"""),
)
return

session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I was unable to fix all of the pre-commit errors automatically. Try running `pre-commit run --all-files` locally.
"""
),
"""),
)

succeeded = push_the_work(session, payload, arguments, local_config=local_config)
Expand All @@ -566,12 +554,10 @@ def precommit(
if succeeded:
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I've applied "pre-commit" and pushed. You may have trouble pushing further
commits, but feel free to force push and ask me to run again.
"""
),
"""),
)
else:
session.post_comment(comment_url, body="I was unable to push due to errors")
Expand Down Expand Up @@ -623,11 +609,9 @@ def blackify(*, session, payload, arguments, local_config=None):
if process.returncode != 0:
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I was unable to run "blackify" due to an error.
"""
),
"""),
)
return

Expand All @@ -637,13 +621,11 @@ def blackify(*, session, payload, arguments, local_config=None):
if succeeded:
session.post_comment(
comment_url,
body=dedent(
"""
body=dedent("""
I've rebased this Pull Request, applied `black` on all the
individual commits, and pushed. You may have trouble pushing further
commits, but feel free to force push and ask me to reformat again.
"""
),
"""),
)
else:
session.post_comment(comment_url, body="I was unable to push due to errors")
Expand All @@ -665,13 +647,6 @@ def safe_backport(session, payload, arguments, local_config=None):
s_slug = ""

def keen_stats():
nonlocal s_slug
nonlocal s_clone_time
nonlocal s_success
nonlocal s_reason
nonlocal s_fork_time
nonlocal s_clean_time
nonlocal s_ff_time
add_event(
"backport_stats",
{
Expand Down Expand Up @@ -913,7 +888,7 @@ def keen_stats():
elif "after resolving the conflicts" in e.stderr.lower():
# TODO, here we should also do a git merge --abort
# to avoid thrashing the cache at next backport request.
cmd = " ".join(shlex.quote(arg) for arg in sys.argv)
cmd = shlex.join(sys.argv)
print(
"\nPatch did not apply. Resolve conflicts (add, not commit), then re-run `%s`"
% cmd,
Expand Down Expand Up @@ -1319,7 +1294,5 @@ def quote(*, session, payload, arguments, local_config=None):
"""
> MeeseeksDev: Gee, {user}, what do you want to do tonight?
{user}: The same thing we do every night, MeeseeksDev - try to take over the world!
""".format(
user=user
),
""".format(user=user),
)
20 changes: 12 additions & 8 deletions meeseeksdev/meeseeksbox/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
from yieldbreaker import YieldBreaker

from .scopes import Permission
from .utils import ACCEPT_HEADER_SYMMETRA, Authenticator, add_event, clear_caches, http_client
from .utils import (
ACCEPT_HEADER_SYMMETRA,
Authenticator,
add_event,
clear_caches,
http_client,
)

green = "\033[0;32m"
yellow = "\033[0;33m"
Expand All @@ -26,12 +32,10 @@


class Config:
botname = None
integration_id = -1
key = None
botname = None
at_botname = None
integration_id = None
integration_id: int | None = None
webhook_secret = None
personal_account_name = None
personal_account_token = None
Expand Down Expand Up @@ -461,7 +465,7 @@ def dispatch_on_mention(self, body: str, payload: dict, user: str) -> None:

permission_level = session._get_permission(org, repo, user)
command_args = process_mentioning_comment(body, self.mention_bot_re)
for (command, arguments) in command_args:
for command, arguments in command_args:
print(" :: treating", command, arguments)
add_event(
"dispatch",
Expand Down Expand Up @@ -609,9 +613,9 @@ def user_can(user, command, repo, org, session):
gen.send(None)
else:
try:
comment_url = payload.get("issue", payload.get("pull_request"))[
"comments_url"
]
issue_or_pr = payload.get("issue", payload.get("pull_request"))
assert issue_or_pr is not None
comment_url = issue_or_pr["comments_url"]
user = payload["comment"]["user"]["login"]
session.post_comment(
comment_url,
Expand Down
Loading
Loading