Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format type parameters on functions and classes #5931

Closed
konstin opened this issue Jul 20, 2023 · 0 comments · Fixed by #6161
Closed

Format type parameters on functions and classes #5931

konstin opened this issue Jul 20, 2023 · 0 comments · Fixed by #6161
Assignees
Labels
formatter Related to the formatter python312 Related to Python 3.12

Comments

@konstin
Copy link
Member

konstin commented Jul 20, 2023

PEP 695 introduces type parameters on function and classes in python 3.12, which are currently not considered when formatting, but should be added:

class ClassA[T: str]:
    def method1(self) -> T:
        ...

def func[T](a: T, b: T) -> T:
    ...

Their implementation can likely reuse larger parts of dict comprehensions. See psf/black#3703 for the black implementation

@konstin konstin added the formatter Related to the formatter label Jul 20, 2023
@MichaReiser MichaReiser added this to the Formatter: Alpha milestone Jul 31, 2023
zanieb added a commit that referenced this issue Aug 2, 2023
…6161)

Part of #5062 
Closes #5931

Implements formatting of a sequence of type parameters in a dedicated
struct for reuse by classes, functions, and type aliases (preparing for
#5929). Adds formatting of type parameters in class and function
definitions — previously, they were just elided.
@zanieb zanieb added the python312 Related to Python 3.12 label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter python312 Related to Python 3.12
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants