Rule
UP047: non-pep695-generic-function
Purpose
Modernize generic function definitions to Python 3.12 PEP 695 syntax.
Example
# Before (old style)
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T:
return items[0]
# After (Python 3.12 style)
def first[T](items: list[T]) -> T:
return items[0]
Auto-fix
✅ Available
Notes
- Part of Python 3.12 modernization effort
- Eliminates boilerplate TypeVar definitions
- Cleaner and more readable generic function syntax
JIRA Issue: BA-4028