Skip to content

Commit 94d07e9

Browse files
committed
Fixed most of pylint issues.
1 parent 669c7bf commit 94d07e9

16 files changed

Lines changed: 85 additions & 81 deletions

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ max-returns=6
322322
max-statements=50
323323

324324
# Minimum number of public methods for a class (see R0903).
325-
min-public-methods=2
325+
min-public-methods=1
326326

327327

328328
[EXCEPTIONS]

main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121
"""
2222

2323
import logging
24-
25-
# TODO - fix certificate verification
2624
import warnings
27-
from urllib3.exceptions import InsecureRequestWarning
28-
29-
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
3025

3126
from github import Github, Auth
27+
from urllib3.exceptions import InsecureRequestWarning
3228

3329
from release_notes_generator.generator import ReleaseNotesGenerator
3430
from release_notes_generator.model.custom_chapters import CustomChapters
@@ -37,6 +33,8 @@
3733
from release_notes_generator.utils.logging_config import setup_logging
3834
from release_notes_generator.filter import FilterByRelease
3935

36+
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
37+
4038

4139
def run() -> None:
4240
"""

release_notes_generator/action_inputs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ def get_coderabbit_release_notes_title() -> str:
228228
"""
229229
Get the CodeRabbit release notes title from the action inputs.
230230
"""
231-
return get_action_input(CODERABBIT_RELEASE_NOTES_TITLE, CODERABBIT_RELEASE_NOTE_TITLE_DEFAULT) # type: ignore[return-value]
231+
return get_action_input(
232+
CODERABBIT_RELEASE_NOTES_TITLE, CODERABBIT_RELEASE_NOTE_TITLE_DEFAULT
233+
) # type: ignore[return-value]
232234

233235
@staticmethod
234236
def get_coderabbit_summary_ignore_groups() -> list[str]:

release_notes_generator/builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
logger = logging.getLogger(__name__)
3030

3131

32-
# pylint: disable=too-few-public-methods
3332
class ReleaseNotesBuilder:
3433
"""
3534
A class representing the Release Notes Builder.

release_notes_generator/filter.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ def filter(self, data: MinedData) -> MinedData:
8787
md.commits = commits_list
8888

8989
logger.debug(
90-
f"Input data. Issues: {len(data.issues)}, "
91-
f"Pull Requests: {len(data.pull_requests)}, Commits: {len(data.commits)}"
90+
"Input data. Issues: %d, Pull Requests: %d, Commits: %d",
91+
len(data.issues),
92+
len(data.pull_requests),
93+
len(data.commits),
9294
)
9395
logger.debug(
94-
f"Filtered data. Issues: {len(md.issues)}, "
95-
f"Pull Requests: {len(md.pull_requests)}, Commits: {len(md.commits)}"
96+
"Filtered data. Issues: %d, Pull Requests: %d, Commits: %d",
97+
len(md.issues),
98+
len(md.pull_requests),
99+
len(md.commits),
96100
)
97101
else:
98102
md.issues = deepcopy(data.issues)

release_notes_generator/miner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def __init__(self, github_instance: Github, rate_limiter: GithubRateLimiter):
4747
self._safe_call = safe_call_decorator(rate_limiter)
4848

4949
def mine_data(self) -> MinedData:
50+
"""
51+
Mines data from GitHub, including repository information, issues, pull requests, commits, and releases.
52+
"""
5053
logger.info("Starting data mining from GitHub...")
5154
data = MinedData()
5255

release_notes_generator/model/chapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ def __init__(
3333
self.rows: dict[int | str, str] = {}
3434
self.empty_message = empty_message
3535

36-
def add_row(self, id: int | str, row: str) -> None:
36+
def add_row(self, row_id: int | str, row: str) -> None:
3737
"""
3838
Adds a row to the chapter.
3939
4040
@param id: The number or sha of the row.
4141
@param row: The row to add.
4242
@return: None
4343
"""
44-
self.rows[id] = row
44+
self.rows[row_id] = row
4545

4646
def to_string(self, sort_ascending: bool = True, print_empty_chapters: bool = True) -> str:
4747
"""

release_notes_generator/model/custom_chapters.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ def populate(self, records: dict[int | str, Record]) -> None:
3838
@param records: A dictionary of records where the key is an integer and the value is a Record object.
3939
@return: None
4040
"""
41-
for id, record in records.items(): # iterate all records
41+
for record_id, record in records.items(): # iterate all records
4242
# check if the record should be skipped
43-
if records[id].skip:
43+
if records[record_id].skip:
4444
continue
4545

4646
# skip direct commits as they do not have labels
4747
if isinstance(record, CommitRecord):
4848
continue
4949

5050
for ch in self.chapters.values(): # iterate all chapters
51-
if id in self.populated_record_numbers_list and ActionInputs.get_duplicity_scope() not in (
51+
if record_id in self.populated_record_numbers_list and ActionInputs.get_duplicity_scope() not in (
5252
DuplicityScopeEnum.CUSTOM,
5353
DuplicityScopeEnum.BOTH,
5454
):
5555
continue
5656

57-
for record_label in records[id].labels: # iterate all labels of the record (issue, or 1st PR)
58-
if record_label in ch.labels and records[id].pulls_count > 0:
59-
if not records[id].is_present_in_chapters:
60-
ch.add_row(id, records[id].to_chapter_row())
61-
self.populated_record_numbers_list.append(id)
57+
for record_label in records[record_id].labels: # iterate all labels of the record (issue, or 1st PR)
58+
if record_label in ch.labels and records[record_id].pulls_count > 0:
59+
if not records[record_id].is_present_in_chapters:
60+
ch.add_row(record_id, records[record_id].to_chapter_row())
61+
self.populated_record_numbers_list.append(record_id)
6262

6363
def from_yaml_array(self, chapters: list[dict[str, str]]) -> "CustomChapters":
6464
"""

release_notes_generator/model/mined_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ def __init__(self):
4747
self.since = datetime(1970, 1, 1) # Default to epoch start
4848

4949
def is_empty(self):
50+
"""
51+
Checks if the mined data is empty, meaning no repository has been set.
52+
53+
Returns:
54+
bool: True if the repository is None, False otherwise.
55+
"""
5056
return self.repository is None

release_notes_generator/model/record.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import logging
2222
import re
2323

24-
from typing import Optional, AnyStr, Any, Dict, List
24+
from typing import Optional, Any, Dict, List
2525

2626
from github.Issue import Issue
2727
from github.PullRequest import PullRequest
@@ -158,7 +158,8 @@ def get_rls_notes(self, line_marks: Optional[list[str]] = None) -> str:
158158
if pull.body and detection_regex.search(pull.body):
159159
release_notes += self.__get_rls_notes_default(pull, line_marks, detection_regex)
160160
elif pull.body and cr_active and cr_detection_regex.search(pull.body): # type: ignore[union-attr]
161-
release_notes += self.__get_rls_notes_code_rabbit(pull, line_marks, cr_detection_regex) # type: ignore[arg-type]
161+
release_notes += self.__get_rls_notes_code_rabbit(pull, line_marks,
162+
cr_detection_regex) # type: ignore[arg-type]
162163

163164
# Return the concatenated release notes
164165
return release_notes.rstrip()
@@ -251,7 +252,7 @@ def pulls_count(self) -> int:
251252
@property
252253
def pr_contains_issue_mentions(self) -> bool:
253254
"""Checks if the pull request contains issue mentions."""
254-
# todo call both and merge solve in issue
255+
# TODO call both and merge solve in issue #153
255256
return len(extract_issue_numbers_from_body(self._pulls[0])) > 0
256257

257258
@property
@@ -346,8 +347,7 @@ def to_chapter_row(self) -> str:
346347
347348
@return: The record as a row string.
348349
"""
349-
# TODO - create a version on child classes
350-
350+
# TODO - create a version on child classes #152
351351
self.increment_present_in_chapters()
352352
row_prefix = f"{ActionInputs.get_duplicity_icon()} " if self.present_in_chapters() > 1 else ""
353353
format_values = {}
@@ -429,11 +429,7 @@ def is_commit_sha_present(self, sha: str) -> bool:
429429
@param sha: The commit SHA to check for.
430430
@return: A boolean indicating whether the specified commit SHA is present in the record.
431431
"""
432-
for pull in self._pulls:
433-
if pull.merge_commit_sha == sha:
434-
return True
435-
436-
return False
432+
return any(pull.merge_commit_sha == sha for pull in self._pulls)
437433

438434
@staticmethod
439435
def is_pull_request_merged(pull: PullRequest) -> bool:
@@ -456,7 +452,7 @@ def __init__(self, pull: PullRequest, skip: bool = False):
456452
super().__init__(issue=None, skip=skip)
457453
self.register_pull_request(pull)
458454
self.__is_release_note_detected = self.contains_release_notes
459-
self.___issues: Dict[int, List[Issue]] = {}
455+
self.__issues: Dict[int, List[Issue]] = {}
460456

461457

462458
class IssueRecord(Record):

0 commit comments

Comments
 (0)