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

PEP 677: Include more rejected alternatives #2219

Merged
merged 6 commits into from
Jan 11, 2022

Conversation

stroxler
Copy link
Contributor

@stroxler stroxler commented Jan 9, 2022

Adding more options that came up in typing-sig and python-dev discussion.

- Rust-style syntax
- Forced outer parentheses
- Improving readability of existing callable type
@stroxler stroxler marked this pull request as ready for review January 9, 2022 17:36
@stroxler stroxler requested a review from gvanrossum as a code owner January 9, 2022 17:36
pep-0677.rst Outdated Show resolved Hide resolved
pep-0677.rst Outdated Show resolved Hide resolved
@stroxler stroxler requested a review from a team as a code owner January 10, 2022 01:34
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits.

pep-0677.rst Outdated Show resolved Hide resolved
pep-0677.rst Outdated Show resolved Hide resolved
pep-0677.rst Outdated
Comment on lines 906 to 909
- We agree that it might make sense to encourage outer parentheses in several
cases, particularly callable types in function return annotations. But we
believe it is more appropriate to encourage this in style guides, linters,
and autoformatters than to bake it into the parser and throw syntax errors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this entire example looks unPythonic, and even if such a function would make sense, I'd probably use a type alias to make the return type less look like line noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified the example a bit and added a bullet about type aliasing as a solution.

Although I have some skepticism about type aliases as a general answer to complex types. Based on the production typed-python code I see I, developers seem hesitant to use them (at least at Meta).

I can understand why. Most code forms a graph where you constantly have to jump-to-source to understand it. One nice thing about types is that they normally speak for themselves. Once we use type aliases, that becomes less true - readers might have to jump hundreds of lines to the top of a module to see what a type actually represents.

This isn't necessarily a bad thing since type aliases provide abstraction and one kind of readability, but there is definitely a cost and it seems to me that many developers don't want to pay it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it depends on lots of things. But I don’t want to feel that we have to do something just because Facebook coders prefer it. There’s a whole community here, and some people are already concerned that Python is more and more being controlled by enterprise developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants