简体   繁体   中英

How to setup VS Code for formatting line breaking symmetrically for Python?

Original code

            job.create_common_job_log_line(message=message, model_id=model_id, product_id=product.id)

This is how it formatted my code which is extremely ugly

            job.create_common_job_log_line(
                message=message, model_id=model_id, product_id=product.id)

I expect

            job.create_common_job_log_line(
                message=message, model_id=model_id, product_id=product.id
            )

or

            job.create_common_job_log_line(
                message=message, 
                model_id=model_id, 
                product_id=product.id
            )

Please use the formatting provided by " black " in settings.json file: (VS Code uses 'autopep8' for formatting by default.)

 "python.formatting.provider": "black",
 "editor.formatOnSave": true,

在此处输入图像描述

Reference: Formatting in Vs Code .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM