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

Return annotation brackets #2990

merged 12 commits into from Apr 9, 2022


Copy link

@jpy-git jpy-git commented Apr 2, 2022


Closes #2041 and #2699. Allows us to better control placement of return annotations.

a) removes redundant parens:

def foo() -> (int): ...


def foo() -> int: ...

b) moves very long type annotations onto their own line:

def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
    return 2


def foo() -> (
    return 2

Checklist - did you ...

  • Add a CHANGELOG entry if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Copy link

github-actions bot commented Apr 2, 2022

diff-shades results comparing this PR (20649d1) to main (9b30740). The full diff is available in the logs under the "Generate HTML diff report" step.

╭─────────────────────── Summary ────────────────────────╮
│ 2 projects & 2 files changed / 28 changes [+17/-11]    │
│                                                        │
│ ... out of 2 178 027 lines, 10 484 files & 23 projects │

Differences found.

What is this? | Workflow run | diff-shades documentation

Copy link

@JelleZijlstra JelleZijlstra left a comment

Thanks! Some small feedback Outdated Show resolved Hide resolved
tests/data/ Show resolved Hide resolved
jpy-git and others added 2 commits Apr 2, 2022
Co-authored-by: Jelle Zijlstra <>
@ichard26 ichard26 self-requested a review Apr 5, 2022
Copy link

@ichard26 ichard26 left a comment

Excellent work @jpy-git 🎉

@ichard26 ichard26 linked an issue Apr 9, 2022 that may be closed by this pull request
@ichard26 ichard26 merged commit 98fccce into psf:main Apr 9, 2022
40 checks passed
@jpy-git jpy-git deleted the return_annotation_brackets branch Apr 9, 2022
felix-hilden added a commit to felix-hilden/black that referenced this pull request Jun 24, 2022
ichard26 added a commit that referenced this pull request Jun 27, 2022
Covers GH-2926, GH-2990, GH-2991, and GH-3035.

Co-authored-by: Jelle Zijlstra <>
Co-authored-by: Richard Si <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

3 participants