Drop Python 2 support#31
Open
JuanTecedor wants to merge 6 commits into
Open
Conversation
Kamforka
reviewed
Jun 9, 2026
| + ")" | ||
| ) | ||
| regex.append({"type": "ip", "regex": re.compile(r"{}".format(r))}) | ||
| regex.append({"type": "ip", "regex": re.compile(r)}) |
Collaborator
There was a problem hiding this comment.
Please make sure that leaving r"" won't cause any issues with the regex pattern rendering
Contributor
Author
There was a problem hiding this comment.
Fairly sure r"{}".format(r) is no-OP equivalent.
Quick test with https://hypothesis.readthedocs.io/en/latest/:
import re
from hypothesis import given, strategies as st
from hypothesis.provisional import domains
regexp = (
"("
+ "([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|"
+ "([0-9a-fA-F]{1,4}:){1,7}:|"
+ "([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|"
+ "([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|"
+ "([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|"
+ "([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|"
+ "([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|"
+ "[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|"
+ ":((:[0-9a-fA-F]{1,4}){1,7}|:)|"
+ "fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|"
+ "::(ffff(:0{1,4}){0,1}:){0,1}"
+ r"((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}"
+ "(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|"
+ "([0-9a-fA-F]{1,4}:){1,4}:"
+ r"((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}"
+ "(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
+ ")"
)
original_regex = re.compile(r"{}".format(regexp))
new_regex = re.compile(regexp)
@given(
st.text()
| domains()
| st.ip_addresses()
| st.none()
| st.integers()
| st.floats()
| st.binary()
)
def test_regex_refactor(data: str):
old = original_regex.search(str(data))
new = new_regex.search(str(data))
if old is None or new is None:
assert old == new
else:
assert old.group() == new.group()
assert old.span() == new.span()$ pytest tests/test_regex.py
test session starts ...
1 passed in 0.21s
Contributor
Author
There was a problem hiding this comment.
I also compared the original_regex == new_regex and they are the same 😄
| with open( | ||
| "%s/output/output.json" % self.job_directory, mode="w" | ||
| ) as f_output: | ||
| output_path = f"{self.job_directory}/output" |
Collaborator
There was a problem hiding this comment.
Suggested change
| output_path = f"{self.job_directory}/output" | |
| output_dir = f"{self.job_directory}/output" |
| fixture_file = open(path + "/" + fixture_path) | ||
| input = fixture_file.read() | ||
| fixture_file.close() | ||
| with open(path + "/" + fixture_path) as fixture_file: |
Collaborator
There was a problem hiding this comment.
I think for these kind of syntaxes we can start using os.path.join to be future proof in case of different platforms with different path separators
Kamforka
reviewed
Jun 9, 2026
Co-authored-by: Kamforka <antalszabolcs01@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
# -*- coding: utf-8 -*-formfrom builtins import str as unicode(all text should be unicode https://docs.python.org/3/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit)withstatement instead of rawopensys.version_infochecks and brancheshttps://docs.python.org/3/whatsnew/3.0.html