lablup / lablup/backend.ai

Enable UP047: Simplify generic function syntax (Python 3.12)

Open
#8,331 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.