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
merged 12 commits into from Apr 9, 2022
Merged

Conversation

jpy-git
Copy link
Contributor

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

Description

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

a) removes redundant parens:

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

becomes

def foo() -> int: ...

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

def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
    return 2

becomes

def foo() -> (
    intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
):
    return 2

Checklist - did you ...

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

@github-actions
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
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Thanks! Some small feedback

CHANGES.md Outdated Show resolved Hide resolved
tests/data/return_annotation_brackets.py Show resolved Hide resolved
jpy-git and others added 2 commits Apr 2, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@ichard26 ichard26 self-requested a review Apr 5, 2022
Copy link
Collaborator

@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 <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants