@@ -64,6 +64,7 @@ def __init__(self):
64
64
self .auto_assign = os .getenv ('INPUT_AUTO_ASSIGN' , 'false' ) == 'true'
65
65
self .actor = os .getenv ('INPUT_ACTOR' )
66
66
67
+ # noinspection PyMethodMayBeStatic
67
68
def get_timestamp (self , commit ):
68
69
return commit .get ('timestamp' )
69
70
@@ -220,7 +221,7 @@ def __init__(self):
220
221
try :
221
222
custom_identifiers_dict = json .loads (custom_identifiers )
222
223
for identifier_dict in custom_identifiers_dict :
223
- if type (identifier_dict ['name' ]) != str or type (identifier_dict ['labels' ]) != list :
224
+ if type (identifier_dict ['name' ]) is not str or type (identifier_dict ['labels' ]) is not list :
224
225
raise TypeError
225
226
self .identifiers = [identifier ['name' ] for identifier in custom_identifiers_dict ]
226
227
self .identifiers_dict = custom_identifiers_dict
@@ -256,6 +257,7 @@ def __init__(self):
256
257
if custom_languages != '' :
257
258
# Load all custom languages
258
259
for path in custom_languages .split (',' ):
260
+ # noinspection PyBroadException
259
261
try :
260
262
# Decide if the path is a url or local file
261
263
if path .startswith ('http' ):
@@ -302,9 +304,10 @@ def __init__(self):
302
304
'language' : lang ['language' ],
303
305
'markers' : lang ['markers' ]
304
306
})
305
- except :
307
+ except Exception :
306
308
print ('An error occurred in the custom language file (\' ' + path + '\' )' )
307
- print ('Please check the file, or if it represents undefined behavior, create an issue at \' https://github.com/alstr/todo-to-issue-action/issues\' ' )
309
+ print ('Please check the file, or if it represents undefined behavior, '
310
+ 'create an issue at \' https://github.com/alstr/todo-to-issue-action/issues\' ' )
308
311
309
312
# noinspection PyTypeChecker
310
313
def parse (self , diff_file ):
@@ -346,8 +349,8 @@ def parse(self, diff_file):
346
349
continue
347
350
348
351
# Break this section down into individual changed code blocks.
349
- line_numbers = re .finditer (self .LINE_NUMBERS_PATTERN , hunk )
350
- for i , line_numbers in enumerate (line_numbers ):
352
+ line_numbers_iterator = re .finditer (self .LINE_NUMBERS_PATTERN , hunk )
353
+ for i , line_numbers in enumerate (line_numbers_iterator ):
351
354
line_numbers_inner_search = re .search (self .LINE_NUMBERS_INNER_PATTERN , line_numbers .group (0 ))
352
355
line_numbers_str = line_numbers_inner_search .group (0 ).strip ('@@ -' )
353
356
start_line = line_numbers_str .split (' ' )[1 ].strip ('+' )
@@ -367,6 +370,7 @@ def parse(self, diff_file):
367
370
prev_index = len (code_blocks ) - 1
368
371
# Set the end of the last code block based on the start of this one.
369
372
if prev_block and prev_block ['file' ] == block ['file' ]:
373
+ # noinspection PyTypedDict
370
374
code_blocks [prev_index ]['hunk_end' ] = line_numbers .start ()
371
375
code_blocks [prev_index ]['hunk' ] = (prev_block ['hunk' ]
372
376
[prev_block ['hunk_start' ]:line_numbers .start ()])
@@ -405,13 +409,16 @@ def parse(self, diff_file):
405
409
suff_escape_list .append (self ._extract_character (to_escape ['pattern' ]['start' ], 1 ))
406
410
search = to_escape ['pattern' ]['end' ].find (marker ['pattern' ])
407
411
if search != - 1 :
408
- pref_escape_list .append (self ._extract_character (to_escape ['pattern' ]['end' ], search - 1 ))
409
-
410
- comment_pattern = (r'(^[+\-\s].*' +
411
- (r'(?<!(' + '|' .join (pref_escape_list ) + r'))' if len (pref_escape_list ) > 0 else '' ) +
412
- marker ['pattern' ] +
413
- (r'(?!(' + '|' .join (suff_escape_list ) + r'))' if len (suff_escape_list ) > 0 else '' ) +
414
- r'\s*.+$)' )
412
+ pref_escape_list .append (self ._extract_character (to_escape ['pattern' ]['end' ],
413
+ search - 1 ))
414
+
415
+ comment_pattern = (r'(^[+\-\s].*'
416
+ + (r'(?<!(' + '|' .join (pref_escape_list ) + r'))' if len (pref_escape_list ) > 0
417
+ else '' )
418
+ + marker ['pattern' ]
419
+ + (r'(?!(' + '|' .join (suff_escape_list ) + r'))' if len (suff_escape_list ) > 0
420
+ else '' )
421
+ + r'\s*.+$)' )
415
422
comments = re .finditer (comment_pattern , block ['hunk' ], re .MULTILINE )
416
423
extracted_comments = []
417
424
prev_comment = None
@@ -543,15 +550,16 @@ def _extract_issue_if_exists(self, comment, marker, code_block):
543
550
@staticmethod
544
551
def _escape_markdown (comment ):
545
552
# All basic characters according to: https://www.markdownguide.org/basic-syntax
546
- must_escaped = ['\\ ' , '<' , '>' , '#' , '`' , '*' , '_' , '[' , ']' , '(' , ')' , '!' , '+' , '-' , '.' , '|' , '{' , '}' , '~' , '=' ]
553
+ must_escape = ['\\ ' , '<' , '>' , '#' , '`' , '*' , '_' , '[' , ']' , '(' , ')' , '!' , '+' , '-' , '.' , '|' , '{' , '}' , '~' ,
554
+ '=' ]
547
555
548
556
escaped = ''
549
557
550
558
# Linear Escape Algorithm, because the algorithm ends in an infinite loop when using the function 'replace',
551
559
# which tries to replace all backslashes with duplicate backslashes, i.e. also the already other escaped
552
560
# characters.
553
561
for c in comment :
554
- if c in must_escaped :
562
+ if c in must_escape :
555
563
escaped += '\\ ' + c
556
564
else :
557
565
escaped += c
@@ -657,6 +665,7 @@ def _get_milestone(self, comment):
657
665
milestone = int (milestone )
658
666
return milestone
659
667
668
+ # noinspection PyMethodMayBeStatic
660
669
def _should_ignore (self , file ):
661
670
ignore_patterns = os .getenv ('INPUT_IGNORE' , None )
662
671
if ignore_patterns :
0 commit comments