python-black

GitLab CI Python black formatter says: would reformat, whereas running black does not reformat

GitLab CI Python black formatter says: would reformat, whereas running black does not reformat Question: When I run GitLab CI on this commit with this gitlab-ci.yml: stages: – format – test black_formatting: image: python:3.6 stage: format before_script: # Perform an update to make sure the system is up to date. – sudo apt-get update –fix-missing …

Total answers: 2

ImportError: cannot import name '_unicodefun' from 'click'

ImportError: cannot import name '_unicodefun' from 'click' Question: When running our lint checks with the Python Black package, an error comes up: ImportError: cannot import name ‘_unicodefun’ from ‘click’ (/Users/robot/.cache/pre-commit/repo3u71ccm2/py_env-python3.9/lib/python3.9/site-packages/click/init.py)` In researching this, I found the following related issues: ImportError: cannot import name ‘_unicodefun’ from ‘click’ #2976 ImportError: cannot import name ‘_unicodefun’ from ‘click’ #6013 …

Total answers: 6

Python Black code formatter doesn't format docstring line length

Python Black code formatter doesn't format docstring line length Question: I am running the Black code formatter against a Python script however it doesn’t reformat the line length for docstrings. For example, given the following code: def my_func(): """ This is a really long docstring. This is a really long docstring. This is a really …

Total answers: 1

black formatter: How can I place one newline before and after function instead of two

black formatter: How can I place one newline before and after function instead of two Question: I am using black formatter. I have two newlines before and two newlines after function definition. I want one newline before and one newline after function definition. Can i do it using black config file black –config FILE. If …

Total answers: 2

How to automatically break long string constants in Python code using Black formatter?

How to automatically break long string constants in Python code using Black formatter? Question: Python formatting guidelines, the famous PEP8 recommends no line longer than 79 chars. I can easily auto-format my code to a max line length with the Black Formatter, but it does not break long strings. The linter will still complain about …

Total answers: 2

Nesting long lists and sets using black formatter

Nesting long lists and sets using black formatter Question: Can the python black formatter nest long lists and sets? For example: Input coworkers = {"amy", "bill", "raj", "satoshi", "jim", "lifeng", "jeff", "sandeep", "mike"} Default output coworkers = { "amy", "bill", "raj", "satoshi", "jim", "lifeng", "jeff", "sandeep", "mike", } Desired output coworkers = { "amy", "bill", …

Total answers: 5

Formatter black is not working on my VSCode…but why?

Formatter black is not working on my VSCode…but why? Question: I have started using Python and Django and I am very new in this field. And, this is my first time to ask a question here…I do apologise in advance if there is a known solution to this issue… When I installed and set VSCode …

Total answers: 21

The Black Formatter – Python

The Black Formatter – Python Question: I just started using the Black Formatter module with VSCode everything was going well till I just noticed that it uses double quotes over single quotes which I already was using in my code.. and it overrode that.. So, is there an Black Argument that I could add to …

Total answers: 3

Black does not support "Format Selection" command – VS Code error

Black does not support "Format Selection" command – VS Code error Question: I need to indent my python file in Vs Code. I followed the normal procedure, On Windows Shift + Alt + F On Mac Shift + Option + F On Linux Ctrl + Shift + I But my question is every time when …

Total answers: 4