Skip to main content
Glama
enkryptai

Enkrypt AI Secure MCP Gateway

Official
by enkryptai
remove_useless_fstrings.py1.3 kB
import re import sys from pathlib import Path def has_fstring_without_placeholders(line): return re.search(r'^\s*(?:[^#\n]*?)f"[^{}]*?"', line) or re.search(r"^\s*(?:[^#\n]*?)f'[^{}]*?'", line) def fix_line(line): return line.replace('f"', '"').replace("f'", "'") # Handle command line arguments for pre-commit if len(sys.argv) > 1: # Pre-commit passes filenames as arguments files_to_process = sys.argv[1:] else: # Default behavior - process all Python files in src files_to_process = [str(f) for f in Path("src").rglob("*.py")] count = 0 changed_files = 0 for file_path in files_to_process: file = Path(file_path) if file.exists() and file.suffix == ".py": new_lines = [] file_changed = False for line in file.read_text(encoding="utf-8").splitlines(keepends=True): if has_fstring_without_placeholders(line): new_line = fix_line(line) new_lines.append(new_line) file_changed = True count += 1 else: new_lines.append(line) if file_changed: file.write_text("".join(new_lines), encoding="utf-8") changed_files += 1 if count > 0: print(f"Cleaned {count} unnecessary f-strings from {changed_files} files")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/enkryptai/secure-mcp-gateway'

If you have feedback or need assistance with the MCP directory API, please join our Discord server