From 1bb18744e5bd44f8a2c75da14165210c06010778 Mon Sep 17 00:00:00 2001 From: Mehdi Boutayeb Date: Sun, 13 Sep 2026 12:19:49 +0200 Subject: [PATCH] Fix invalid escape sequence SyntaxWarnings in source source/common.py and source/process.py build markdown output using string literals with invalid escapes (\|, \#, \+, \-). On Python 3.12+ these emit `SyntaxWarning: invalid escape sequence` at import time (previously a silent DeprecationWarning; slated to become SyntaxError). Escape the backslashes so each literal's value is byte-for-byte identical - the generated markdown is unchanged. Mirrors ruff's W605 autofix. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_014HBQNzAf5C2E3MiJC48HQw --- source/common.py | 2 +- source/process.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/common.py b/source/common.py index 177f01e216..d447970c9f 100644 --- a/source/common.py +++ b/source/common.py @@ -28,7 +28,7 @@ def write_ranking_repo(file_name, method, repos): for idx, repo in enumerate(repos): repo_description = repo['description'] if repo_description is not None: - repo_description = repo_description.replace('|', '\|') # in case there is '|' in description + repo_description = repo_description.replace('|', '\\|') # in case there is '|' in description f.write("| {} | [{}]({}) | {} | {} | {} | {} | {} | {} |\n".format( idx + 1, repo['name'], repo['html_url'], repo['stargazers_count'], repo['forks_count'], repo['language'], repo['open_issues_count'], repo_description, repo['pushed_at'] diff --git a/source/process.py b/source/process.py index d759bd5db8..ec8b824d0b 100644 --- a/source/process.py +++ b/source/process.py @@ -13,14 +13,14 @@ "JavaScript", "Julia", "Kotlin", "Lua", "MATLAB", "Objective-C", "Perl", "PHP", "PowerShell", "Python", "R", "Ruby", "Rust", "Scala", "Shell", "Swift", "TeX", "TypeScript", "Vim-script"] # Escape characters in markdown like # + - etc -languages_md = ["ActionScript", "C", "C\#", "C\+\+", "Clojure", "CoffeeScript", "CSS", "Dart", "DM", "Elixir", "Go", "Groovy", "Haskell", "HTML", "Java", - "JavaScript", "Julia", "Kotlin", "Lua", "MATLAB", "Objective\-C", "Perl", "PHP", "PowerShell", "Python", "R", "Ruby", "Rust", "Scala", "Shell", +languages_md = ["ActionScript", "C", "C\\#", "C\\+\\+", "Clojure", "CoffeeScript", "CSS", "Dart", "DM", "Elixir", "Go", "Groovy", "Haskell", "HTML", "Java", + "JavaScript", "Julia", "Kotlin", "Lua", "MATLAB", "Objective\\-C", "Perl", "PHP", "PowerShell", "Python", "R", "Ruby", "Rust", "Scala", "Shell", "Swift", "TeX", "TypeScript", "Vim script"] table_of_contents = """ * [ActionScript](#actionscript) * [C](#c) -* [C\#](#c-1) -* [C\+\+](#c-2) +* [C\\#](#c-1) +* [C\\+\\+](#c-2) * [Clojure](#clojure) * [CoffeeScript](#coffeescript) * [CSS](#css) @@ -37,7 +37,7 @@ * [Kotlin](#kotlin) * [Lua](#lua) * [MATLAB](#matlab) -* [Objective\-C](#objective-c) +* [Objective\\-C](#objective-c) * [Perl](#perl) * [PHP](#php) * [PowerShell](#powershell)