github-overlord 0.7.0__tar.gz → 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: github-overlord
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Automatically merge Dependabot PRs in public repositories
5
5
  Home-page: https://github.com/iloveitaly/github-overlord
6
6
  Keywords: github,dependabot,automation
@@ -12,8 +12,8 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Requires-Dist: apscheduler (>=3.10.4,<4.0.0)
14
14
  Requires-Dist: click (>=8.1.7,<9.0.0)
15
- Requires-Dist: funcy-pipe (>=0.11.0,<0.12.0)
16
- Requires-Dist: openai (>=1.37.1,<2.0.0)
15
+ Requires-Dist: funcy-pipe (>=0.11.1,<0.12.0)
16
+ Requires-Dist: openai (>=1.41.1,<2.0.0)
17
17
  Requires-Dist: pygithub (>=2.3.0,<3.0.0)
18
18
  Requires-Dist: python-decouple-typed (>=3.11.0,<4.0.0)
19
19
  Requires-Dist: structlog (>=24.4.0,<25.0.0)
@@ -5,18 +5,15 @@ from types import NoneType
5
5
 
6
6
  import click
7
7
  import funcy_pipe as fp
8
- import funcy as f
9
8
  from github import Github
10
9
  from github.GithubObject import NotSet
11
10
  from github.Notification import Notification
12
11
  from github.PullRequest import PullRequest
13
12
 
14
- from github_overlord.stale_commenter import (
15
- check_for_stale_comments,
16
- inspect_repo_for_stale_prs,
17
- is_stale_comment,
18
- )
19
- from github_overlord.utils import log
13
+ import github_overlord.patch as _
14
+
15
+ from .stale_commenter import inspect_repo_for_stale_prs
16
+ from .utils import log
20
17
 
21
18
  AUTOMATIC_MERGE_MESSAGE = "Automatically merged with [github-overlord](https://github.com/iloveitaly/github-overlord)"
22
19
 
@@ -258,12 +255,14 @@ def keep_alive_prs(token, dry_run, repo):
258
255
  )
259
256
  def notifications(token, dry_run, only_unread):
260
257
  """
261
- Look at notifications and mark them as read if they are dependabot notifications
258
+ Look at notifications and mark them as read if they are:
262
259
 
263
260
  * Dependabot notifications
264
261
  * Releases on repos I own
265
262
  * Closed (merged, closed) pull requests on repos I own
266
263
  * Closed pull requests that I authored
264
+
265
+ Helpful if you work across a lot of repos and want to keep your notifications clean.
267
266
  """
268
267
 
269
268
  github = Github(token)
@@ -283,10 +282,11 @@ def notifications(token, dry_run, only_unread):
283
282
  # TODO I think there is a way to convert the instance method to a standard method so it could be mapped
284
283
  # patchy had some code for this
285
284
  )
286
- | fp.map(lambda n: n.mark_as_done())
287
- | fp.to_list()
285
+ | fp.lmap(Notification.mark_as_done)
288
286
  )
289
287
 
288
+ log.info("marked releases as done", count=len(released_on_owned_repos))
289
+
290
290
  def is_dependabot_notification(notification: Notification) -> bool:
291
291
  return notification.get_pull_request().user.login == "dependabot[bot]"
292
292
 
@@ -301,22 +301,23 @@ def notifications(token, dry_run, only_unread):
301
301
  notifications
302
302
  | fp.filter(is_pull_request)
303
303
  | fp.filter(is_dependabot_notification)
304
- | fp.map(Notification.mark_as_done)
305
- | fp.to_list()
304
+ | fp.lmap(Notification.mark_as_done)
306
305
  )
307
306
 
307
+ log.info("marked dependabot PRs as done", count=len(pull_requests_by_dependabot))
308
+
308
309
  # Closed (merged, closed) pull requests that I authored
309
310
  owned_closed_pull_requests = (
310
311
  notifications
311
312
  # PRs that I did not author may still be interesting
312
313
  | fp.where_attr(reason="author")
313
314
  | fp.filter(is_pull_request)
314
- # TODO should use `fp`
315
- | fp.filter(f.complement(is_pull_request_open))
316
- | fp.map(Notification.mark_as_done)
317
- | fp.to_list()
315
+ | fp.filter(fp.complement(is_pull_request_open))
316
+ | fp.lmap(Notification.mark_as_done)
318
317
  )
319
318
 
319
+ log.info("marked owned closed PRs as done", count=len(owned_closed_pull_requests))
320
+
320
321
 
321
322
  cli.add_command(dependabot)
322
323
  cli.add_command(keep_alive_prs)
@@ -9,8 +9,23 @@ from pathlib import Path
9
9
  import structlog
10
10
  from decouple import config
11
11
 
12
+ root: Path
13
+
14
+ # must type manually, unfortunately :/
15
+ # https://www.structlog.org/en/21.3.0/types.html
16
+ log: structlog.stdlib.BoundLogger
17
+
12
18
 
13
19
  def configure_logger():
20
+ global log
21
+
22
+ # context manager to auto-clear context
23
+ log.context = structlog.contextvars.bound_contextvars # type: ignore
24
+ # set thread-local context
25
+ log.local = structlog.contextvars.bind_contextvars # type: ignore
26
+ # clear thread-local context
27
+ log.clear = structlog.contextvars.clear_contextvars # type: ignore
28
+
14
29
  logger_factory = structlog.PrintLoggerFactory()
15
30
 
16
31
  # allow user to specify a log in case they want to do something meaningful with the stdout
@@ -38,28 +53,15 @@ def configure_logger():
38
53
  )
39
54
 
40
55
 
41
- # must type manually, unfortunately :/
42
- # https://www.structlog.org/en/21.3.0/types.html
43
- log: structlog.stdlib.BoundLogger
44
-
45
-
46
56
  def setup():
47
57
  if hasattr(setup, "complete") and setup.complete:
48
58
  return
49
59
 
50
- global root, logger, log
60
+ global root, log
51
61
 
52
62
  root = Path(__file__).parent.parent
53
63
 
54
64
  log = structlog.get_logger()
55
-
56
- # context manager to auto-clear context
57
- log.context = structlog.contextvars.bound_contextvars # type: ignore
58
- # set thread-local context
59
- log.local = structlog.contextvars.bind_contextvars # type: ignore
60
- # clear thread-local context
61
- log.clear = structlog.contextvars.clear_contextvars # type: ignore
62
-
63
65
  configure_logger()
64
66
 
65
67
  log.debug("application setup")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "github-overlord"
3
- version = "0.7.0"
3
+ version = "0.7.1"
4
4
  description = "Automatically merge Dependabot PRs in public repositories"
5
5
  authors = ["Michael Bianco <mike@mikebian.co>"]
6
6
  readme = "README.md"
@@ -12,10 +12,10 @@ python = "^3.11"
12
12
  pygithub = "^2.3.0"
13
13
  click = "^8.1.7"
14
14
  python-decouple-typed = "^3.11.0"
15
- funcy-pipe = "^0.11.0"
15
+ funcy-pipe = "^0.11.1"
16
16
  structlog = "^24.4.0"
17
17
  apscheduler = "^3.10.4"
18
- openai = "^1.37.1"
18
+ openai = "^1.41.1"
19
19
 
20
20
  [tool.poetry.scripts]
21
21
  github-overlord = "github_overlord:cli"
@@ -28,8 +28,8 @@ float_to_top = true
28
28
 
29
29
  [tool.poetry.group.dev.dependencies]
30
30
  isort = "^5.13.2"
31
- black = "^24.4.2"
32
- pyright = "^1.1.373"
31
+ black = "^24.8.0"
32
+ pyright = "^1.1.376"
33
33
  pylint = "^3.2.6"
34
34
 
35
35
  [build-system]