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

Post PyCon PEP cleanup #43

Merged
merged 7 commits into from
May 30, 2024
Merged

Post PyCon PEP cleanup #43

merged 7 commits into from
May 30, 2024

Conversation

pauleveritt
Copy link
Collaborator

@pauleveritt pauleveritt commented May 28, 2024

More focus on protocols, remove extraneous sections.

@pauleveritt pauleveritt changed the title pe-post-pycon-pep Post PyCon PEP cleanup May 28, 2024
@pauleveritt
Copy link
Collaborator Author

@lysnikolaou I worked with @jimbaker the last week to wrap up the PEP. It's in good shape for review. Jim's cleanup really helped readability.

It tracks some changes in main (3.14) for how Protocols can be used in structural pattern matching, so the examples won't run on the 3.12-based tag string branch.

Do you mind giving it a look?

pep.rst Outdated Show resolved Hide resolved
@rmorshea
Copy link
Collaborator

Does anyone know if peps.python.org supports admonitions? (e.g. .. note::). I kind of suspect it does since I've seen tables and other more complicated directives used in PEPs. If so, there are a few places that might benefit from that extra formatting flourish.

@lysnikolaou
Copy link
Contributor

@lysnikolaou I worked with @jimbaker the last week to wrap up the PEP. It's in good shape for review. Jim's cleanup really helped readability.

It tracks some changes in main (3.14) for how Protocols can be used in structural pattern matching, so the examples won't run on the 3.12-based tag string branch.

Do you mind giving it a look?

Thanks for the ping @pauleveritt! I'll take a look later today.

Does anyone know if peps.python.org supports admonitions?

Yes, it does. There's a list of what the CPython documentation supports on this devguide page and I'm pretty sure that peps.python.org support all of that as well.

Copy link
Contributor

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

I had a brief pass over the changes, which look good to me! Let's merge this, so that I can go through the PEP as a whole one more time and review it more deeply then.

@pauleveritt pauleveritt merged commit 9557158 into main May 30, 2024
def greet(*args):
salutation, recipient, *_ = args
_, getvalue = recipient
return f"{salutation.title()} {getvalue().upper()}!"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I missed an extra strip() here. That, or removing the space. I might argue against the strip() just to have one less thing for the user to think about, but either way:

Suggested change
return f"{salutation.title()} {getvalue().upper()}!"
return f"{salutation.title()}{getvalue().upper()}!"

Or

Suggested change
return f"{salutation.title()} {getvalue().upper()}!"
return f"{salutation.title().strip()} {getvalue().upper()}!"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do strip() in the other examples so I'll follow your first example. I don't believe any of the other examples have the extra-space problem.

Since this branch is deleted, I've started a new branch where I'll apply comments.

pep.rst Outdated Show resolved Hide resolved
@jimbaker jimbaker deleted the pe-post-pycon-pep branch May 30, 2024 21:46
@pauleveritt
Copy link
Collaborator Author

I had a brief pass over the changes, which look good to me! Let's merge this, so that I can go through the PEP as a whole one more time and review it more deeply then.

@lysnikolaou Think you have time to review more deeply before we announce to broader group?

@lysnikolaou
Copy link
Contributor

Sure! I'll have a look and post any comments I have later today. Not sure what the best place to do that would be though, I'll probably just open a new PR with my suggestions if I have any.

@@ -194,7 +227,7 @@ For example:
Valid Tag Names
---------------

The tag name can be any **undotted** name that isn't already an existing valid
The tag name can be any *undotted* name that isn't already an existing valid
Copy link

@davepeck davepeck Jun 14, 2024

Choose a reason for hiding this comment

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

Out of curiosity, I'd love to understand the instinct here. I could imagine wanting, at minimum, dots:

import somelib

x = somelib.sometag"..."

Beyond dots, JavaScript allows tags to be arbitrary expressions. Perhaps that'd get too awkward in python?:

x = (lambda *args: args)"..."

Then again, PEP 614 allows for:

@(lambda *args: args)
def foo():
    ...

In any case, thank you... excited about this PEP!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will let @jimbaker address the motivation here. Glad you're excited about the PEP, lots we can do with this.

Copy link
Owner

Choose a reason for hiding this comment

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

@davepeck in principle we could allow both dotted names and arbitrary expressions, since both are currently invalid syntax. This was briefly mentioned here in the bikeshed issue, #3 (comment)

Given how much namespaces are used in current code - and the last admonition of import this/Zen of Python, "Namespaces are one honking great idea -- let's do more of those!", perhaps we should relax this constraint; and possibly the use of parenthesized expression as well (to keep it reasonable, at least for human readers).

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I would also vote for a more relaxed syntax here. Dotted names at least, or even PEP 614-compatible syntax.

Copy link
Owner

Choose a reason for hiding this comment

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

Agreed. Note that the syntax for PEP 614 is somewhat different because the @ introduces different opportunities for avoiding ambiguity, such as named expressions need not be parenthesized (https://peps.python.org/pep-0614/#named-expressions-need-not-be-parenthesized).

But atomic expressions should work (https://docs.python.org/3.9/reference/expressions.html#atoms)

Of course this does allow code like the following

(yield foo)"Hello, {name}"

where the tag function is provided by a value sent into the wrapping generator, but that's true of the generalization supported by PEP 614, and likely not not seen in actual decorator usage.

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.

None yet

5 participants