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

Strings not aligned properly #1067

Closed
yajo opened this issue Oct 15, 2019 · 1 comment
Closed

Strings not aligned properly #1067

yajo opened this issue Oct 15, 2019 · 1 comment

Comments

@yajo
Copy link
Contributor

yajo commented Oct 15, 2019

Operating system: Ubuntu Xenial
Python version: Python 3.6.7
Black version: 19.3b0
Does also happen on master: Yes.

Hi there, I come from @OCA, where we have a ton of repos that now started using Black, so I think this one won't be my last issue here. 😄

Well, we develop Odoo and many of our source codes are Odoo manifests, which look like this until now:

# Copyright 2016 Nicolas Bessi, Camptocamp SA
# Copyright 2018-2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
    "name": "Location management (aka Better ZIP)",
    "version": "13.0.1.0.0",
    "depends": ["base_address_city", "contacts"],
    "author": "Camptocamp,"
              "ACYSOS S.L.,"
              "Alejandro Santana,"
              "Tecnativa,"
              "AdaptiveCity,"
              "Odoo Community Association (OCA)",
    "license": "AGPL-3",
    "summary": """Enhanced zip/npa management system""",
    "website": "https://github.com/OCA/partner-contact",
    "data": [
        "security/ir.model.access.csv",
        "views/res_city_zip_view.xml",
        "views/res_city_view.xml",
        "views/res_country_view.xml",
        "views/res_company_view.xml",
        "views/res_partner_view.xml",
    ],
    "demo": ["demo/res_city_zip.xml"],
    "installable": True,
    "auto_install": False,
}

The problem is in the author key, that after blacked it looks like this (stripped the rest):

    ...
    "depends": ["base_address_city", "contacts"],
    "author": "Camptocamp,"
    "ACYSOS S.L.,"
    "Alejandro Santana,"
    "Tecnativa,"
    "AdaptiveCity,"
    "Odoo Community Association (OCA)",
    "license": "AGPL-3",
    ...

Not very readable! In fact, it was better before.

@sbidoul found that wrapping that with a parenthesis made Black behave fine, as you can see in OCA/partner-contact#793 (it's a very short PR, check it please).

So, is this the intended behavior? It doesn't seem like a very beautiful default...

Regards.

@zsol
Copy link
Collaborator

zsol commented Oct 16, 2019

I think #620 will help this issue. Having said that, when (in the future) Black will start automatically merging strings, it will merge all these authors into one string which is probably not your intention. Looks like the hack to inline multiple authors into the single author field of the Odoo manifest will break down at that point. You could always do ",".join(["author1", "author2"]) I guess, which expresses your intent better, and will help Black format this file properly as well.

Closing this issue as I believe the string alignment issue is covered by #620.

@zsol zsol closed this as completed Oct 16, 2019
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

No branches or pull requests

2 participants