• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fedora-llvm-team / llvm-snapshots / 14795010914

02 May 2025 12:16PM UTC coverage: 58.86% (+0.02%) from 58.84%
14795010914

push

github

web-flow
Add mypy, autoflake and ruff pre-commit checks (#1331)

* Add mypy pre-commit hook

This adds mypy, autoflake, and ruff as a pre-commit check and addresses all the complaints it
has. This solved a lot of real issues plus some boilerplate.

* Add autoflake pre-commit hook

This adds autoflake as a pre-commit check and addresses all the complaints it has.

* Add ruff pre-commit hook

This adds ruff as a pre-commit check and addresses all the complaints it has. This solved a lot of real issues plus some boilerplate.

Other commits:

* Provide tests with secret
* Remove unused kwargs
* Deal with cases in which the XML attribute lookup is None
* [pre-commit] autoupdate
* Fix: [WARNING] Unexpected key(s) present on https://github.com/psf/black-pre-commit-mirror => black: force-exclude
* Annotate test fixtures
* Remove premature github label cache
* Add annotation to load-tests protocol
* Add comment about munch.Munch not being typed https://github.com/Infinidat/munch/issues/84
* Annotate subparsers parameters
* Remove unused session_headers property from GithubGraphQL

176 of 234 new or added lines in 21 files covered. (75.21%)

18 existing lines in 7 files now uncovered.

1239 of 2105 relevant lines covered (58.86%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

19.44
/scripts/delete-assets.py
1
#!/bin/env python3
2

3
import argparse
1✔
4
import datetime
1✔
5
import sys
1✔
6

7
from github import Github, UnknownObjectException
1✔
8

9

10
def delete_assets(
1✔
11
    token: str, project: str, release_name: str, delete_older: int, delete_today: bool
12
) -> bool:
13
    """
14
    Deletes release assets of a github project that are older than a given
15
    number of days. Optionally assets from today are also deleted.
16

17
    :param str token: to be used for github token authentication
18
    :param str project: the github project to work with
19
    :param str release_name: the github release within the project to operate on
20
    :param int delete_older: delete assets that are older than this amount of days
21
    :param bool delete_today: if True, deletes assets from today
22
    """
23
    g = Github(login_or_token=token)
×
24
    repo = g.get_repo(project)
×
25

26
    print(
×
27
        "deleting assets older than a week and from today in release '{}'".format(
28
            release_name
29
        )
30
    )
31
    try:
×
32
        release = repo.get_release(release_name)
×
NEW
33
    except UnknownObjectException:
×
34
        print(
×
35
            "release '{}' not found and so there's nothing to delete".format(
36
                release_name
37
            )
38
        )
39
    else:
40
        for asset in release.get_assets():
×
41
            now = datetime.datetime.now(asset.created_at.tzinfo)
×
42
            if asset.created_at < (now - datetime.timedelta(days=delete_older)):
×
43
                print(
×
44
                    "deleting asset '{}' created at {}".format(
45
                        asset.name, asset.created_at
46
                    )
47
                )
NEW
48
                if not asset.delete_asset():
×
49
                    return False
×
NEW
50
            if delete_today and asset.created_at.strftime("%Y%m%d") == now.strftime(
×
51
                "%Y%m%d"
52
            ):
53
                print(
×
54
                    "deleting asset '{}' created at {}".format(
55
                        asset.name, asset.created_at
56
                    )
57
                )
NEW
58
                if not asset.delete_asset():
×
59
                    return False
×
60
    return True
×
61

62

63
def main() -> None:
1✔
64
    parser = argparse.ArgumentParser(
×
65
        description="Delete assets from today and older than a week (by default)."
66
    )
67
    parser.add_argument(
×
68
        "--token",
69
        dest="token",
70
        type=str,
71
        default="YOUR-TOKEN-HERE",
72
        help="your github token",
73
    )
74
    parser.add_argument(
×
75
        "--project",
76
        dest="project",
77
        type=str,
78
        default="fedora-llvm-team/llvm-snapshots",
79
        help="github project to use (default: fedora-llvm-team/llvm-snapshots)",
80
    )
81
    parser.add_argument(
×
82
        "--release-name",
83
        dest="release_name",
84
        type=str,
85
        default="source-snapshot",
86
        help="name of the release to store the source snapshots (default: source-snapshot)",
87
    )
88
    parser.add_argument(
×
89
        "--delete-older",
90
        dest="delete_older",
91
        type=int,
92
        default="7",
93
        help="assets older than the given amount of days will be deleted (default: 7)",
94
    )
95
    parser.add_argument(
×
96
        "--delete-today",
97
        dest="delete_today",
98
        action="store_true",
99
        help="delete assets of today before recreating them (default: no)",
100
    )
101
    args = parser.parse_args()
×
102
    if not delete_assets(
×
103
        token=args.token,
104
        project=args.project,
105
        release_name=args.release_name,
106
        delete_older=args.delete_older,
107
        delete_today=args.delete_today,
108
    ):
109
        sys.exit(-1)
×
110
    sys.exit(0)
×
111

112

113
if __name__ == "__main__":
1✔
114
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc