Fix Codeblock False Positives#3517
Conversation
Update regex comment Co-authored-by: Joe Banks <joe@jb3.dev>
Invalidated by push of d92d178
| """, | ||
| re.DOTALL | re.VERBOSE | ||
| ) | ||
| _RE_CODE_BLOCK_REGEX = regex.compile(_RE_CODE_BLOCK.pattern, regex.DOTALL | regex.VERBOSE) |
There was a problem hiding this comment.
Am I missing something here or is this just a copy of _RE_CODE_BLOCK?
There was a problem hiding this comment.
Yes and no.
So, it is a copy, but it uses the regex module, rather than the re module, because regex.finditer allows to pass an additional overlapped parameter, which I need in the find_faulty_code_blocks function.
The reason why I didn't omit the _RE_CODE_BLOCK variable entirely just comes down to code highlighting. Let me show you with this image:

As you can see, at least in PyCharm, there is no default regex-highlighting when using the regex.compile function, but there is when using the re.compile function.
There was a problem hiding this comment.
Oh yeah I missed that it's different library. I don't find syntax highlighting to be a compelling reason to create this confusion, but don't feel strongly.
There was a problem hiding this comment.
I added a comment explaining the decision to avoid further confusion
Fixes #3515
Fixes the described issue and adds some unit tests to cover common cases.
Also updates the bad_ticks error message to work with the new, more flexible, variable ticks approach.