|
46 | 46 |
|
47 | 47 | POLICY_MONTHS_DELTA = 6 |
48 | 48 |
|
| 49 | +DEFAULT_STUBTEST_FILE = Path("/tmp/stubs.txt") # Sync with `stubsabot` github job |
| 50 | + |
49 | 51 |
|
50 | 52 | class ActionLevel(enum.IntEnum): |
51 | 53 | def __new__(cls, value: int, doc: str) -> Self: |
@@ -629,6 +631,17 @@ def is_new_release(upload_datetime: datetime.datetime) -> bool: |
629 | 631 | return upload_datetime > yesterday |
630 | 632 |
|
631 | 633 |
|
| 634 | +def append_stub_to_stubtest_list(distribution: str, *, file_path: Path = DEFAULT_STUBTEST_FILE) -> None: |
| 635 | + if Path.exists(file_path): |
| 636 | + with Path.open(file_path, "r") as f: |
| 637 | + stubs = f.read().strip() |
| 638 | + else: |
| 639 | + stubs = "" |
| 640 | + stubs = f"{stubs} {distribution}" if stubs else distribution |
| 641 | + with Path.open(file_path, "w") as f: |
| 642 | + f.write(stubs) |
| 643 | + |
| 644 | + |
632 | 645 | async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error: |
633 | 646 | try: |
634 | 647 | return await determine_action_no_error_handling(distribution, session) |
@@ -673,11 +686,7 @@ async def determine_action_no_error_handling( |
673 | 686 | obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session) |
674 | 687 | if obsolete_since is None and latest_version in stub_info.version_spec: |
675 | 688 | if is_new_release(latest_release.upload_date): |
676 | | - stubs = os.environ.get("STUBS", "").strip() |
677 | | - if stubs: |
678 | | - stubs = f"{stubs} {latest_release.distribution}" |
679 | | - else: |
680 | | - stubs = latest_release.distribution |
| 689 | + append_stub_to_stubtest_list(latest_release.distribution) |
681 | 690 | return NoUpdate(stub_info.distribution, "up to date") |
682 | 691 |
|
683 | 692 | relevant_version = obsolete_since.version if obsolete_since else latest_version |
|
0 commit comments