You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by Daniel Standish <da...@astronomer.io.INVALID> on 2022/09/21 00:32:14 UTC

[DISCUSS] string normalization in black

Black, our python formatter, can "normalize" strings to prefer double
quotes, and we disable this feature.

I have always been a single quotes person unless using f-string and
supported disabling normalization when we introduced black.

But lately, black’s string normalization has seemed more appealing to me.
 for two reasons… one is when i’m searching the codebase for something that
i know is a string, i have to search for it two times, once for each flavor
of quote.  the other is simply the noise / friction / decisionmaking about
choosing when to use which, particularly when the area of code uses both in
close proximity.

this isn't gonna win the award for most important discussion of the
year...  but i just wanted to test the waters and see if others have a
similar feeling, or generally people would prefer to leave well-enough
alone.

thanks

Re: [DISCUSS] string normalization in black

Posted by "Ferruzzi, Dennis" <fe...@amazon.com.INVALID>.
+1 non-binding to starting the lazy consensus?  :P


________________________________
From: Daniel Standish <da...@astronomer.io.INVALID>
Sent: Wednesday, September 21, 2022 9:55 AM
To: dev@airflow.apache.org
Subject: RE: [EXTERNAL][DISCUSS] string normalization in black


CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.


Opinion: Adding a lazy consensus thread will not hurt and I think it should happen

Sure, can do

Re: [DISCUSS] string normalization in black

Posted by Daniel Standish <da...@astronomer.io.INVALID>.
>
> Opinion: Adding a lazy consensus thread will not hurt and I think it
> should happen


Sure, can do

>

Re: [DISCUSS] string normalization in black

Posted by Jarek Potiuk <ja...@potiuk.com>.
Opinion: Adding a lazy consensus thread will not hurt and I think it
should happen -  for the record and for people who might be busy.

I think it's easy to miss the fact that a decision was made in a [DISCUSS]
thread. That's the main purpose of the subject prefixes - to drag attention
for people who are busy and do not read all the emails [VOTE] and [LAZY
CONSENSUS] would surely drag attention.

This was - I think - one of the reasons we had a bit of difficulty/
communication issue when I raised the PRs for ("__future__. annotations") -
it seemed we had consensus but it was all in the [DISCUSS] thread and it
was missed by some people who do not spend a lot of time following all the
discussions happening in the devils (and are not able to parse all the
answers in the long thread to understand that consensus was reached there).

The problem with [LAZY CONSENSUS] is that people answer it with +1 which -
by definition - they should not if they are ok with it :). But that's a
completely different story :)

J.


On Wed, Sep 21, 2022 at 6:35 PM Kaxil Naik <ka...@gmail.com> wrote:

> +1 for string normalization.
>
> I love double quoted strings anyways :)
>
> On Wed, 21 Sep 2022 at 16:46, Daniel Standish
> <da...@astronomer.io.invalid> wrote:
>
>> OK seems like all are in favor.  Do we even need a vote?  I guess lazy
>> consensus still applies even when you don't formally call for a lazy
>> consensus vote.  So I reckon I won't bother.
>>
>> But the implementation.... to @Jed Cunningham <je...@astronomer.io>'s
>> point we can wait until closer to 2.5.  And I'll connect with folks on
>> slack on other details.  But the main decision, to remove `
>> --skip-string-normalization` or not (which is the main question here)
>> seems resolved.
>>
>> Thanks
>>
>

Re: [DISCUSS] string normalization in black

Posted by Kaxil Naik <ka...@gmail.com>.
+1 for string normalization.

I love double quoted strings anyways :)

On Wed, 21 Sep 2022 at 16:46, Daniel Standish
<da...@astronomer.io.invalid> wrote:

> OK seems like all are in favor.  Do we even need a vote?  I guess lazy
> consensus still applies even when you don't formally call for a lazy
> consensus vote.  So I reckon I won't bother.
>
> But the implementation.... to @Jed Cunningham <je...@astronomer.io>'s point
> we can wait until closer to 2.5.  And I'll connect with folks on slack on
> other details.  But the main decision, to remove `
> --skip-string-normalization` or not (which is the main question here)
> seems resolved.
>
> Thanks
>

Re: [DISCUSS] string normalization in black

Posted by Daniel Standish <da...@astronomer.io.INVALID>.
OK seems like all are in favor.  Do we even need a vote?  I guess lazy
consensus still applies even when you don't formally call for a lazy
consensus vote.  So I reckon I won't bother.

But the implementation.... to @Jed Cunningham <je...@astronomer.io>'s point
we can wait until closer to 2.5.  And I'll connect with folks on slack on
other details.  But the main decision, to remove `
--skip-string-normalization` or not (which is the main question here) seems
resolved.

Thanks

Re: [DISCUSS] string normalization in black

Posted by Ash Berlin-Taylor <as...@apache.org>.
> Happy to adapt to any style as long as I don't even have to think about it and my personal preferences are not important here.

That.
On Sep 21 2022, at 12:45 pm, Jarek Potiuk <ja...@potiuk.com> wrote:
> Yeah! Heated discussions! Tabs vs. Spaces.
>
> I am also full in for consistency. I think where there are no clear arguments to do this or that, for me consistency trumps any individual preference/style (especially when it is backed with automation that will correct things for you and will not put any extra burden on maintainers having to control it).
> One of my friends in Poland had the rather vulgar saying "Lepiej ch..o ale jednakowo" (Those who know, will know) - very free translation is "Better sh..ty but consistently" and I fully agree with it.
>
> Happy to adapt to any style as long as I don't even have to think about it and my personal preferences are not important here.
>
> J.
>
>
> On Wed, Sep 21, 2022 at 9:03 AM Bartłomiej Hirsz <bartek.hirsz@gmail.com (mailto:bartek.hirsz@gmail.com)> wrote:
> > The formatting discussions are always the most heated ones :) I'm for normalization - we have ugly mix of both and I'm down for whatever but to be consistent. I wouldn't worry about git history or cherry picks. We had several PRs recently that touched almost every file anyway (like improving our imports). And number of changes per file doesn't matter since later it will be handled by precommit before adding your new code anyway.
> >
> > Regarding replacing "string with '" to 'string with "' - this cannot be done automatically because in many cases it was done deliberately. For example, if someone wants to write an English sentence: "It'll go nicely". The (ugly) solution for this, if someone would really want to use one type of quote marks, would be using triple single quota for such cases.
> > śr., 21 wrz 2022 o 08:54 Pankaj Koti <pa...@astronomer.io.invalid> napisał(a):
> > > Correction in my previous email. pre-commit hook double-quote-string-fixer too does not seem to work well for f-strings with a mix of double and single quotes (meaning does not convert a f-string which has outer quotes as double and inner quotes as single). It just skips it if the string is like the below:
> > > f"hello how are you, my name is 'Pankaj', I hope you're well"
> > >
> > >
> > > Regards,
> > >
> > >
> > >
> > >
> > > Pankaj Koti
> > >
> > >
> > >
> > > Senior Software Engineer, OSS Engineering Team.
> > > Location: Pune, India
> > >
> > >
> > > Timezone: Indian Standard Time (IST)
> > >
> > >
> > > Email: pankaj.koti@astronomer.io (mailto:pankaj.koti@astronomer.io)
> > >
> > >
> > > Mobile: +91 9730079985
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Wed, Sep 21, 2022 at 12:15 PM Jeambrun Pierre <pierrejbrun@gmail.com (mailto:pierrejbrun@gmail.com)> wrote:
> > > > Definitely in favor of more consistency. (Hoping it will not make things too hard for people doing the cherry picking)
> > > >
> > > > Best Regards,
> > > > Pierre
> > > >
> > > >
> > > > Le mer. 21 sept. 2022 à 08:35, Pankaj Koti <pa...@astronomer.io.invalid> a écrit :
> > > > > I'm in for normalizing.
> > > > > Personally, I don't like a mix of both single and double quotes.
> > > > >
> > > > > In my opinion, we can enforce double-quotes with Black or also try the pre-commit hook double-quote-string-fixer https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer which converts double quotes to single quotes. I believe the python community prefers single quotes over double in general (https://github.com/psf/black/issues/373) so we can consider the latter option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings too.
> > > > >
> > > > > Regards,
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Pankaj Koti
> > > > >
> > > > >
> > > > >
> > > > > Senior Software Engineer, OSS Engineering Team.
> > > > > Location: Pune, India
> > > > >
> > > > >
> > > > > Timezone: Indian Standard Time (IST)
> > > > >
> > > > >
> > > > > Email: pankaj.koti@astronomer.io (mailto:pankaj.koti@astronomer.io)
> > > > >
> > > > >
> > > > > Mobile: +91 9730079985
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall <fe...@pm.me.invalid> wrote:
> > > > > > Totally for it!
> > > > > >
> > > > > > That’s not true actually. Black won’t reformat strings using f-string if you use single quotes for the string and double quotes within e.g. when passing a str.join statement as a value which uses double quotes. So you can still have a mixture of both in the codebase but it will be less. :)
> > > > > > (I would have expected black to reformat this and turn the f-string quotes into double quotes and single quotes within, but it is a difficult decision.)
> > > > > >
> > > > > > Best,
> > > > > > Felix
> > > > > >
> > > > > >
> > > > > >
> > > > > > Sent from Proton Mail for iOS
> > > > > >
> > > > > >
> > > > > > On Wed, Sep 21, 2022 at 06:19, Daniel Standish <daniel.standish@astronomer.io.INVALID (mailto:daniel.standish@astronomer.io.INVALID)> wrote:
> > > > > > > > I'll weigh in on this most important of decisions
> > > > > > >
> > > > > > > :)
> > > > > > >
> > > > > > > OK but I must clear up one thing ... if we turn on string normalization, we do not get to choose single vs double -- with black, there is only one way, and it is double.
> > > > > > >
> > > > > > > Personally I have always liked single but yeah, I am in favor of turning on normalization, which means double (generally speaking). Black explains the reasoning for the choice here (https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings).

Re: [DISCUSS] string normalization in black

Posted by Jarek Potiuk <ja...@potiuk.com>.
Yeah! Heated discussions! Tabs vs. Spaces.

I am also full in for consistency. I think where there are no clear
arguments to do this or that, for me consistency trumps any individual
preference/style (especially when it is backed with automation that will
correct things for you and will not put any extra burden on maintainers
having to control it).
One of my friends in Poland had the rather vulgar saying "Lepiej ch..o ale
jednakowo" (Those who know, will know) - very free translation is "Better
sh..ty but consistently" and I fully agree with it.

Happy to adapt to any style as long as I don't even have to think about it
and my personal preferences are not important here.

J.


On Wed, Sep 21, 2022 at 9:03 AM Bartłomiej Hirsz <ba...@gmail.com>
wrote:

> The formatting discussions are always the most heated ones :) I'm for
> normalization - we have ugly mix of both and I'm down for whatever but to
> be consistent. I wouldn't worry about git history or cherry picks. We had
> several PRs recently that touched almost every file anyway (like improving
> our imports). And number of changes per file doesn't matter since later it
> will be handled by precommit before adding your new code anyway.
>
> Regarding replacing "string with '" to 'string with "' - this cannot be
> done automatically because in many cases it was done deliberately. For
> example, if someone wants to write an English sentence: "It'll go nicely".
> The (ugly) solution for this, if someone would really want to use one type
> of quote marks, would be using triple single quota for such cases.
>
> śr., 21 wrz 2022 o 08:54 Pankaj Koti <pa...@astronomer.io.invalid>
> napisał(a):
>
>> Correction in my previous email. pre-commit hook
>> double-quote-string-fixer too does not seem to work well for f-strings with
>> a mix of double and single quotes (meaning does not convert a f-string
>> which has outer quotes as double and inner quotes as single). It just skips
>> it if the string is like the below:
>> f"hello how are you, my name is 'Pankaj', I hope you're well"
>>
>>
>> Regards,
>>
>>
>>
>> Pankaj Koti
>>
>> *Senior Software Engineer, *OSS Engineering Team.
>> Location: Pune, India
>>
>> Timezone: Indian Standard Time (IST)
>>
>> Email: pankaj.koti@astronomer.io
>>
>> Mobile: +91 9730079985
>>
>>
>> On Wed, Sep 21, 2022 at 12:15 PM Jeambrun Pierre <pi...@gmail.com>
>> wrote:
>>
>>> Definitely in favor of more consistency. (Hoping it will not make things
>>> too hard for people doing the cherry picking)
>>>
>>> Best Regards,
>>> Pierre
>>>
>>> Le mer. 21 sept. 2022 à 08:35, Pankaj Koti
>>> <pa...@astronomer.io.invalid> a écrit :
>>>
>>>> I'm in for normalizing.
>>>> Personally, I don't like a mix of both single and double quotes.
>>>>
>>>> In my opinion, we can enforce double-quotes with Black or also try the
>>>> pre-commit hook double-quote-string-fixer
>>>> https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer
>>>> which converts double quotes to single quotes. I believe the python
>>>> community prefers single quotes over double in general (
>>>> https://github.com/psf/black/issues/373) so we can consider the latter
>>>> option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings
>>>> too.
>>>>
>>>>
>>>> Regards,
>>>>
>>>>
>>>>
>>>> Pankaj Koti
>>>>
>>>> *Senior Software Engineer, *OSS Engineering Team.
>>>> Location: Pune, India
>>>>
>>>> Timezone: Indian Standard Time (IST)
>>>>
>>>> Email: pankaj.koti@astronomer.io
>>>>
>>>> Mobile: +91 9730079985
>>>>
>>>>
>>>> On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall
>>>> <fe...@pm.me.invalid> wrote:
>>>>
>>>>> Totally for it!
>>>>>
>>>>> That’s not true actually. Black won’t reformat strings using f-string
>>>>> if you use single quotes for the string and double quotes within e.g.
>>>>> when passing a str.join statement as a value which uses double quotes. So
>>>>> you can still have a mixture of both in the codebase but it will be less. :)
>>>>> (I would have expected black to reformat this and turn the f-string
>>>>> quotes into double quotes and single quotes within, but it is a difficult
>>>>> decision.)
>>>>>
>>>>> Best,
>>>>> Felix
>>>>>
>>>>>
>>>>>
>>>>> Sent from Proton Mail for iOS
>>>>>
>>>>>
>>>>> On Wed, Sep 21, 2022 at 06:19, Daniel Standish <
>>>>> daniel.standish@astronomer.io.INVALID> wrote:
>>>>>
>>>>> I'll weigh in on this most important of decisions
>>>>>
>>>>>
>>>>> :)
>>>>>
>>>>> OK but I must clear up one thing ... if we turn on string
>>>>> normalization, we do not get to choose single vs double -- with black,
>>>>> there is only one way, and it is double.
>>>>>
>>>>> Personally I have always liked single but yeah, I am in favor of
>>>>> turning on normalization, which means double (generally speaking). Black
>>>>> explains the reasoning for the choice here
>>>>> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>

Re: [DISCUSS] string normalization in black

Posted by Bartłomiej Hirsz <ba...@gmail.com>.
The formatting discussions are always the most heated ones :) I'm for
normalization - we have ugly mix of both and I'm down for whatever but to
be consistent. I wouldn't worry about git history or cherry picks. We had
several PRs recently that touched almost every file anyway (like improving
our imports). And number of changes per file doesn't matter since later it
will be handled by precommit before adding your new code anyway.

Regarding replacing "string with '" to 'string with "' - this cannot be
done automatically because in many cases it was done deliberately. For
example, if someone wants to write an English sentence: "It'll go nicely".
The (ugly) solution for this, if someone would really want to use one type
of quote marks, would be using triple single quota for such cases.

śr., 21 wrz 2022 o 08:54 Pankaj Koti <pa...@astronomer.io.invalid>
napisał(a):

> Correction in my previous email. pre-commit hook double-quote-string-fixer
> too does not seem to work well for f-strings with a mix of double and
> single quotes (meaning does not convert a f-string which has outer quotes
> as double and inner quotes as single). It just skips it if the string is
> like the below:
> f"hello how are you, my name is 'Pankaj', I hope you're well"
>
>
> Regards,
>
>
>
> Pankaj Koti
>
> *Senior Software Engineer, *OSS Engineering Team.
> Location: Pune, India
>
> Timezone: Indian Standard Time (IST)
>
> Email: pankaj.koti@astronomer.io
>
> Mobile: +91 9730079985
>
>
> On Wed, Sep 21, 2022 at 12:15 PM Jeambrun Pierre <pi...@gmail.com>
> wrote:
>
>> Definitely in favor of more consistency. (Hoping it will not make things
>> too hard for people doing the cherry picking)
>>
>> Best Regards,
>> Pierre
>>
>> Le mer. 21 sept. 2022 à 08:35, Pankaj Koti
>> <pa...@astronomer.io.invalid> a écrit :
>>
>>> I'm in for normalizing.
>>> Personally, I don't like a mix of both single and double quotes.
>>>
>>> In my opinion, we can enforce double-quotes with Black or also try the
>>> pre-commit hook double-quote-string-fixer
>>> https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer
>>> which converts double quotes to single quotes. I believe the python
>>> community prefers single quotes over double in general (
>>> https://github.com/psf/black/issues/373) so we can consider the latter
>>> option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings
>>> too.
>>>
>>>
>>> Regards,
>>>
>>>
>>>
>>> Pankaj Koti
>>>
>>> *Senior Software Engineer, *OSS Engineering Team.
>>> Location: Pune, India
>>>
>>> Timezone: Indian Standard Time (IST)
>>>
>>> Email: pankaj.koti@astronomer.io
>>>
>>> Mobile: +91 9730079985
>>>
>>>
>>> On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall <fe...@pm.me.invalid>
>>> wrote:
>>>
>>>> Totally for it!
>>>>
>>>> That’s not true actually. Black won’t reformat strings using f-string
>>>> if you use single quotes for the string and double quotes within e.g.
>>>> when passing a str.join statement as a value which uses double quotes. So
>>>> you can still have a mixture of both in the codebase but it will be less. :)
>>>> (I would have expected black to reformat this and turn the f-string
>>>> quotes into double quotes and single quotes within, but it is a difficult
>>>> decision.)
>>>>
>>>> Best,
>>>> Felix
>>>>
>>>>
>>>>
>>>> Sent from Proton Mail for iOS
>>>>
>>>>
>>>> On Wed, Sep 21, 2022 at 06:19, Daniel Standish <
>>>> daniel.standish@astronomer.io.INVALID> wrote:
>>>>
>>>> I'll weigh in on this most important of decisions
>>>>
>>>>
>>>> :)
>>>>
>>>> OK but I must clear up one thing ... if we turn on string
>>>> normalization, we do not get to choose single vs double -- with black,
>>>> there is only one way, and it is double.
>>>>
>>>> Personally I have always liked single but yeah, I am in favor of
>>>> turning on normalization, which means double (generally speaking). Black
>>>> explains the reasoning for the choice here
>>>> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
>>>> .
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>

Re: [DISCUSS] string normalization in black

Posted by Pankaj Koti <pa...@astronomer.io.INVALID>.
Correction in my previous email. pre-commit hook double-quote-string-fixer
too does not seem to work well for f-strings with a mix of double and
single quotes (meaning does not convert a f-string which has outer quotes
as double and inner quotes as single). It just skips it if the string is
like the below:
f"hello how are you, my name is 'Pankaj', I hope you're well"


Regards,



Pankaj Koti

*Senior Software Engineer, *OSS Engineering Team.
Location: Pune, India

Timezone: Indian Standard Time (IST)

Email: pankaj.koti@astronomer.io

Mobile: +91 9730079985


On Wed, Sep 21, 2022 at 12:15 PM Jeambrun Pierre <pi...@gmail.com>
wrote:

> Definitely in favor of more consistency. (Hoping it will not make things
> too hard for people doing the cherry picking)
>
> Best Regards,
> Pierre
>
> Le mer. 21 sept. 2022 à 08:35, Pankaj Koti
> <pa...@astronomer.io.invalid> a écrit :
>
>> I'm in for normalizing.
>> Personally, I don't like a mix of both single and double quotes.
>>
>> In my opinion, we can enforce double-quotes with Black or also try the
>> pre-commit hook double-quote-string-fixer
>> https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer
>> which converts double quotes to single quotes. I believe the python
>> community prefers single quotes over double in general (
>> https://github.com/psf/black/issues/373) so we can consider the latter
>> option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings
>> too.
>>
>>
>> Regards,
>>
>>
>>
>> Pankaj Koti
>>
>> *Senior Software Engineer, *OSS Engineering Team.
>> Location: Pune, India
>>
>> Timezone: Indian Standard Time (IST)
>>
>> Email: pankaj.koti@astronomer.io
>>
>> Mobile: +91 9730079985
>>
>>
>> On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall <fe...@pm.me.invalid>
>> wrote:
>>
>>> Totally for it!
>>>
>>> That’s not true actually. Black won’t reformat strings using f-string if
>>> you use single quotes for the string and double quotes within e.g.
>>> when passing a str.join statement as a value which uses double quotes. So
>>> you can still have a mixture of both in the codebase but it will be less. :)
>>> (I would have expected black to reformat this and turn the f-string
>>> quotes into double quotes and single quotes within, but it is a difficult
>>> decision.)
>>>
>>> Best,
>>> Felix
>>>
>>>
>>>
>>> Sent from Proton Mail for iOS
>>>
>>>
>>> On Wed, Sep 21, 2022 at 06:19, Daniel Standish <
>>> daniel.standish@astronomer.io.INVALID> wrote:
>>>
>>> I'll weigh in on this most important of decisions
>>>
>>>
>>> :)
>>>
>>> OK but I must clear up one thing ... if we turn on string normalization,
>>> we do not get to choose single vs double -- with black, there is only one
>>> way, and it is double.
>>>
>>> Personally I have always liked single but yeah, I am in favor of turning
>>> on normalization, which means double (generally speaking). Black explains
>>> the reasoning for the choice here
>>> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
>>> .
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>

Re: [DISCUSS] string normalization in black

Posted by Jeambrun Pierre <pi...@gmail.com>.
Definitely in favor of more consistency. (Hoping it will not make things
too hard for people doing the cherry picking)

Best Regards,
Pierre

Le mer. 21 sept. 2022 à 08:35, Pankaj Koti
<pa...@astronomer.io.invalid> a écrit :

> I'm in for normalizing.
> Personally, I don't like a mix of both single and double quotes.
>
> In my opinion, we can enforce double-quotes with Black or also try the
> pre-commit hook double-quote-string-fixer
> https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer
> which converts double quotes to single quotes. I believe the python
> community prefers single quotes over double in general (
> https://github.com/psf/black/issues/373) so we can consider the latter
> option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings
> too.
>
>
> Regards,
>
>
>
> Pankaj Koti
>
> *Senior Software Engineer, *OSS Engineering Team.
> Location: Pune, India
>
> Timezone: Indian Standard Time (IST)
>
> Email: pankaj.koti@astronomer.io
>
> Mobile: +91 9730079985
>
>
> On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall <fe...@pm.me.invalid>
> wrote:
>
>> Totally for it!
>>
>> That’s not true actually. Black won’t reformat strings using f-string if
>> you use single quotes for the string and double quotes within e.g.
>> when passing a str.join statement as a value which uses double quotes. So
>> you can still have a mixture of both in the codebase but it will be less. :)
>> (I would have expected black to reformat this and turn the f-string
>> quotes into double quotes and single quotes within, but it is a difficult
>> decision.)
>>
>> Best,
>> Felix
>>
>>
>>
>> Sent from Proton Mail for iOS
>>
>>
>> On Wed, Sep 21, 2022 at 06:19, Daniel Standish <
>> daniel.standish@astronomer.io.INVALID> wrote:
>>
>> I'll weigh in on this most important of decisions
>>
>>
>> :)
>>
>> OK but I must clear up one thing ... if we turn on string normalization,
>> we do not get to choose single vs double -- with black, there is only one
>> way, and it is double.
>>
>> Personally I have always liked single but yeah, I am in favor of turning
>> on normalization, which means double (generally speaking). Black explains
>> the reasoning for the choice here
>> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
>> .
>>
>>
>>
>>
>>
>>
>>
>>

Re: [DISCUSS] string normalization in black

Posted by Pankaj Koti <pa...@astronomer.io.INVALID>.
I'm in for normalizing.
Personally, I don't like a mix of both single and double quotes.

In my opinion, we can enforce double-quotes with Black or also try the
pre-commit hook double-quote-string-fixer
https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md#double-quote-string-fixer
which converts double quotes to single quotes. I believe the python
community prefers single quotes over double in general (
https://github.com/psf/black/issues/373) so we can consider the latter
option (double-quote-string-fixer pre-commit hook)? It normalizes f-strings
too.


Regards,



Pankaj Koti

*Senior Software Engineer, *OSS Engineering Team.
Location: Pune, India

Timezone: Indian Standard Time (IST)

Email: pankaj.koti@astronomer.io

Mobile: +91 9730079985


On Wed, Sep 21, 2022 at 11:22 AM Felix Uellendall <fe...@pm.me.invalid>
wrote:

> Totally for it!
>
> That’s not true actually. Black won’t reformat strings using f-string if
> you use single quotes for the string and double quotes within e.g.
> when passing a str.join statement as a value which uses double quotes. So
> you can still have a mixture of both in the codebase but it will be less. :)
> (I would have expected black to reformat this and turn the f-string
> quotes into double quotes and single quotes within, but it is a difficult
> decision.)
>
> Best,
> Felix
>
>
>
> Sent from Proton Mail for iOS
>
>
> On Wed, Sep 21, 2022 at 06:19, Daniel Standish <
> daniel.standish@astronomer.io.INVALID> wrote:
>
> I'll weigh in on this most important of decisions
>
>
> :)
>
> OK but I must clear up one thing ... if we turn on string normalization,
> we do not get to choose single vs double -- with black, there is only one
> way, and it is double.
>
> Personally I have always liked single but yeah, I am in favor of turning
> on normalization, which means double (generally speaking). Black explains
> the reasoning for the choice here
> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
> .
>
>
>
>
>
>
>
>

Re: [DISCUSS] string normalization in black

Posted by Felix Uellendall <fe...@pm.me.INVALID>.
Totally for it!

That’s not true actually. Black won’t reformat strings using f-string if you use single quotes for the string and double quotes within e.g. when passing a str.join statement as a value which uses double quotes. So you can still have a mixture of both in the codebase but it will be less. :)
(I would have expected black to reformat this and turn the f-string quotes into double quotes and single quotes within, but it is a difficult decision.)

Best,
Felix

Sent from Proton Mail for iOS

On Wed, Sep 21, 2022 at 06:19, Daniel Standish <da...@astronomer.io.INVALID> wrote:

>> I'll weigh in on this most important of decisions
>
> :)
>
> OK but I must clear up one thing ... if we turn on string normalization, we do not get to choose single vs double -- with black, there is only one way, and it is double.
>
> Personally I have always liked single but yeah, I am in favor of turning on normalization, which means double (generally speaking). Black explains the reasoning for the choice [here](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings).

Re: [DISCUSS] string normalization in black

Posted by Daniel Standish <da...@astronomer.io.INVALID>.
>
> I'll weigh in on this most important of decisions


:)

OK but I must clear up one thing ... if we turn on string normalization, we
do not get to choose single vs double -- with black, there is only one way,
and it is double.

Personally I have always liked single but yeah, I am in favor of turning
on normalization, which means double (generally speaking).  Black explains
the reasoning for the choice here
<https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings>
.

Re: [DISCUSS] string normalization in black

Posted by "Ferruzzi, Dennis" <fe...@amazon.com.INVALID>.
I'll weigh in on this most important of decisions.   I find myself wishing I had time to standardize string quotes when I am in files and not doing it because I don't want to complicate PRs with unnecessary/unrelated changes.  So I'd be for this.   I prefer single-quotes myself, but I'd consider standardizing either way a win.


- ferruzzi


________________________________
From: Jed Cunningham <je...@apache.org>
Sent: Tuesday, September 20, 2022 8:39 PM
To: dev@airflow.apache.org
Subject: RE: [EXTERNAL][DISCUSS] string normalization in black


CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.


I'd be in favor of turning it on.

I tend to prefer double quotes, but I'd rather have it on and have single quotes.

If we do get enough support for this, I'd like to wait until we are closer to 2.5 to reduce conflicts when cherry-picking for 2.4.x's.

Re: [DISCUSS] string normalization in black

Posted by Jed Cunningham <je...@apache.org>.
I'd be in favor of turning it on.

I tend to prefer double quotes, but I'd rather have it on and have single
quotes.

If we do get enough support for this, I'd like to wait until we are closer
to 2.5 to reduce conflicts when cherry-picking for 2.4.x's.

Re: [DISCUSS] string normalization in black

Posted by Kamil Breguła <dz...@gmail.com>.
This option has been used to limit the number of changes to files.
https://github.com/apache/airflow/pull/9550#issuecomment-650971650

śr., 21 wrz 2022 o 02:32 Daniel Standish
<da...@astronomer.io.invalid> napisał(a):

> Black, our python formatter, can "normalize" strings to prefer double
> quotes, and we disable this feature.
>
> I have always been a single quotes person unless using f-string and
> supported disabling normalization when we introduced black.
>
> But lately, black’s string normalization has seemed more appealing to me.
>  for two reasons… one is when i’m searching the codebase for something that
> i know is a string, i have to search for it two times, once for each flavor
> of quote.  the other is simply the noise / friction / decisionmaking about
> choosing when to use which, particularly when the area of code uses both in
> close proximity.
>
> this isn't gonna win the award for most important discussion of the
> year...  but i just wanted to test the waters and see if others have a
> similar feeling, or generally people would prefer to leave well-enough
> alone.
>
> thanks
>
>