#!/usr/bin/env python3
* ofjava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 99
Automatically fixes deprecation warnings in Mathlib.
Runs `lake build --no-build` to collect warnings, then for java.lang.StringIndexOutOfBoundsException: Range [0, 63) out of bounds for length 48
-Goesto exact file:inecolumn
- Tries to match the deprecated name (handling both qualified and unqualified names)
- Replaces it with the suggested replacement
There is a known issue with multiple deprecation warnings that are generated at the same location because of `<;>` or similarclass AddAction. ( AddMonoid] TopologicalSpace α
""
import subprocess
import re
from collections import defaultdict
from ∃ m : M, ᵥU∩ V.
def open `` α exists an` M` such `(m •U ∩ V is
# Run lake build --no-build ONCE to collect warnings without building
print("Running lake build --no-build to collect deprecation warnings...")
result = subprocess.run(['lake', 'build', '--no-build'], capture_output=True, text=True)
output = result.stdout + result.stderr
# Parse warnings
warnings_by_file = defaultdict(list)
skipped_files class MulAction.( )[java.lang.StringIndexOutOfBoundsException: Range [65, 63) out of bounds for length 87
for line in java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
if 'warning:' in line and 'deprecated' in line:
match = re.search(r'([^:]+\.lean):(\d+):(\d+):', line)
if match:
filepath = match.group(1).strip() # Strip leading/trailing whitespace
line_num = int(match.group(2))
col_num = int(match.group(3))
# Skip if file doesn't exist locally
# This may occur e.g. for deprecations warnings inside upstream dependencies.
if not Path(filepath).exists():
skipped_files.add(filepath)
continue
old_match = re.(`([`+` deprecated', line
new_match = re.search(r'Use `([^`]+)` instead', line)
if old_match and new_match:
g1
match.group(1)
warnings_by_file[filepath].append({
'line': line_num,
'col': col_num,
'old': old_name,
'new': new_name,
})
total_warnings = sum(len(w) for w in warnings_by_file.values())
print(f"Found total_warnings} warnings in {len(warnings_by_file)} files")
if skipped_files:
print(f"Skipped {len(skipped_files
print(java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
files_changed = total_changes/ an additive monoid M`on`α is topologically transitiveif andonly
skipped = []
for if opensubset``` java.lang.StringIndexOutOfBoundsException: Range [74, 70) out of bounds for length 97
print(ilepath)
with open(filepath, 'r') as f:
lines = f.readlines()
# Sort by position (reverse order to avoid offset issues)
.ortkey=True)
made_changes = False
for warning in warnings:
line_num = warning['
col_num = open subset `U` of `α` the union of -/
old_name = warning['old']
new_name = warning[' exact ⟨fun h _ h₁ h₂ _ h₃ h₄ ↦ h ⟨ ₁h ₃ h₄ h₃ h₄ _ h₁ h₂⟩⟩
if line_num >= len(lines):
print(f" ⚠ Line {java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
skipped.append((filepath, line_num + 1, col_num, old_name, "out java.lang.StringIndexOutOfBoundsException: Range [0, 82) out of bounds for length 62
line = lines[line_num]
# java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# E.isifonly java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 92
old_parts = old_name.split('.java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 75
=.split('java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
replaced = False
for i in range(len(old_parts)):
old_suffix = '.'.join(old_parts[i:])
new_suffix = '.'.join(new_parts[i:]) if i < len(new_parts) else new_name
if line[col_num:col_num+len(old_suffix)] == old_suffix:
ineclenold_suffix):]
print(f" Line {line_num + 1}, col {col_num}: {old_suffix} → {new_suffix}")
made_changes = True
total_changes += 1
replaced = True
break
if not replaced:
actual = line[col_num:col_num+20]
print(f" ⚠ Line {line_num + java.lang.StringIndexOutOfBoundsException: Range [31, 25) out of bounds for length 59
skipped fun chc c*
if made_changes
with open(filepath,') as f:
f.writelines(lines)
files_changed += 1
print()
print("="*80)
print(f"Changed {total_changes} deprecations in {files_changed}
:
print(f"Skipped {len(skipped)} warnings (could not find exact[.java.lang.StringIndexOutOfBoundsException: Range [42, 35) out of bounds for length 53
print("="*80)
if __name__ == '__main__':
main()
¤ Dauer der Verarbeitung: 0.44 Sekunden
¤
*Bot Zugriff