Page MenuHomePhabricator

Get the u'' to '' string conversion over with in Pywikibot
Closed, ResolvedPublic

Description

Looks like we don't want u'' strings, but '' strings. Do one big search and replace to go to this standard. That will save us from counter productive discussions like https://gerrit.wikimedia.org/r/#/c/354719/1/scripts/newitem.py@98

Event Timeline

@Xqt wrote at the mentioned page: "Anyway we shouldn't change old code for it". Why? Us will always cause problem in Python 3000.

@Xqt wrote at the mentioned page: "Anyway we shouldn't change old code for it". Why? Us will always cause problem in Python 3000.

One of the problems we have is 300+ open changesets. If we change u'' to '' now, a lot of these sets will need a manual rebase. That's a pain to do. So we should probably do this in small chunks for parts we don't have a lot of conflicting changes.

Then a better piece of advice would be "Remove u only from scripts with no pending changes", wouldn't it? I think a patch only removing us can be revised on express lane.

Us will always cause problem in Python 3000.

Not, they don't. The u'' prefix has been allowed since Python 3.3, which was released in 2012. Official support for Python 3.2 was dropped in Feb 2016. There is absolutely no reason to remove them, apart from 'it looks nicer'.

Xqt triaged this task as Lowest priority.May 28 2017, 1:29 PM

I think it is not necessary to replace all u'' with '' in our code but we should do it when a line will be changed due to out development guidelines [1]; u'' prefix on strings is meaningless due to __future__.unicode_literals. Well py3.0 and py3.1 isn't compatible with u prefix but I guess there are other problems too to get them running and keep py2.7 compatibility.

Anyway I am not against cleaning up this prefix even some changesets must be rebased if they have related changes on such strings. This may have the advantage that maintained patches will get a proper focus.

[1] https://www.mediawiki.org/wiki/Manual:Pywikibot/Development/Guidelines

Not, they don't. The u'' prefix has been allowed since Python 3.3, which was released in 2012.

OK, I didn't know that.

In Description, @Multichill wrote:

Do one big search and replace to go to this standard.

I think we should not do that because it breaks the blame history without any reason. The prefix should removed only when a line will be changed.

+1. I personally don't care about blame history much. Making the code more visually appealing, more newcomer-friendly, and one less thing to argue about during code reviews is more important for me.

Xqt claimed this task.

This was done already

Xqt removed Xqt as the assignee of this task.Apr 18 2020, 2:41 PM
Dvorapa subscribed.

I can still see a lot of places in code where u'' or u"" is used

Change 590281 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [cleanup] remove remaining unicode literals specifiers

https://gerrit.wikimedia.org/r/590281

I can still see a lot of places in code where u'' or u"" is used

They are only in comments otherwise it would have been detected by flake8-no-u-prefixed-strings. Anyway I made a patch.

In case of user-config.py the are not detected (as part of strings)

Change 590281 merged by jenkins-bot:
[pywikibot/core@master] [cleanup] remove remaining unicode literals specifiers

https://gerrit.wikimedia.org/r/590281

Xqt claimed this task.