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

Redundant parentheses around return annotation #2041

Closed
NeilGirdhar opened this issue Mar 12, 2021 · 1 comment · Fixed by #2990
Closed

Redundant parentheses around return annotation #2041

NeilGirdhar opened this issue Mar 12, 2021 · 1 comment · Fixed by #2990
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@NeilGirdhar
Copy link

def infer_encoding_trajectory(encoding: EncodingElement,
                              observation: PoolingMessage,
                              prediction: PredictionMessage,
                              weights: hk.Params,
                              rng: Generator,
                              iterations: int) -> (
                                  tuple[EncodingState, EncodingTrajectory]):

became

def infer_encoding_trajectory(
    encoding: EncodingElement,
    observation: PoolingMessage,
    prediction: PredictionMessage,
    weights: hk.Params,
    rng: Generator,
    iterations: int,
) -> (tuple[EncodingState, EncodingTrajectory]):

The parentheses were only there to allow wrapping and should have been removed. In general, black doesn't need to preserve parentheses around an entire expression, including a type annotation.

@NeilGirdhar NeilGirdhar added the T: bug Something isn't working label Mar 12, 2021
@JelleZijlstra
Copy link
Collaborator

I agree, a PR would be welcome. In general, there's a number of places where Black should remove parentheses that it currently keeps. From past experience it's tricky sometimes to remove parentheses without causing stability bugs, but maybe in this context it won't be too bad.

@ichard26 ichard26 added T: style What do we want Blackened code to look like? F: parentheses Too many parentheses, not enough parentheses, and so on. and removed T: bug Something isn't working labels Mar 12, 2021
@ichard26 ichard26 added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label May 30, 2021
@JelleZijlstra JelleZijlstra changed the title Unnecessary parentheses preserved in type annotation Redundant parentheses around return annotation Jan 29, 2022
@jpy-git jpy-git mentioned this issue Apr 2, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants