add Python version comment

This commit is contained in:
David Lord 2025-05-28 12:09:42 -07:00
parent 9c11dd65ff
commit 0547cd6c58
No known key found for this signature in database
GPG Key ID: 43368A7AA8CC5926

View File

@ -54,17 +54,16 @@ def build_pattern(ranges):
def main(): def main():
"""Build the regex pattern and write it to """Build the regex pattern and write it to ``jinja2/_identifier.py``."""
``jinja2/_identifier.py``.
"""
pattern = build_pattern(collapse_ranges(get_characters())) pattern = build_pattern(collapse_ranges(get_characters()))
filename = os.path.abspath( filename = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "src", "jinja2", "_identifier.py") os.path.join(os.path.dirname(__file__), "..", "src", "jinja2", "_identifier.py")
) )
with open(filename, "w", encoding="utf8") as f: with open(filename, "w", encoding="utf8") as f:
f.write("# generated by scripts/generate_identifier_pattern.py")
f.write(f"# Python {sys.version_info[0]}.{sys.version_info[1]}\n")
f.write("import re\n\n") f.write("import re\n\n")
f.write("# generated by scripts/generate_identifier_pattern.py\n")
f.write("pattern = re.compile(\n") f.write("pattern = re.compile(\n")
f.write(f' r"[\\w{pattern}]+" # noqa: B950\n') f.write(f' r"[\\w{pattern}]+" # noqa: B950\n')
f.write(")\n") f.write(")\n")