Enable UP047: Simplify generic function syntax (Python 3.12)
Open
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 14h 15m
- Merged PRs (30d)
- 335
Description
## Rule
**UP047**: `non-pep695-generic-function`
## Purpose
Modernize generic function definitions to Python 3.12 PEP 695 syntax.
## Example
```python
# 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
Contributor guide
Assessment
This issue has not been assessed yet.