Skip to content

Commit bd530cc

Browse files
committed
Chore: Improve linting, add RUF linter (Ruff-specific rules)
1 parent 9b33276 commit bd530cc

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ lint.select = [
168168
"PD",
169169
# return
170170
"RET",
171+
# Ruff-specific rules
172+
"RUF",
171173
# Bandit
172174
"S",
173175
# print

src/rapporto/github/actions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def markdown(self):
6060
# CI failures report {dt.datetime.now().strftime("%Y-%m-%d")}
6161
A report about GitHub Actions workflow runs that failed recently (now-{self.request.DELTA_HOURS}h).
6262
{mdc.render()}
63-
""".strip() # noqa: E501
63+
""".strip()
6464

6565

6666
class GitHubActionsRequest:
@@ -72,7 +72,7 @@ class GitHubActionsRequest:
7272

7373
DELTA_HOURS = 24
7474

75-
event_section_map = OrderedDict(
75+
event_section_map: t.ClassVar[t.OrderedDict[str, str]] = OrderedDict(
7676
schedule="Schedule",
7777
pull_request="Pull requests",
7878
# push="Pushes",
@@ -140,7 +140,9 @@ class MultiRepositoryInquiry:
140140
repositories: t.List[str]
141141

142142
@classmethod
143-
def make(cls, repository: str, repositories_file: Path = None) -> "MultiRepositoryInquiry":
143+
def make(
144+
cls, repository: str, repositories_file: t.Optional[Path] = None
145+
) -> "MultiRepositoryInquiry":
144146
if repository:
145147
return cls(repositories=[repository])
146148
elif repositories_file:

src/rapporto/github/activity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def format_pr(item: "PullRequestMetadata"):
116116

117117
@property
118118
def markdown(self) -> str:
119-
timerange = self.inquiry.created and f"for {self.inquiry.created}" or ""
119+
timerange = (self.inquiry.created and f"for {self.inquiry.created}") or ""
120120
with redirect_stdout(io.StringIO()) as buffer:
121121
print(f"# PPP report {timerange}")
122122
# print("## Overview")

src/rapporto/github/attention.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GitHubAttentionQueryBuilder(GitHubQueryBuilder):
2020
Find all open issues and pull requests with labels "bug" or "important".
2121
"""
2222

23-
labels = [
23+
labels: t.ClassVar[t.List[str]] = [
2424
"bug", # GitHub standard.
2525
"important", # CrateDB.
2626
"stale", # CrateDB.
@@ -44,14 +44,14 @@ class GitHubAttentionReport:
4444
Find all issues and pull requests with labels "bug" or "important".
4545
"""
4646

47-
label_section_map = OrderedDict(
47+
label_section_map: t.ClassVar[t.OrderedDict[str, str]] = OrderedDict(
4848
bug="Bugs",
4949
important="Important",
5050
stale="Stale",
5151
others="Others",
5252
)
5353

54-
label_aliases = {
54+
label_aliases: t.ClassVar[t.Dict[str, t.List[str]]] = {
5555
"bug": ["type-bug", "type-crash", "type: Bug", "type: bug"],
5656
}
5757

@@ -109,4 +109,4 @@ def markdown(self):
109109
A report about important items that deserve your attention, bugs first.
110110
Time range: {self.search.query_builder.timeinterval.githubformat() or "n/a"}
111111
{mdc.render()}
112-
""".strip() # noqa: E501
112+
""".strip()

src/rapporto/github/backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
class GitHubBackup:
1111
def run(self, args):
12-
cmd = [which("github-backup")] + args
12+
cmd = [which("github-backup"), *args]
1313
subprocess.check_call(cmd) # noqa: S603

src/rapporto/github/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def print_output(report, format_):
6060
@repository_option
6161
@repositories_file_option
6262
@format_option
63-
def actions(repository: str, repositories_file: Path = None, format_: t.Optional[str] = None):
63+
def actions(
64+
repository: str, repositories_file: t.Optional[Path] = None, format_: t.Optional[str] = None
65+
):
6466
"""
6567
CI/GHA failures.
6668
"""

src/rapporto/github/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def issues_and_prs(self):
143143

144144
@dataclasses.dataclass()
145145
class MarkdownContent:
146-
labels: OrderedDict = dataclasses.field(default_factory=OrderedDict)
146+
labels: t.OrderedDict[str, str] = dataclasses.field(default_factory=OrderedDict)
147147
content: t.Dict[str, t.List[str]] = dataclasses.field(default_factory=dict)
148148

149149
def add(self, section, content):

0 commit comments

Comments
 (0)