Skip to content

Enable UP047: Simplify generic function syntax (Python 3.12) #8235

@HyeockJinKim

Description

@HyeockJinKim

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions