[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Maciej Górski

Maciej Górski  added the comment:

Thanks for helping me with my very first python contribution! @eric.smith 
@lys.nikolaou

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks, @macgors!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-28 Thread Eric V. Smith

Eric V. Smith  added the comment:


New changeset 7b44ade018cfe6f54002a3cee43e8aa415d4d635 by Maciej Górski in 
branch 'main':
bpo-47129: Add more informative messages to f-string syntax errors (32127)
https://github.com/python/cpython/commit/7b44ade018cfe6f54002a3cee43e8aa415d4d635


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-27 Thread Maciej Górski

Maciej Górski  added the comment:

I agree as well. I will change it to the new version :) Thanks for your input 
in this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-27 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

I like the newest suggestion by @Jelle better as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

>From a suggestion by @Jelle on the python discord server: how about just 
>"f-string: expression required before '!'"?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

Maciej Górski  added the comment:

Understandable. In this case I can maybe propose something along the lines of 
"f-string: empty expression not allowed (Conversion specifier '!' can only 
follow non-empty expressions)", and so on for each of the specifiers.

This way the original message is still present and we just add some more 
information. I'm open to any of your ideas.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'm not convinced this is an improvement. I don't think someone trying '!' in 
an f-string expression happens often enough to worry about that specific error 
message.

And a generic "optional specifier" isn't great. If we're going to do this, it 
should reflect the actual thing that's present: a conversion specifier, a 
format specifier, or debug specifier. And "optional" doesn't add anything, 
since it's actually present in this string.

I'll give it some more thought. I can't come up with an error message I 
actually like. The focus still needs to be on the empty expression.

--
assignee:  -> eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

Change by Maciej Górski :


--
keywords: +patch
pull_requests: +30206
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/32127

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47129] Improve errors messages in f-string syntax errors

2022-03-26 Thread Maciej Górski

New submission from Maciej Górski :

When an empty expression is provided in curly brackets inside an f-string we 
get Syntax Error: "f-string: empty expression not allowed".


This is correct, however error with the same message is raised in the following 
cases: f"{!foo}", f"{!}", f"{:bar}", f"{=}", etc.
For example, should someone make an error and try to negate an expression with 
'!' instead of 'not' (i.e. f"{!True}"), they would get a confusing error, 
saying that the expression is empty, when it isn't. 

I propose we raise an error with the message: "f-string: optional specifier 
'%c' must follow a non-empty expression.

--
components: Parser
messages: 416069
nosy: lys.nikolaou, macgors, pablogsal
priority: normal
severity: normal
status: open
title: Improve errors messages in f-string syntax errors

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com