3636}
3737
3838
39- def sorted_whatsnew () -> Iterator [Path ]:
39+ def sorted_whatsnew (verbose : bool ) -> Iterator [Path ]:
4040 """Return the whatsnew in the 'right' numerical order ('9' before '10')"""
4141 numeric_whatsnew = {}
4242 for file in PATH_TO_WHATSNEW .glob ("**/*" ):
@@ -46,7 +46,8 @@ def sorted_whatsnew() -> Iterator[Path]:
4646 if file .name in NO_CHECK_REQUIRED_FILES or any (
4747 version == x for x in UNCHECKED_VERSION
4848 ):
49- print (f"I don't care about '{ file } ' : π€π€·" )
49+ if verbose :
50+ print (f"I don't care about '{ file } ' : π€π€·" )
5051 continue
5152 num = tuple (int (x ) for x in (version .split ("." )))
5253 numeric_whatsnew [num ] = file
@@ -63,15 +64,17 @@ def main(argv: list[str] | None = None) -> int:
6364 default = 0 ,
6465 help = "The issue we expect to find in the changelog." ,
6566 )
66- parser .parse_args (argv )
67+ parser .add_argument ("--verbose" , "-v" , action = "count" , default = 0 )
68+ args = parser .parse_args (argv )
69+ verbose = args .verbose
6770 is_valid = True
68- for file in sorted_whatsnew ():
69- if not check_file (file ):
71+ for file in sorted_whatsnew (verbose ):
72+ if not check_file (file , verbose ):
7073 is_valid = False
7174 return 0 if is_valid else 1
7275
7376
74- def check_file (file : Path ) -> bool :
77+ def check_file (file : Path , verbose : bool ) -> bool :
7578 """Check that a file contain valid changelog's entries."""
7679 with open (file , encoding = "utf8" ) as f :
7780 content = f .read ()
@@ -81,22 +84,26 @@ def check_file(file: Path) -> bool:
8184 expected = len (contain_issue_number_descriptions )
8285 if result != expected :
8386 return create_detailed_fail_message (
84- contain_issue_number_descriptions , valid_full_descriptions
87+ file , contain_issue_number_descriptions , valid_full_descriptions
8588 )
86- print (f"Checked '{ file } ' : LGTM π€π" )
89+ if verbose :
90+ print (f"Checked '{ file } ' : LGTM π€π" )
8791 return True
8892
8993
9094def create_detailed_fail_message (
91- contain_issue_number_descriptions , valid_full_descriptions
95+ file_name : Path ,
96+ contain_issue_number_descriptions : list ,
97+ valid_full_descriptions : list ,
9298) -> bool :
9399 is_valid = True
94100 for issue_number_description in contain_issue_number_descriptions :
95101 if not any (v [0 ] in issue_number_description for v in valid_full_descriptions ):
96102 is_valid = False
97103 issue_number = ISSUE_NUMBER_PATTERN .findall (issue_number_description )[0 ]
98104 print (
99- f"{ issue_number } 's description is not on one line, or does not respect the standard format."
105+ f"{ file_name } : { issue_number } 's description is not on one line, or "
106+ "does not respect the standard format π€π"
100107 )
101108 return is_valid
102109
0 commit comments