Skip to content

Conversation

@sobolevn
Copy link
Member

@sobolevn sobolevn commented Apr 1, 2025

It works!

Снимок экрана 2025-04-01 в 18 49 46

https://www.youtube.com/watch?v=wgxBHuUOmjA

Happy 1st April, everyone!

@pablogsal
Copy link
Member

pablogsal commented Apr 1, 2025

⚠️ You have been identified by the parser correctness brigade. This incident will be reported ⚠️

sm7og

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I think maybe should depend on the mood of the interpreter and thus a random.random() should be added as well to have unpredictable branches

Copy link

@Bobronium Bobronium left a comment

Choose a reason for hiding this comment

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

LGTM! Maybe.

@ConfirmedPlayer
Copy link

Approve

invalid_maybe_stmt:
| "maybe" named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
| a="maybe" a=named_expression ':' NEWLINE !INDENT {
RAISE_INDENTATION_ERROR("expected an indented block after 'if' statement on line %d", a->lineno) }
Copy link

Choose a reason for hiding this comment

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

Suggested change
RAISE_INDENTATION_ERROR("expected an indented block after 'if' statement on line %d", a->lineno) }
RAISE_INDENTATION_ERROR("expected an indented block after 'maybe' statement on line %d", a->lineno) }

@Bobronium
Copy link

Bobronium commented Apr 1, 2025

We might want to add more pythonic keywords for old elif and else as well:

I propose:
elif -> ormay
else -> otherwise

maybe answer == 42:
    print("Found the meaning")
ormay answer == 41: 
    print("So close")
otherwise:
    print("Keep searching")

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Please include a What's New entry and NEWS file.

@bedevere-app
Copy link

bedevere-app bot commented Apr 1, 2025

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@yuiauo
Copy link

yuiauo commented Apr 1, 2025

I think maybe should depend on the mood of the interpreter and thus a random.random() should be added as well to have unpredictable branches

Perfect feature to be added in pytest lib

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Nice use of soft keywords.

Please update pattern matching guards to allow the new syntax:

>>> match match:
...     case case maybe maybe:
...          ...

As well as ternary maybe:

>>> maybe maybe maybe else maybe


// maybe_stmt:
// | invalid_maybe_stmt
// | "maybe" named_expression ':' block elif_stmt

Choose a reason for hiding this comment

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

Suggested change
// | "maybe" named_expression ':' block elif_stmt
// | "maybe" named_expression ':' block elmaybe_stmt

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

You have no idea how tempted I am to add the release blocker label.

@pablogsal
Copy link
Member

pablogsal commented Apr 1, 2025

You have no idea how tempted I am to add the release blocker label.

Don't worry I will do it for you 🤣

The steering council will resist!

@pablogsal
Copy link
Member

pablogsal commented Apr 1, 2025

Nice use of soft keywords.

Please update pattern matching guards to allow the new syntax:

>>> maybe = 42

>>> match maybe:

...     case maybe maybe maybe:

...          ...

...

As well as ternary maybe:

>>> maybe maybe maybe else maybe

42

Btw: You laugh but I am moderately confident the PEG parser can support this atrocity like Atlas holding the world 🌍🙂

@hugovk hugovk added the needs backport to 3.9 only security fixes label Apr 1, 2025
@hugovk hugovk added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Apr 1, 2025
@ambv
Copy link
Contributor

ambv commented Apr 1, 2025

Btw: You laugh but I am moderately confident the PEG parser can support this atrocity like Atlas holding the world 🌍🙂

This would be the end of Black as we know it. Maybe.

@AA-Turner AA-Turner added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 1, 2025
@ZeroIntensity ZeroIntensity added type-feature A feature request or enhancement type-security A security issue labels Apr 1, 2025
@CuriousLearner
Copy link
Member

Finally, Python achieves peak performance by just skipping the hard parts. Truly an if you can't solve it, ignore it moment. Guido would be proud. 🐍✨

But honestly, at this point, I don't want Python to handle exceptions. I want it to handle my emotions.

@blaisep
Copy link
Contributor

blaisep commented Apr 1, 2025

I believe that functions using maybe handle exceptions better when you wrap them with the decorator @whatsinit_forme

@pablogsal
Copy link
Member

pablogsal commented Apr 1, 2025

Nice use of soft keywords.
Please update pattern matching guards to allow the new syntax:

>>> maybe = 42

>>> match maybe:

...     case maybe maybe maybe:

...          ...

...

As well as ternary maybe:

>>> maybe maybe maybe else maybe

42

Btw: You laugh but I am moderately confident the PEG parser can support this atrocity like Atlas holding the world 🌍🙂

I had to try:

lol

@sobolevn I pushed a commit to this PR. It's not on the PEP ( 😆 ) but @brandtbucher has a way to nerdsnipe me :)

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.

Excellent work!

@sobolevn
Copy link
Member Author

sobolevn commented Apr 2, 2025

Thanks everyone, I hope we had fun on this 1st April together :)
Now it is time to close this PR :(

@ZeroIntensity
Copy link
Member

Long live the BDFL.

@corona10
Copy link
Member

corona10 commented Apr 2, 2025

The service of the SC will be continued.

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

Labels

awaiting merge DO-NOT-MERGE interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes release-blocker skip issue skip news type-feature A feature request or enhancement type-security A security issue

Projects

Development

Successfully merging this pull request may close these issues.