#black-formatter

1 messages · Page 5 of 1

elder tusk
#

nice! looks like i might have close to doubled my score after you posted this

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the bug

When Black is used as a pre-commit hook, the --extend-exclude option has no effect.

To Reproduce

  • Take a piece of Python code that you know will be formatted by Black
  • Add the path of this file to --extend-exclude
  • Run Black directly in the command line (like black /folder/that/contains/this/file)
  • Run Black in pre-commit

Expected behavior

When Black is run directly in the command line, that file is not formatted.

When `B...

flat krakenBOT
flat krakenBOT
fallow lance
dense jungle
flat krakenBOT
elder tusk
#

most tools seem to follow # word colon comment directive syntax, could maybe special case that

slow ibex
#

# TODO: fix that - is this a directive?

flat krakenBOT
elder tusk
#

good example, hadn't thought of that. no, but might be okay to treat it like one

fallow lance
#

I'd vote for simplicity+practicality over purity

flat krakenBOT
#

In the output of black --check --diff the diff is shown like this:

@@ -7,11 +7,11 @@
     print("test")
     print("test")
     print("test")
     print("test")
     print("test")
- 
+
     print("test")
     print("test")
     print("test")
     print("test")
     print("test")

There is one space too much in line 12.

Because the line itself is not mentioned in the output, it makes it impossible to write a regex to extract the line number. This would be handy f...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
elder tusk
#

has anyone looked into why the pypy tests are so slow? wondering if maybe we can just turn coverage for them off or something and everything becomes fast

bright glacier
#

probably coverage yeah

flat krakenBOT
flat krakenBOT
strong barn
#

Is there a way to disable the if-check consolidation via configuration file ?

Example:

-        else "Always Convert"
-        if mode == CoinsAutoConvert.ALWAYS
-        else "Never Convert"
+        else "Always Convert" if mode == CoinsAutoConvert.ALWAYS else "Never Convert"
strong barn
fallow lance
#

@dense jungle sorry for direct ping, would you know why https://github.com/psf/black/pull/3661 is not working for me on 3.9? I replaced all the places where type: ignore is mentioned by pyright: ignore but still no luck -- comments are reformatted....

GitHub

Description
Hi! It looks like you have some special handling for # type: ignore comments to avoid moving said comments around due to positional meaning. I think this same special handling should al...

dense jungle
fallow lance
flat krakenBOT
#

Describe the bug

I have a repo in which I use the following rule to ignore all files without extensions (e.g all compiled executables)

# To ignore compiled binaries that have no extensions we need to first ignore everything, 
# then unignore files with extensions and directories
*
!*.*
!*/

When I run black in the root of this repo, none of the python files in any of the subdirectories are checked because black thinks those subdirectories are ignored:

...

fallow lance
#

When trying to build with mypyc on 23.3.0

CIBW_BUILD='cp39-*' python3 -m cibuildwheel --platform linux

I'm getting error

 Successfully installed click-8.1.4 editables-0.4 hatch-mypyc-0.16.0 hatchling-1.18.0 mypy-0.991 mypy-extensions-1.0.0 packaging-23.1 pathspec-0.11.1 platformdirs-3.8.1 pluggy-1.2.0 setuptools-68.0.0 tomli-2.0.1 trove-classifiers-2023.7.6 types-typed-ast-1.5.8.7 typing-extensions-4.7.1
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  Traceback (most recent call last):
    File "/opt/python/cp39-cp39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/opt/python/cp39-cp39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/opt/python/cp39-cp39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
      whl_basename = backend.build_wheel(metadata_directory, config_settings)
    File "/tmp/pip-build-env-d3py5x5p/overlay/lib/python3.9/site-packages/hatchling/build.py", line 56, in build_wheel
      return os.path.basename(next(builder.build(wheel_directory, ['standard'])))
    File "/tmp/pip-build-env-d3py5x5p/overlay/lib/python3.9/site-packages/hatchling/builders/plugin/interface.py", line 150, in build
      build_hook.initialize(version, build_data)
    File "/tmp/pip-build-env-d3py5x5p/normal/lib/python3.9/site-packages/hatch_mypyc/plugin.py", line 338, in initialize
      raise Exception(f'Error while invoking Mypyc:\n{process.stdout.decode("utf-8")}')
  Exception: Error while invoking Mypyc:
  src/black/__init__.py:200:2: error: Argument 1 has incompatible type "Callable[[Optional[str], int, List[TargetVersion], bool, bool, bool, bool, bool, bool, Sequence[str], bool, bool, bool, bool, bool, bool, bool, Optional[str], Pattern[str], Optional[Pattern[str]], Optional[Pattern[str]], Optional[Pattern[str]], Optional[str], Optional[int], Tuple[str, ...], Optional[str]], None]"; expected <nothing>  [arg-type]
  src/black/__init__.py:461:13: error: <nothing> has no attribute "get_usage"  [attr-defined]
  src/black/__init__.py:466:13: error: <nothing> has no attribute "get_usage"  [attr-defined]
  src/black/__init__.py:1447:5: error: <nothing> not callable  [misc]

  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

Seems to work fine on main .

bright glacier
#

Yeah, IIRC a recent click release broke typing. It's fixed on main, but we don't backport fixes.

fallow lance
#

@bright glacier thank you for the replay. Would it be possible to make a release? 🙂 I'd prefer to avoid backporting myself, but at the same time I don't want to use non-release commit for build the internal wheel.

bright glacier
#

I don't get to make that decision anymore as I've effectively retired from the project, but you're in luck! 23.7.0 is scheduled for ~next week: psf/black#3774

toxic stormBOT
bright glacier
fallow lance
dense jungle
bright glacier
#

Haha, nice :)

#

I do plan on getting involved here and there, but I got work too and it's a bigger priority at the moment 🙂

#

@elder tusk thank you so much for all of your work, it really does have an impact!

#

Clearing out all of the cruft! 🧹

fallow lance
#

amazing!

dense jungle
#

will take a bit for the mypyc wheels to build though

#

but the pure-Python wheel is on PyPI already

dense jungle
#

all the wheels are built successfully 🙂

flat krakenBOT
fallow lance
#

@dense jungle ty

fallow lance
#

Hm, got a ton of INTERNAL ERROR: Black produced code that is not equivalent to the source. on the new release. Here is an example diff

--- src
+++ dst
@@ -2112,11 +2112,11 @@
                   annotation=
                     None,  # NoneType
                   arg=
                     'memory',  # str
                   type_comment=
-                    'Optional[joblib.Memory]',  # str
+                    None,  # NoneType
                 )  # /arg
               defaults=
                 Constant(
                   kind=
                     None,  # NoneType
@@ -2290,11 +2290,11 @@
           name=
             '__init__',  # str
           returns=
             None,  # NoneType
           type_comment=
-            None,  # NoneType
+            'Optional[joblib.Memory]',  # str
         )  # /FunctionDef
         FunctionDef(
           args=
             arguments(
               args=

flat krakenBOT
flat krakenBOT
dense jungle
flat krakenBOT
elder tusk
#

probably related to the type comment ast validation change I made?

fallow lance
#

let me make one

#

actually. I have this custom pyright patch now lol. Let me try it on the vanialla release

fallow lance
#

yeah sorry for the false alarm -- on vanilla release I don't see these crashes

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the problem

The documentation of the current code-style fails to list hashbang comments (#!) among the types of comments that are excepted from the spacing rules, even though they are indeed excepted from the spacing rules (see src/black/comments.py).

From the [comments subsection of docs/the_black_code_style/current_style.md](https://github.com/psf/black/blob/main/docs/the_black_code_style/current_style...

flat krakenBOT
polar forum
#

congratulations on the release!

flat krakenBOT
#

Here is my black configuration in pyproject.toml

[tool.black]
required-version = '23.3.0'
target-version = ['py38', 'py39', 'py310', 'py311']
skip_magic_trailing_comma = true
line-length = 88
verbose = true

I have a .pre-commit-config.yaml file that will install the black hook

(buildtest)  ~/Documents/github/buildtest/ [pyproject.toml+*] cat .pre-commit-config.yaml                          
ci:
    autoupdate_branch: ''
    autoupdate_commit_msg: '[pre-commit.c...
flat krakenBOT
#

Describe the style change

Hello,
We noticed that Black breaks long chains of assignments into multiple lines in a very unexpected way.

Example source code

AA = BB = CC = DD = EE = FF = GG = HH = JJ = KK = LL = MM = NN = OO = PP = QQ = RR = SS = TT = UU = WW = XX = YY = ZZ = 1

Examples in the current Black style

Black formats it in this way (last line is matched to max line length, but previous elements get 2 lines per one element):

AA = ...
raw bobcat
#

for some reason the latest release of black is failing to parse what seems to be valid code:

error: cannot format /home/iwana/sw/d/github.com/Kron-AS/kron-backend.review/kron/prosolutions/adapters/cash_order.py: Cannot parse: 338:4: match (

This corresponds to the first line below

    match (
        await kron.db.execute(
            db,
            sa.select(CashAccount.type).where(
                CashAccount.id == cash_order.dst_account_id
            ),
        )
    ).scalar_one_or_none():
        case None:
            assert cash_order.dst_account_type != CashOrderAccountType.CASH_ACCOUNT
            epk_segment = None
slow ibex
#

Is it a valid syntax?

#

Try to run this file

raw bobcat
#

It is running in production at the moment, and all tests pass, which includes tests for this

#

So I think so

#

I will make a bug report, I just want to not make a dupe report

#

Just need to isolate and reproduce

raw bobcat
#

it has to do with the .type in there

raw bobcat
#

It is .type inside ()

#
$ task
task: [default] python3.11 badfile.py PASSWORD
2023-07-13T12:50:47.673 952320 140388153448256 020:INFO     root         badfile:26:black_likes_this TRY AGAIN
2023-07-13T12:50:47.673 952320 140388153448256 020:INFO     root         badfile:35:black_does_not_like_this TRY AGAIN
task: [default] python3.11 badfile.py SECRET
2023-07-13T12:50:47.693 952321 139883387086656 020:INFO     root         badfile:24:black_likes_this YOU GOT IT
2023-07-13T12:50:47.693 952321 139883387086656 020:INFO     root         badfile:33:black_does_not_like_this YOU GOT IT
task: [default] pipx run --spec=black==23.3.0 black --diff badfile.py
⚠️  black is already on your PATH and installed at /home/iwana/.local/bin/black. Downloading and running anyway.
All done! ✨ 🍰 ✨
1 file would be left unchanged.
task: [default] pipx run --spec=black==23.7.0 black --diff badfile.py
⚠️  black is already on your PATH and installed at /home/iwana/.local/bin/black. Downloading and running anyway.
error: cannot format badfile.py: Cannot parse: 31:4:     match (input + SomeClass.type):

Oh no! 💥 💔 💥
1 file would fail to reformat.
task: Failed to run task "default": exit status 123
#

Filing a bug now

flat krakenBOT
#

Describe the bug

When black encounters access of a .type attribute inside brackets, inside a switch statement, it thinks that it is invalid syntax, even though python 3.11 executes it just fine.

To Reproduce

For example, take this code:

class SomeClass:
    type = ""


match (SomeClass.type):
    case _:
        print("Hello there ...")

And run it with these arguments:

$ pipx run --python python3.11 --spec=black==23.7.0 black --...
grand cipher
#

I sometimes find that black inserts blank lines in spots that significantly harm readability.
This is the only time that I find myself wanting to fight the tool. I've had this particular gripe for a few years and I don't think it's going to go away, for me.
The cases I know of:

  1. inner classes / functions
  2. tightly related module-scope objects (constants/functions/classes)
  3. import statements tightly related to the next line

All of these are uncommon, but aren't bad style if they exist due to inherent complexity. Black makes them even harder to understand than necessary though, because I can't control those lines relations to their comments and surrounding lines of code.

Do you find this as well, or is it just me?

These are the relevant (open) issues that I find:

  1. https://github.com/psf/black/issues/450
  2. https://github.com/psf/black/issues/1797
  3. https://github.com/psf/black/issues/2020
  4. https://github.com/psf/black/issues/2543 (full disclosure: filed by me)
rancid abyss
#

anyone aware of a repr function that returns black-safe text - default repr uses wrong quotes

slow ibex
#

Why would you need that?

rancid abyss
#

@slow ibex to generate code thats not going to be reformatted by black

flat krakenBOT
#

Describe the bug

if clauses in match-case blocks in are not reformatted when the line length is above the maximum length set.

To Reproduce

Take this code, where the second line is 99 characters (11 characters above the horizontal limit):

match "test":
    case "test" if "any long condition" != "another long condition" and "this is a long condition":
        print("Test")

And try formatting it:

$ black file.py

Black...

bright glacier
#

Will take a look tomorrow. I need sleep.

flat krakenBOT
flat krakenBOT
quiet elk
#

Hello

bright glacier
#

ouch, the newlines are being escaped it seems like :/

late dewBOT
#

scripts/diff_shades_gha_helper.py lines 227 to 228

# https://github.community/t/set-output-truncates-multiline-strings/16852/3
escaped = body.replace("%", "%25").replace("\n", "%0A").replace("\r", "%0D")```
flat krakenBOT
bright glacier
bright glacier
bright glacier
#

And to mark the 3rd thing I've noticed since coming back to Black development today: diff-shades is really slow now

#

Seems like I should bite the bullet and add sharding support

quiet elk
#

Pyright is giving me some errros

#

Should I just ignore the errors?

bright glacier
#

We don't use pyright as our type checker so unless the errors seem bad, yes you can ignore them.

#

Are they a lot of them?

quiet elk
bright glacier
#

mypy

quiet elk
#

Thanks

bright glacier
#

if there are only two errors, what are the errors? Maybe they are worth addressing

quiet elk
#

I am going Afk

quiet elk
#
        [Pyright] Cannot access member "detach" for type "AnsiToWin32"
  Member "detach" is unknown (911:10)
#

I am on linux btw

#

if that is relevant

#

in init.py

bright glacier
#

yeah, we can probably ignore that. I'll take a look later

quiet elk
#

okay

flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

It would be nice to be able to force black to never change the order of code and comments.

for example:

x = (
    codeA   # commentA
    .codeB  # commentB
    .codeC  # commentC
    .codeD  # commentD
    .codeE  # commentE
    .codeF  # commentF
)

[gets formatted to](https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AD9AG5dAD2IimZxl1N_WmyLkeQzBfBJMV7c0GsbQl...

flat krakenBOT
#

Describe the bug

To Reproduce

For example, take this code:

    def __str__(self):
        return f"{self.get_name_display()}" # pyright: ignore[reportGeneralTypeIssues] -- This is some special Django magic that we can't easily tell Pyright about

And run it with these arguments:

$ black --preview

The resulting error is:

Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues" (Pylance)

    def __str__(self):...
flat krakenBOT
#

Describe the bug

pre-commit is using pyyaml with broken version pyyaml==5.4.1, upping the version to pyyaml==6.0.1 (.pre-commit-config.yaml)

To Reproduce

Run:

pre-commit run -a

The resulting error is:

Stack trace

[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/user/.cache/pre-co...

flat krakenBOT
#

The same error as reported before in closed #3357 still happens when running unit tests locally now with
pytest-cov==4.1.0
pytest-xdist==3.3.1

To Reproduce
Run unit tests

(.venv) % tox -e py
...
...
Successfully built black
Installing collected packages: typing-extensions, pathspec, mypy-extensions, multidict, idna, frozenlist, click, charset-normalizer, attrs, async-timeout, yarl, black, aiosignal, aiohttp
Successfully installed aiohttp-3.8.5 aiosignal-1.3.1 async-timeou...
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the bug

I modified a file to remove commas after ** unpacking operators to support compatibility with older versions of Python, but Black added them back. The docs say this will only happen if Black thinks my code requires Python 3.6 or above, and that it determines this by looking for other instances of commas following * or ** operators, or f-strings. I've checked carefully and none of those things are present in the file as far as I can tell.

To Reproduce

I was ...

flat krakenBOT
flat krakenBOT
#

Description

Hello, first-time submitting PR here.

This PR updates an assert statement that checks the bounds of a string-slicing operation. The updated assertion provides more accurate and informative error handling by specifically checking the relative values of the indices and the string length.

The original assertion was essentially checking if Python's string slicing was behaving as expected. However, it wasn't providing any guarantees or useful information about th...

flat krakenBOT
#

good day,

i want to raise here the requirement for support formating with tab indentation on small devices with low memory / limited resources.

i am aware that there are already some issues regarding this (all closed for comments). e.g. https://github.com/psf/black/issues/47

i kindly ask you to have a closer look at the following scenario.

the following script has indented with tabs the size of 103 bytes, and formatted with black default 133 bytes (1 tab == 4 spaces).

a ...
flat krakenBOT
#

Is this related to a problem? Please describe.
How to separate multiple values, command line or toml.

I can't work out how to do multiple excludes: the following doesn't work

black --check --line-length 120 --force-exclude PoB_rc.py src/ui/*.py src/*.py src/*/*.py
black --check --line-length 120 --force-exclude "PoB_rc.py src/ui/*.py" src/*.py src/*/*.py
black --check --line-length 120 --force-exclude PoB_rc.py src/ui/*.py --include src/*.py src/*/*.py

**Describe the...

flat krakenBOT
elder ibex
#

Hi there! I did black . on my project, but then I want black --line-length 120 .. And it did nothing after first call. How can I force black to format my code with 120 characters width?

bright glacier
#

it sounds like you need to need to run black -l 120 . with --skip-trailing-comma and then rerun it without that flag

#

the magic trailing comma is sticky

slow ibex
#

black by default normalizes strings to double quotes
there is option to disable string normalization

is there a way to force single quotes?

ivory quest
#

And don't bother with feature requests, black chose double quotes and won't change it

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the style change

Currently, black will break a long line that uses a | character for type hints after the | character resulting is very unsightly code.

If it is possible to break the line after the type hints to stay within the line limit, black should leave the type hints on a single line.

Examples in the current Black style

def foo(
    bar: Baz
    | None = Baz(
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod...
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

Rewrite and improve caching implementation to use file hashes as fallback for mtime and size comparisons. Especially for CI systems, comparing just based on mtime makes caching practically useless. With each new run and git checkout it changes and the cache will miss even if the file didn't change.

This PR adds a fallback to compare file hashes if the mtime changed to resolve that. It's not as fast, but still much faster than formatting the file outright. This approach is ...

flat krakenBOT
flat krakenBOT
#

Description

At present, Black removes spaces around walrus operators within subscripts. For example, this is stable style:

x[y:=1]

While rare in practice, it appears that this behavior is unintentional, and falls out from Black's removal of spaces around colons in slices (e.g., x[y:z]).

This PR removes that behavior, instead requiring spaces around walrus operators in such cases.

Closes https://github.com/psf/black/issues/3820.

Checklist - d...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the bug
I use the force-exclude feature to exclude files living in symlinked directories.
However, it looks like black uses the regexp from force-exclude after the symlink is resolved (not the symlinked path).

$ black -v /path_2_file/application/api/lib/dir_symlinked/__init__.py
Identified `/path_2_file` as project root containing a .git directory.
Using configuration from project root.
line_length: 135
target_version: ['py39']
force_exclude: (?:.*?applic...
flat krakenBOT
#

Describe the bug

black seems to reformat and change the default values from None to (None,). Was this necessary? First time I have seen it being changed to (None,)

From:

@dataclass
class Foobar:
    include_feedback: Optional[List[str]] = None,
    exclude_feedback: Optional[List[str]] = None,

To:

@dataclass
class Foobar:
    include_feedback: Optional[List[str]] = (None,)
    exclude_feedback: Optional[List[str]] = (None,)

...
quartz pendant
#

@dusky bluff

bright glacier
amber cargo
#

I'm using black as my formatter in VSCode, including for jupyter notebooks. Is there a way to disable it adding an empty line at the end of each cell?

EDIT: actually, that seems to be the extension's fault, not black's, #1877. But I don't see a way to fix it in notebook cells...

EDIT2: Fixed by switching to the Black Formatter extension (from just having the black formatter in the Python extension).
EDIT3: ahh, but that doesn't work when formatting the entire notebook...

remote totem
#

isnt an empty line a requirement for normal python files? probably carry over from there

flat krakenBOT
elder tusk
flat krakenBOT
flat krakenBOT
warm stag
#

!e print(set("abc"))

#

!e

a = "abc"
b = "dcba"
print(set(b) - set(a))
late dewBOT
#

@warm stag :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'d'}
flat krakenBOT
quiet elk
#

I am trying to read black source code and confused about something,
this is their __main__.py file. How are they taking cli arguments?

from black import patched_main

patched_main()
#

hoping a black developer is here

little parrot
#

check what patched_main looks like ;)

quiet elk
little parrot
#

basically you dont need to take cli arguments in the main.py file as you can access them anyway from sys.argv

#

but yeah click parses the argv for you

quiet elk
#

what does freeze mean btw?

little parrot
#

iirc its just to fix a multiprocessing issue, i wouldnt worry about it

quiet elk
#

okay

#

Hey whats the difference btw src and code?

little parrot
#

black can be used just with a snippet so code is the snippet provided and src is the place to run black on

quiet elk
#

oh

little parrot
#

its like python -c "import foo; foo.do_something()" vs python foo.py

#

except its gonna do formatting and not run the code/file

quiet elk
#

didn't know there was a thing called echo() in python

#
    if not src and code is None:
        out(main.get_usage(ctx) + "\n\nOne of 'SRC' or 'code' is required.")
        ctx.exit(1)
little parrot
quiet elk
#

is just checking is one of them or are present?

#

I thought you use `or' for that?

little parrot
#

there are multiple ways of doing basically anything

quiet elk
#
not (src or code)
#

wouldn't this be better?

#

or am I missing something here

#
#+begin_src python :results output
  src = None
  code = None
  print(not (src or code))
  print(not src or code is None)
#+end_src

#+RESULTS:
: True
: True
#

They seem to do the same?

#

ah nevermind

#
#+begin_src python :results output
  src = False
  code = False
  print(not (src or code))
  print(not src and code is None)
#+end_src

#+RESULTS:
: True
: False
#

they do differ

flat krakenBOT
flat krakenBOT
#

I have checked with the online formatter that it is not fixed in the most up to date development branch.

Describe the bug

The following code has a line that is longer than 88 characters and yet is not split by black:

class LongNameLongName:
    pass


class LongNameLongName2:
    pass


class LongNameLongName3:
    pass


class LongNameLongName4:
    pass


class LongNameLongName5:
    pass


class LongNameLongName6:
    pass


class ClassWithTypeDefs...
flat krakenBOT
#

I've been using the black-jupyter pre-commit hook and was trying to update to the pre-commit mirror documented in #3828. However, the mirrored hook does not seem to reformat any files.

Describe the bug

To Reproduce

With this entry in my .pre-commit-config.yaml and Jupyter notebook test.ipynb, running pre-commit run --hook-stage manual black-jupyter --files=test.ipynb does not reformat the notebook.

  - repo: https://github.com/psf/black-pre-co...
flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
lament crow
#

Cool 👀

flat krakenBOT
flat krakenBOT
#

black uses CWD to search for config files when using stdin mode instead of --stdin-file as a starting point for locating config files.

This impacts tools like VS Code where we need to format unsaved file buffer content before saving it to disk. Like as implemented with this extension here https://github.com/psf/black/issues/2883

To Reproduce

Dir structure:

project
|- client
|   |- pyproject.toml
|   |- script.py
|- templates

  1. Set cwd as prokect
  2. Run `...
flat krakenBOT
#

black, 22.8.0 (compiled: yes)
Python (CPython) 3.6.9 (I know, I know, sorry)

Ran black on a pytest file with some pytest.fixture definitions; a Test class, decorated with pytest.usefixtures(), with three staticmethod tests; and several test functions decorated with pytest.parametrize(). Got this:

error: cannot format test/test_apps.py: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues.

Am ...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

I am planning to use black for my existing large codebase. till now it didnt have any formatters used.
black does change a lot of code along with replacing code with backslashes to paranthesis which i am fine with to maintain consistency. but my import statements are greater than 79 chars even after formatting because of nested module structure and long file names which doesn't look good in my code.

**Describe the solut...

flat krakenBOT
#

Rewrite "Next steps" paragraph.

Description

I just wanted to notify you of a paragraph that I thought needed to be re-phrased after reading this page. However, I'll leave the final decision up to you. As I'm not familiar with GitHub at all, I'm not even sure if I'm doing this "Pull Request" correctly and don't have the time or inclination to read up on everything as I don't plan on becoming a regular contributor. Nevertheless, I've put an 'x' in all 3 check boxes below but have no...

dense jungle
flat krakenBOT
#

Describe the bug

Match patterns with lots of |-delimited alternatives are not split into multiple lines.

To Reproduce

% cat longmatch.py 
match x:
    case "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd":
        pass
% black -t py311 longmatch.py --diff
All done! ✨ 🍰 ✨
1 file would be left unchanged.

(Note the line is 142 characters long)

Expected behavior
...

flat krakenBOT
#

Describe the style change

Unlike other expression level single element tuples, single element tuples in yield expressions (e.g. yield 1,) are currently not parenthesized. This is inconsistent, they should also be parenthesized.

Examples in the current Black style

Input:

for a, in b:
    pass

c = d,


def e():
    yield f,
    return g,

Output:

for (a,) in b:
    pass

c = (d,)


def e():
    yield f,
    return (g,)

...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Black currently formats

zzzzzzzzzzzzzzzzzzzzzzzzzzz = zzzzzzzzzzzzzzzzzzzz = zzzzzzzzzzzzzzz = (
    "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
)

to:

zzzzzzzzzzzzzzzzzzzzzzzzzzz = (
    zzzzzzzzzzzzzzzzzzzz
) = zzzzzzzzzzzzzzz = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

Expected behavior

Black should favor using parenthesis and break on the right most side:

zzzzzzzzzzzzzzzzzzzzzzzzzzz = z...
neon loom
#

Sorry if I caused spammed - Airplane internets ...

neon loom
cyan quiver
#

Hi everyone! I'm a bit surprised by two cases where I would have expected different results. Each is one line that is nicely wrapped and one slightly altered example that is not wrapped and thus exceeds the maximum line length (set to 40 for these examples):

a = (
    a123456789.a123456789()
    .a123456789()
    .a123456789()
    .a123456789()
)

a = (
    a123456789.a123456789.a123456789.a123456789.a12345678()
)

Is there a workaround for the above example? I.e. what can I do so that black will wrap the second line?

(
    a123456789.a123456789()
    .a123456789()
    .a123456789()
    .a123456789()
)

a123456789.a123456789().a123456789().a123456789().a123456789()

Is this expected? Could black be extended to add parenthesis or backslashes automatically so the line can be wrapped (the original example where this came from in my codebase had backslashes).

Both examples here: https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AF5AHBdAD2IimZxl1N_WlOfrjrv4T23UbUYHWg1zD1m9T0F1nfTX2BqCGeMRfOiykERJggv8Jr2kKRYcrlFj2OyDovZj7NnlnOGpyU35dDX2uR9yB-_9xw5V_YrtdWCbe1G-8UQuNGjm3gqb5aEVYorvooetAAAbgxBBd21ByMAAYwB-gIAAGMLGH2xxGf7AgAAAAAEWVo=

I'm happy to open GitHub issues for either one, if requested.

Playground for Black, the uncompromising Python code formatter.

flat krakenBOT
dense jungle
#

we should probably fix it by adding parentheses (Black doesn't do backslashes)

cyan quiver
cyan quiver
# dense jungle we should probably fix it by adding parentheses (Black doesn't do backslashes)

Hot take here: IIUC backslashes would allow black to wrap some lines that it currently can't without adding parenthesis, which often change the AST (were not changing the AST if possible is a stated, understandable design decision).

Has there ben any talk on using backslashes vs. using parenthesis? I know this might never change but I always use backslashes when possible to wrap long statements and in my experience, that works well, so IMHO chossing backslashes instead of parenthesis would have also been a valid desing choice.

dense jungle
#

Changing parentheses doesn't change the AST (except in one arcane case, the del statement)

cyan quiver
#

Ah, really? I would have assumed they're part of the AST in most chases.

dense jungle
#

Not using backslashes was an early decision by Lukasz, probably because he thought they looked ugly; I agree

#

(important edit there :D)

cyan quiver
#

I added the two "bad" examples I got to the issue.

cyan quiver
#

I'm looking through our (about 100k lines) project for instances of bad formatting (after running with --preview) and I'm quite happy so far. One thing that comes up a lot in our codebase is examples like this (we have a lot of API help messages and error messages):

example(
    help_text=f'a123456789 "a123456789" {a123456789}')

Which gets formatted to this:

example(
    help_text=(
        "a123456789"
        ' "a123456789"'
        f" {a123456789}"
    )
)

After looking at this for a few hours I still find it quite annoying that different lines of the same implicitly concatenated string end up having different quotes and prefixes. I think the reasons I find this annoying are:

  • Harder to edit because different lines need different quotes escaped (it's mostly english text with lots of ' plus lots of " around identifiers in the help text).
  • Harder to join lines after editing text (need to convert between quote types to be able to join string).
  • The content of each line doesn't start on the same column making it harde to gauge which quotes are part of the string and which are the delimiting quotes.

I haven't found an open GitHub issue about this exact stylistic question. Should I open one or is it obvious that isn't going to change?

Playground for Black, the uncompromising Python code formatter.

#

My idea would be to change the style rules so that implicitly concatenated string literals and f-strings are always formatted as a single item. For that item, a single "best" quote (same rules as currently used for individual strings) is selected plus whether it needs to be an f-string or not, then the implicitly concatenated string is re-flowed and all lines are formatted with the same quote and prefixes.

#

(haven't thought about r-strings, because I have not much experience using those, but our code base certainly contains some of these)

flat krakenBOT
slow ibex
cyan quiver
#

I was just now investigating that idea as a possible workaround. But:

  • It won't solve the issue of having inconsistent prefixes (string literal vs. f-string).
  • I'd actually like to have quotes normalized (it's currently a mess), but I could use other tooling for that.
dense jungle
#

I think using the same quote style consistently for implicitly concatenated strings makes sense, but for prefixes, we would have to change the user's decision on whether to use a raw string, which feels a little icky

cyan quiver
#

I see the issue here. A pragmatic approach would be to look at a corpus of projects and seeing how often r-strings and other strings are mixed in this way. I assume this doesn't happen often, and I would find it super confusing

#

But there is an edge case here: A string containing a single trailing backslash can't be representet as a r-string, i.e. r'C:\Windows\System32' '\\' would have to be converted to a normal string instead of an r-string, if it was to be noramlized to a single string type.

flat krakenBOT
#

Error compiling contract, Error message:
tokenize.TokenError: ('EOF in multi-line statement', (230, 0))

The above exception was the direct cause of the following exception:

vyper.exceptions.SyntaxException: EOF in multi-line statement
line 230:0
229 227 ],
---> 230
---------^

_Originally posted by @Last-Winner in https://github.com/psf/black/issues/2317#issuecomment-169572856

![Screenshot_2023-08-28-23-17-13-06](https://user-images.githubuserc...

mint barn
#

est il possible d'avoir la localisation EXACT d'une personne avec un scipt python ?

bright glacier
mint barn
#

Sry

flat krakenBOT
#

Describe the bug
Indentation of split string in dict would be better align to the value rather than key

To Reproduce

For example, take this code:

a_dict = {
    "key1": "value1",
    "key2": "long longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong"
       "long long value",
}

Expected behavior

I think it would be visually more pleasing to have it aligned by value

a_dict =...
flat krakenBOT
flat krakenBOT
#

Describe the bug

astropy is in the process of migrating its project metadata from the setup.cfg file to the pyproject.toml file in astropy/astropy#15247, as part of this process it triggered black making the changes in astropy/astropy#15254.

black making these changes was surprising as astropy has always configured black via the pyproject.toml file and no changes to the black configuration were made as part of astropy/astropy#15247. This seems like a bug if no ch...

cyan quiver
late dewBOT
#

src/diff_shades/config.py line 35

PROJECTS: Final = [```
flat krakenBOT
civic ore
#

using the same prefix everywhere doesn't make sense imo

#

you shouldn't use f strings when f strings aren't needed

#

same for raw strings

#

e.g.

'blah {'
f'  key: {value}'
'}'
#

doing this is undesirable

f'blah {{'
f'  key: {value}'
f'}}'
outer relic
#
...
 'blah {'
f'  key: {value}'
 '}'
...
#

why not something like that

#

it's clear which strings are f-strings and which aren't, but the strings still all line up

cyan quiver
cyan quiver
civic ore
cyan quiver
#

Yeah, that's what I mean by "question of style". I can understand that some people might find that confusing.

#

OTOH to me it is confusing to have a string expression across multple lines that starts with " but then continues to contain placeholders on the next line.

#

So I think in any case that it's a good thing to get more consistency here, in whichever direction.

civic ore
#

my impression of black's behavior is to pick the simplest representation for every string, which is also consistent

#

just differently consistent

cyan quiver
civic ore
#

granted, breaking up/reflowing f-strings makes me feel uneasy in general

#

feels like it can end up muddying the intent of the code

civic ore
#

hmm, this reflowing has some interesting quirks in general

#

it will never make short things longer

#

so doing black -l 20 then black -l 80 in succession sticks with the narrow reflow

civic ore
cyan quiver
# civic ore feels like it can end up muddying the intent of the code

Yeah, that's my general feeling too. :/ I'm currently thinking a lot about how a style rule could look that would lead to consistent, readable code that also doesn't make hand-formatted code worse in too many cases or at least allows the freedom to hand-format in a way that isn't messed up by black.

cyan quiver
stuck lava
cyan quiver
#

I've only been looing into black for less than a week, but my understanding was that it is moving into the direction of re-wrapping strings in the future. Is that a decision that's still being discussed?

stuck lava
#

I would hope they don't do that personally. Rewrapping at all based on line length seems like a mistake to me. Number of things yes, but that makes little sense for strings.

dense jungle
#

should be in the stable style next year

flat krakenBOT
flat krakenBOT
#

Black produced code that is not equivalent to the source. (with --preview)

Describe the bug

To Reproduce

For example, take this code:

log.info(f'Skipping: {desc["db_id"]=} {desc["ms_name"]} {money=} {dte=} {pos_share=} {desc["status"]=} {desc["exposure_max"]=}')

And run it with these arguments:

$ black --preview file.py

The resulting error is:

cannot format file.py: INTERNAL ERROR: ...


--- src
+++ dst
@@ -8,11 ...
elder tusk
#

i went through all the black preview issues. of 21, 15 + maybe 1 are caused by string_processing, 5 are other things

copper grove
#

Hello, I'm experiencing a bizarre issue with black, some files in certain folders error out when trying to format them with black

#

(both test.py are equivalent and it's just a hello world)

#

The only difference I can see between both is that it's reading from the pyproject.toml in the first example, but even so the only thing defined there is the line-length parameter, and the root of the project seems to be properly identified

slow ibex
#

Maybe these files are saved in different encodings

copper grove
#

Both files have been created in the same way with the same content, and they have the same checksum

foggy walrus
#

If they have the same checksum, then they should be the same... Do they have the same permissions set? Could it be that black can't open the file, and is erroring out saying that the file has no data?

bright glacier
#

Honestly just delete Black's cache, might be some weird corruption

#

It should be in ~/.cache/black

wraith flax
#

hello guys, how can i resolve this error?.....ImportError: DLL load failed while importing win32print: The specified module could not be found.
[8596] Failed to execute

wraith flax
#

but how? error in windows?

slow ibex
bright glacier
slow ibex
#

Yeah, that makes sense. Thank you

flat krakenBOT
#

#2736 added as rule that preserves a blank line between attributes and methods. The implementation looks at the previous line instead of the previous statement, so it depends on the last statement in the (potentially arbitrarily nested) body if black inserts a blank line or not (code). #2783/#3564 fixes this for classes by always inserting a blank line, but this does not apply e.g. to fu...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

The idea behind this change is that we stop looking into previous body to determine if there should be a blank before a function or class definition.

Input:

import sys

if sys.version_info > (3, 7):
    class Nested1:
        assignment = 1
        def function_definition(self): ...
    def f1(self) -> str: ...
    class Nested2:
        def function_definition(self): ...
        assignment = 1
    def f2(self) -> str: ...

if sys.version_info > (3, 7):
    def n...
earnest sequoia
#

is there an official way to turn of caching in development? I've been using BLACK_CACHE_DIR=/dev/null so far

flat krakenBOT
dense jungle
#

release time

flat krakenBOT
dense jungle
#

I don't think mypyc supports 3.12 fully yet as of the latest release

#

oh seems like latest mypy should support it?

#

23.9.0 is on pypi now but without mypyc wheels. I think I'll make 23.9.1 tomorrow, if possible with 3.12 mypyc wheels and otherwise with wheels only for 3.8-3.11

#

cc @bright glacier if you're around/available

bright glacier
#

I'm honestly not entirely sure if the latest mypyc fully supports 3.12.

flat krakenBOT
dense jungle
bright glacier
#

Yea... is black using the latest mypyc?

dense jungle
#

no we were on 1.3.0

#

^ upgrades to 1.5.1

bright glacier
#

probably worth doing that

dense jungle
#

do you know off hand the command to test building the wheels locally?

bright glacier
#

unfortunately no

dense jungle
#

so I can test whether it works without doing another release 🙂

#

ok I'll figure it out

bright glacier
#

found Tal's instructions on running CIBW locally

dense jungle
#

thanks, that's great

bright glacier
#

if you'd like, I can just do an one-off GHA run for 23.9.0 with an updated mypyc (and avoid the bugfix) tomorrow

#

I still have upload privileges to PyPI.

dense jungle
#

it feels slightly sketchy to have the release tag pin 1.3.0 but have a wheel built with 1.5.1

bright glacier
#

fair enough

#

we should really set up the workflow to perform a test run weekly or biweekly

#

I'll take a look this weekend.

dense jungle
#

thanks!

flat krakenBOT
#

The mypyc wheels for the latest release (23.9.0) failed to build (https://github.com/psf/black/actions/runs/6128665138/job/16635954268) because we were running a version of mypyc that doesn't yet support Python 3.12. Therefore, 23.9.0 now only provides a pure-Python wheel on pypi, which will be much slower.

My current plan is to upgrade to the latest mypyc (#3864), confirm that the 3.12 wheel gets built correctly with it, then release version 23.9.1 tomorrow.

dense jungle
#

^ pinning this preemptively in case people complain

bright glacier
#

Reasonably likely I'd say

#

It would be nice if CIBW could not bail on a single platform failing to build, but it does make sense (if one is broken, the others may be subtly broken)

#

or at least it could still save the wheels from the successful platforms for debugging (and returning an appropriate failure indicator)

dense jungle
#

getting errors like this running cibuildwheel, suggesting that it's installing an old version of black somehow ```/project/tests/util.py:31: in <module>
DEFAULT_MODE = black.Mode()
E AttributeError: module 'black' has no attribute 'Mode'. Did you mean: 'mode'?

elder tusk
#

(we've been building 3.12 mypyc wheels for mypy for a month, so it should work with sufficiently new mypy)

stiff acorn
#

Hey!
How do people feel about supporting mojo in black? If you mojo like python black will often just work, but more mojo like features break compatibility.
The mojo peeps apparently have some internal fork

I have a suspicion however supporting two languages (even if they are related) might become a bit of a hassle, so a fork might be preferable.

dense jungle
#

got a 3.12 wheel to build locally, but import fails with ```>>> import black
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "src/black/init.py", line 64, in <module>
from black.linegen import LN, LineGenerator, transform_line
File "src/black/linegen.py", line 1000, in <module>
@dont_increase_indentation
File "src/black/linegen.py", line 971, in dont_increase_indentation
def split_wrapper(
File "/Users/jelle/.pyenv/versions/3.12.0b2/lib/python3.12/functools.py", line 58, in update_wrapper
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'split_wrapper_dont_increase_indentation_obj' object has no attribute 'dict'. Did you mean: 'dir'?

flat krakenBOT
young sand
dense jungle
#

yes, for nested functions only maybe?

young sand
dense jungle
#

Can't reproduce this though with a simple example

young sand
# dense jungle Can't reproduce this though with a simple example

I'm also struggling to create a repro that uses functools.wraps, but here's a repro without functools.wraps. Save this to a file repro.py, run mypyc repro.py, then run python -c "import repro:

from typing import Callable

def dont_increase_indentation(split_func: Callable[[], str]) -> Callable[[], str]:
    def split_wrapper() -> str:
        return "foo"

    split_wrapper.__dict__.update(split_func.__dict__)
    return split_wrapper


@dont_increase_indentation
def delimiter_split() -> str:
    return "bar"

Output:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "repro2.py", line 11, in <module>
    @dont_increase_indentation
  File "repro2.py", line 7, in dont_increase_indentation
    split_wrapper.__dict__.update(split_func.__dict__)
AttributeError: 'split_wrapper_dont_increase_indentation_obj' object has no attribute '__dict__'. Did you mean: '__dir__'?
dense jungle
#

Another oddity is that if you use @wraps the name of the inner function ends up in the module namespace

flat krakenBOT
young sand
#

Which parts of black do you mypycify? Could it be that the issue only occurs if you @wraps a function in a non-mypycified file where the function is imported from a mypycified file?

#

I'm wondering if @wraps in a mypycified file maybe doesn't access __dict__ in the same way as it does in a non-mypycified file

dense jungle
#

this occurs in src/black/linegen.py, the decorator is in the same file as the decorated function

#

I don't recall which parts we compile, almost all I think

#

oh but the decorated function is a generator, I wonder if that matters

young sand
#

I tried with generator functions, they didn't seem to be any different from regular functions

bright glacier
#

I'm not sure mypyc properly supports function attributes ig

#

Nested functions are usually compiled into a dict less class internally

dense jungle
#

I thought so too but the code in linegen.py is pretty old, so it used to work

#

which I also can't reproduce locally 😦

bright glacier
#

Did functools change in 3.12 ?

young sand
young sand
young sand
bright glacier
#

The RTD build is still failing which is strange since docs CI on GH is fine...

#

It's seemingly some bad interaction involving Furo, but I have no idea..

bright glacier
young sand
late dewBOT
#

mypyc/irbuild/callable_class.py lines 60 to 65

# The functools @wraps decorator attempts to call setattr on
# nested functions, so we create a dict for these nested
# functions.
# https://github.com/python/cpython/blob/3.7/Lib/functools.py#L58
if builder.fn_info.is_nested:
    callable_class_ir.has_dict = True```
bright glacier
bright glacier
bright glacier
dense jungle
young sand
bright glacier
#

I don't even have Python 3.10 on my system right now 😅

#
PyMemberDef split_wrapper_dont_increase_indentation_obj_members[] = {
    {"__dict__", T_OBJECT_EX, sizeof(black_shenanigans___split_wrapper_dont_increase_indentation_objObject), 0, NULL},
    {"__weakref__", T_OBJECT_EX, sizeof(black_shenanigans___split_wrapper_dont_increase_indentation_objObject) + sizeof(PyObject *), 0, NULL},
    {0}
};

__dict__ should exist on the split_wrapper callable class object ...

#

unless CPython expects it to be in the tp_dict slot instead??

young sand
bright glacier
#

I love mypyc development, it is definitely not hairpulling

young sand
bright glacier
#

there are two __dict__ lookups in the C (line 412 and 425) not sure what's going wrong yet

bright glacier
bright glacier
#

ah it looks like the decorated function doesn't have a __dict__

❯ ./shim.py temp/black_shenanigans.py -r
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "temp/black_shenanigans.py", line 12, in <module>
    @dont_increase_indentation
  File "temp/black_shenanigans.py", line 7, in dont_increase_indentation
    src = split_func.__dict__
AttributeError: 'builtin_function_or_method' object has no attribute '__dict__'
[black_shenanigans.py in 3.16s: (646) return code 1]
#

nevermind, both attribute lookups are failing...

#

I don't understand why only Python 3.12 is failing with the older mypyc and why everything is failing with the newer mypyc. I'm still stuck at square one :/

dense jungle
#

I don't know if that decreases or increases the mystery

#

btw the magical incantation to build a mypyc wheel locally is HATCH_BUILD_HOOKS_ENABLE="1" python -m pip wheel --no-deps -v .

young sand
# bright glacier It's failing on 3.8 so probably not relevant?

Okay, I managed to get mypyc working on 3.12 for me locally (using pyenv rather than building from source).

It looks like a mypycified version of this file will break with AttributeError on both 3.11 and 3.12:

from typing import Callable

def dont_increase_indentation(split_func: Callable[[], str]) -> Callable[[], str]:
    def split_wrapper() -> str:
        return "foo"

    split_wrapper.__dict__.update(split_func.__dict__)
    return split_wrapper


@dont_increase_indentation
def delimiter_split() -> str:
    return "bar"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "repro2.py", line 12, in <module>
    @dont_increase_indentation
  File "repro2.py", line 8, in dont_increase_indentation
    split_wrapper.__dict__.update(split_func.__dict__)
AttributeError: 'split_wrapper_dont_increase_indentation_obj' object has no attribute '__dict__'. Did you mean: '__dir__'?

But a mypycified version of this file only breaks on Python 3.12:

from functools import update_wrapper
from typing import Callable

def dont_increase_indentation(split_func: Callable[[], str]) -> Callable[[], str]:
    def split_wrapper() -> str:
        return "foo"

    update_wrapper(split_wrapper, split_func)
    return split_wrapper


@dont_increase_indentation
def delimiter_split() -> str:
    return "bar"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "repro3.py", line 12, in <module>
    @dont_increase_indentation
  File "repro3.py", line 8, in dont_increase_indentation
    update_wrapper(split_wrapper, split_func)
  File "C:\Users\alexw\.pyenv\pyenv-win\versions\3.12.0rc2\Lib\functools.py", line 58, in update_wrapper
    getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'split_wrapper_dont_increase_indentation_obj' object has no attribute '__dict__'. Did you mean: '__dir__'?

So it looks like something did change in Python 3.12?

#

I think this is a minimal enough repro to file a mypy issue, anyway (writing it up now)

young sand
slow ibex
#

have you considered using nuitka instead of mypyc?
from my experience, it makes faster code than mypyc and implements semantics closer to pure python behaviour

flat krakenBOT
#

Describe the bug

Black fails to format code containing inline type comments within a multi-line attribute access consistently (the formatting moves the type comments to the end of line in trying to collapse the attribute access, changing meaning and triggering the INTERNAL ERROR check).

To Reproduce

For example, take this code:

❯ cat /tmp/foo.py

def _get_light_style(app: sphinx.application.Sphinx) -> Style:
    return (
        app  # type: ...
drowsy sonnet
#

I just filed my first issue in black!

flat krakenBOT
elder tusk
#

has anyone been able to reproduce the pickle thing locally?

elder tusk
dense jungle
#

yes that's a good idea, thanks

elder tusk
#

looks green! (diff-shades aside)

flat krakenBOT
flat krakenBOT
#

Describe the bug

TLDR: https://github.com/psf/black/pull/3796 can make stuff longer.

To Reproduce

def long_function_with_sine_params_and_long_return(param, another_one) -> ReturnType:
    ...

which is fine in the current style, is now formatted, in the preview style, as

def long_function_with_sine_params_and_long_return(
    param, another_one
) -> ReturnType: ...

which is longer.

Expected behavior

I am not sure:

  • Acce...
flat krakenBOT
#

Description

I spotted that https://black.readthedocs.io/en/stable/ is still pointing to 23.7.0 and https://black.readthedocs.io/en/latest/ to 23.7.1.dev33, instead of both at 2.3.9.0[.devXX].

The last Read the Docs build failed with:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/black/envs/latest/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in bui...
flat krakenBOT
#

Describe the style change

I don't like current behavior on documented FastAPI handlers.

@router.get("/path",)
async def some_handler(
    can_restrict_members: bool | None = Query(None, description="Can restrict members?"),  # the line is toooooo long
):
    ...

Examples in the current Black style

async def some_handler(
    can_restrict_members: bool
    | None = Query(
        None,
        description="Can restrict members?",
    ),...
dense jungle
#

time to try another release

bright glacier
#

LGTM.

bright glacier
#

Let's see if the workflow passes.

dense jungle
#

I'm glad to no longer be playing Russian roulette with mypyc when I actually cut the release 🙂

flat krakenBOT
#

As of #3870 we now run the full mypyc wheel build workflow on all PRs. This should prevent a repeat of the 23.9.0 release, which didn't come with mypyc wheels because after the release was cut we discovered that the mypyc build was broken (#3865).

It's very important to me that we can test the wheel build before the release, as is happening right now on #3878 for the upcoming release 23.9.1. That gives me confidence to cut a release knowing that the build will actually succeed.

Some o...

dense jungle
#

it's building the last wheel now

dense jungle
#

and all the wheels got uploaded 🎉

flat krakenBOT
#

After upgrading to 23.9.1, due to #3846 I ran into the following situation:

  • a/file.py is a symlink to b/file.py
  • b/file.py is not formatted because it's in exclude

Previously, Black ignored the file. Now it wants to format it.

I would expect Black to not format these files. The actual files are excluded, the symlinks aren't themselves Python files. I think this can be implemented with a simple rule: never follow symlinks. If the file is in a place that Black should form...

elder tusk
#

hmm seeing

    return black.format_str(
  File "src/black/__init__.py", line 1085, in format_str
  File "src/black/__init__.py", line 1117, in _format_str_once
  File "src/black/nodes.py", line 156, in visit
  File "src/blib2to3/pytree.py", line 47, in type_repr
AttributeError: attribute 'paramspec' of '_python_symbols' undefined

on some test at work

dense jungle
#

that node should have been added in #3703 which was in 23.7.0 already

elder tusk
#

probably not from file system state, this is in CI on some test that looks like it's running black on some codegen. anyway, i'll look into it and see what's going on

dense jungle
#

interestingly line 47 appears to be where it does dir(), and the getattr is on line 48.

#

I get a different error locally when I run type_repr

#
>>> blib2to3.pytree.type_repr(42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/blib2to3/pytree.py", line 43, in type_repr
    from .pygram import python_symbols
ImportError: cannot import name 'python_symbols' from 'blib2to3.pygram' (/Users/jelle/py/venvs/py311/lib/python3.11/site-packages/blib2to3/pygram.cpython-311-darwin.so)
#

oh works if I import black first

flat krakenBOT
flat krakenBOT
flat krakenBOT
carmine coyote
#

Hello there! I am looking at https://github.com/psf/black/pull/3796 that, I'd expect, would give this

from typing import overload

...

@overload
def tesy(children: None) -> None: ...
@overload
def tesy(children: str) -> list[dict[str, str]]: ...
def tesy(children: str | None) -> None | list[dict[str, str]]:
    if children is not None:
        return None
        
    return [{"options": "str"}]

...

as output format. However, that's not the case.

What am I missing? 😕

GitHub

Fixes #1797, in particular, see #1797 (comment)

slow ibex
#

i think this applies only to stub files (.pyi)

#

no, stubs are already formatted like this
from Preview.dummy_implementations in self.mode i can infer that you should enable dummy_implementations preview feature

#

i dont see a way to enable only specific features from cli
i guess --preview will do the thing

flat krakenBOT
final lagoon
#

My boss wants to implement Black but also believes that Black may introduce bugs. I shared Black's AST documentation but was told that “there's plenty of places in the existing codebase where a bad import of a typo essentially causes a broken AST”.

Perhaps my understanding of syntax trees is incorrect? I thought that with an identical AST, the introduction of bugs would be impossible.

dense jungle
#

your understanding is basically correct

final lagoon
final lagoon
dense jungle
final lagoon
#

Probably not, but I recognize your name as a Black dev... and maybe from IRC or the Python mailing list? Not sure.

bright glacier
dense jungle
neon loom
#

Quick search didn't show anything - Anyone had flake8 E704 + black fun - I just did on some bandersnatch code - Had to do this to ignore the formatting: https://github.com/pypa/bandersnatch/pull/1545/commits/ec8e1fa9b7e62249e0f69fc088445545d586ac00

#

Can't see if E704 is new or not ... wonder why this has only just come up 😐

#

Or did we just add the merge it to the same line?

#

Ahh right we did ... Lets see if I can find the reasoning ...

elder tusk
#

yeah, you're looking at https://github.com/psf/black/pull/3796. Black's formatting here is still PEP-8 compliant, maybe we can get pycodestyle to change their logic. E704 isn't part of its default config...

flat krakenBOT
#

Describe the style change

There exist a number of functions in numpy and other libraries that use numpy arrays that allow you to specify the array shape directly as function args rather than as a tuple. It is common style when calling such functions with the intent of specifying a single dimension to add a trailing comma. This is such that the argument list is read as a shape and looks like what would be returned when looking at .shape. Unfortunately this plays badly with Black's mag...

stuck lava
#

I would not worry about black introducing bugs, except when it has questionable taste in formatting and that can trip up humans :P

neon loom
flat krakenBOT
#

This preview style change https://github.com/psf/black/pull/3796 violates E704 as implemented by flake8 / pycodestyle.

Note that the change itself is PEP 8 compliant. E704 is disabled by default in pycodestyle for this reason. ruff intentionally does not implement E704, instead explicitly deferring to Black on this question.

At a minimum we should update https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#flake8 , but figured I'd open an issue to discuss.

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the bug

Black miscomputes the horizontal space required for lines containing the power operator ** with simple operands, and rewraps them much earlier than the expected 88-character line length. Perhaps that computation wasn’t adjusted for #538/#2726.

To Reproduce

Run Black with no arguments on this code ([playground link](https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4ADWAE5dAD2IimZxl1N_WmyLkeQ19WvnMnMLiOdunzNME7LTg9q9ETmvUb3zADAfw...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

The simple way of resolving #2316
I would personally prefer to resolve it by formatting it without added parentheses (i.e. option 3 in #2316) to save two unnecessary lines, but that will likely require a bunch of messing around in _maybe_split_omitting_optional_parens and could also impact some other cases - so I think I'll hold off on that one for the moment.

I had to extend maybe_make_parens_invisible_in_atom to also allow expressions, I was quite afraid this would ...

flat krakenBOT
#

Describe the style change

Currently Black has no opinion on the number of empty lines that may exist between the module's docstring and the first import line other than collapsing down to at-most-2. I'm proposing that Black should have an opinion, specifically that there should be none (in line with the general philosophy on empty lines).

Examples in the current Black style

All three examples are left unchanged:

"""My super cool module"""


from __future__ ...
silent apex
#

!help site

late dewBOT
#
Query "site" not found.

Did you mean:
filter
stream

silent apex
#

!help

neon loom
#

Someone here might know - is there any nogil runtime build available anywhere for testing it out? I’d like to compare black’s multiprocess approach to real Gil-less threads and see on a decent size repo if there is any different - or using diff shades …

#

I have 4 hours in an airport tomorrow and this could kill some time

neon loom
#

Ahh - docker nogil/python is prob the easiest way. cool

fresh marlin
#

do checkout and give opinions ty 🙂

#

@viscid vale

#

all the best buddy

#

did it hurt when u fell from heaven

flat krakenBOT
flat krakenBOT
#

Description

As I've been working more on Black, I found the full printing of AST trees to be cumbersome and insanely long, but it regardless often containing necessary info, so I ended up modifying the value of that variable a lot and/or temporarily splitting tests into shorter files. But realized that diff-printing would solve that issue, and while not as simple as I'd initially hoped it wasn't too tricky to work out and is turning out very useful.

Checklist - did you ...

...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

Its often problematic, that you format dictionaries with new comma at the end of each iterator, exg.:

{
"any_list": [
"hans",
"franz", <--- comma to much for json format
]
}

The Problem is, that you finally cant copy your dicionary into a json-file, because the syntax doesnt fit anymore.

Describe the solution you'd like

format dictionaries in a style, that obyes json syntax.

hazy kelp
flat krakenBOT
#

Describe the bug

As per this stackoverflow: https://stackoverflow.com/questions/70961301/black-not-formatting-python-code-from-vscode
And this one: https://stackoverflow.com/questions/66846608/attributeerror-module-secrets-has-no-attribute-token-bytes

Having a 'secrets.py' present in the repository causes black to fail on startup within VSCode

To Reproduce

  1. Setup black to run in VSCode (use the black formatter extension)
  2. Add a file names 'secrets.py' to the project
    ...
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

Closes #3756

👋 First PR c:

StringParenStripper was getting an input that looks like this:

Line(leaves=[Leaf(LSQB, '['),
             Leaf(LPAR, '('),
             # ⬇️ this leaf's ID is the key of the comment
             Leaf(STRING, '"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"'), 
             Leaf(RPAR, ')'),
             Leaf(COMMA, ','),
             Leaf(RSQB, ']')],
     comments={4348688720: [Leaf(COMMENT, '# aaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
flat krakenBOT
flat krakenBOT
#

Description

Closes #3851

Please let me know if I should be going along a different path c^:

I had originally intended to make a visit_yield_expr = partial(v, keywords={"yield"}, parens={"yield"}) to be more similar to return alongside this, but that doesn't work since yield can be an expression but return can't. https://github.com/psf/black/blob/1b08cbc63400a8b8e0fbb620b6b2a4dab35e1e7b/src/black/linegen.py#L527

Checklist - did you ...

  • [ ] Add an entry in `C...
flat krakenBOT
flat krakenBOT
slow ibex
# flat kraken

i use sublack on ST4 and dont see any problems
there is another extension that uses LSP, right? what are advantages?

flat krakenBOT
#

I ran this diff also on our internal codebase, which very heavily uses yield because of https://github.com/quora/asynq. Most of the changes are clear improvements, but I noticed a few cases like this:

-        content_type = yield (
-            a.model.tribe.item.TribeItem(tribe_item_id).get_content_type.asynq()
-        )
+        content_type = yield a.model.tribe.item.TribeItem(
+            tribe_item_id
+        ).get_content_type.asynq()

Here the old formatting see...

flat krakenBOT
flat krakenBOT
#

Description

Fixes #3018

I started out with modifying left_hand_split, doing a comprehensive rewrite of it to fully handle all manner of possible cases (see the length of the test file). But after reading more of the existing source code I started realizing that I was duplicating functionality, and in fact the only real thing that needed fixing was making sure that right_hand_split was applied to the function definition first when there's a trailing comma.
I also found a ...

weak remnant
#

Is the difference in spacing around = depending on whether there's a type hint intentional?

def foo(x=5): ...
def foo(x: int = 7): ...
young sand
flat krakenBOT
#

Description

I run pylsp-mypy in my dev environment, which screams loudly about all the illegal stuff being done in tests/data/.*. So excluding those files in the mypy config would be a nice QoL for me, and probably other users as well, while making no difference to the CI.

Checklist - did you ...

None of the below

  • [x] Add an entry in CHANGES.md if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
flat krakenBOT
#

Describe the style change

Black excludes one-tuples (1,) and single-item subscripts with trailing comma tuple[int,] from magic comma handling, because unlike in list literals etc. the comma here is required, so cannot be used to distinguish between the user's desire to single-line or multi-line.

The single-line format chosen by Black is the desired behavior for "actual" one-tuples, but is not the desired behavior for "currently 1 item but maybe more in the future" tuples.

**E...

flat krakenBOT
neon loom
#

Compilation failing

 #15 49.56       aiohttp/_websocket.c:3293:53: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
dense jungle
neon loom
#

O yeah, the container has probably moved to 3.12

young sand
neon loom
#

I guess we should open an issue and hard pin us to 3.11 until that's fixed for aiohttp ?

dense jungle
#

aiohttp/yarl need to cut a release and regenerate their Cython stuff I think

dense jungle
neon loom
#

Ya, and unfortunately we need to test it 😐

#

Well, install [d] in the container unless we make separate containers

#

But running blackd in a container is a good use case and thus why I did it

dense jungle
#

and apparently their releases are blocked by some nodejs thing?

flat krakenBOT
#

Describe the bug

Docker is failing to build aiohttp with python 3.12.

To Reproduce

Build docker with a 3.12 base image

Expected behavior

Docker to build

Environment

Black's version: [main]
OS and Python version: Debian/3.12

Additional context

This is due to aiohttp being used for blackd

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

The preview style moves a comment on one line of an implicitly concatenated string to a different line.

$ python -m black --version
python -m black, 23.9.1 (compiled: yes)
Python (CPython) 3.9.14
$ python -m black --diff --preview movecomment.py 
--- movecomment.py      2023-10-06 01:40:10.153647+00:00
+++ movecomment.py      2023-10-06 01:40:41.077230+00:00
@@ -1,7 +1,7 @@
 xxxxxxx.xxfx(
-    f"xxxx_xxxxxxxx: "  # xxxxxxx
+    "xxxx_xxxxxxxx: "
     f"xxxxx={xxxx_xxxxxxxx.x...
dense jungle
#

I feel we're going to get a lot of complaints if we actually turn on expterimental string processing by default in January

elder tusk
#

yeah, i agree. impl isn't really there yet; i went through issues a while back and 3/4 of the preview style bugs are esp related

dense jungle
elder tusk
#

i think is okay to push it out if controversial, i think less okay to push it out if buggy and controversial

#

especially since folks people who are okay with the bugs have preview. i'm also not seeing folks really clamouring for the feature, so seems fine to get there when we get there?

#

but i'll try to take a look at some of the bugs some time!

flat krakenBOT
#

Describe the bug

Black 23.9.1 reformat already clean but complex code expression and creates a line too long.
The original expression does not have lines longer than 79 characters.
But black reformat it and creates a line of 94 characters.

To Reproduce

Create a file named bug.py with the following code :

if True:
    if True:
        if True:
            abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr = (
                abcdefghijklmnopqrstuvwxyzabcd
    ...
young sand
#

From the test cases in https://github.com/psf/black/blob/main/tests/data/preview/multiline_strings.py, I guess this is a deliberate choice, but I really don't like the way the preview style will do things like this:

diff --git a/foo.py b/foo.py
index 14dda3925..f2e71baec 100644
--- a/foo.py
+++ b/foo.py
@@ -2,10 +2,8 @@ from textwrap import dedent


 def foo():
-    return dedent(
-        """
+    return dedent("""
         foo
         bar
         baz
-        """
-    )
+        """)

I don't mind moving the opening """ so much, but having the closing ) be on the same line as the closing """ feels really inconsistent with black's style everywhere else, to me at least

flat krakenBOT
#

Describe the bug
This was first reported in #2699, and thought resolved in #2990, except that only solved the specific case of the function having no parameters.

To Reproduce
Run the test return_annotation_brackets_string:

https://github.com/psf/black/blob/3a2d76c7bcf39e852f3b379b76537d7847ed4225/tests/data/preview/return_annotation_brackets_string.py#L1-L23

The second function should be formatted exactly the same as the first one.

dense jungle
flat krakenBOT
neon loom
# flat kraken

Will take pointers on the issue of best way to do this or PRs for this one 😄

flat krakenBOT
neon loom
#

Looking goof for the docker action. Should stop you all getting the scary/ugly red X for now

#

Gosh our build pipeline is impressive. haha

flat krakenBOT
#

Describe the style change

The suggested style change regards the type parameter syntax introduced in Python 3.12.

When formatting lines too long, I think line-wrapping should occur in the arguments' parenthesis rather than in the type parameters' brackets.

Examples in the current Black style

This would work with any generic function using the new type parameter syntax with a long enough signature (longer than the line-length).


type SupportedDataTypes =...
flat krakenBOT
#

Description

Resolves #2316 according to the nextline strategy. The poll is currently 10 to 6 of favor of this style, which certainly isn't a slam-dunk, but enough for me to implement it and we can progress the discussion after seeing impacts on existing code.

This is a pretty messy implementation, as can be seen by the sheer length and the complexity check having made me reformat my code several times to break out functions.
I don't love the existence of _split_first_typehint a...

white jungle
#

Hi, I'd like to contribute something to Black as part of hacktoberfest. Should I start from good-first-issues, or are there particular issues to be looked at for the fest?

flat krakenBOT
#

Description

Resolves https://github.com/psf/black/issues/1872.

This is a rebase of https://github.com/psf/black/pull/2996 and therefore most credit should go to @jpy-git.

I have excluded the refactoring that was included in the rebase attempt at https://github.com/psf/black/pull/3287. I feel the refactoring makes the PR unnecessarily hard to review and rebase. It's probably a very desired refactor (I can't comment on this since I don't know the codebase too well), but it ...

elder tusk
#

okay seeing a diff in Grammar3.11.5.final.0.pickle in the good case vs bad case

#
In [17]: set(a["symbol2number"]) - set(b["symbol2number"])
Out[17]: set()

In [18]: set(b["symbol2number"]) - set(a["symbol2number"])
Out[18]: 
{'paramspec',
 'type_stmt',
 'typeparam',
 'typeparams',
 'typevar',
 'typevartuple'}
#

we've dropped python 2 support yeah

#

but huh there are really no reports of this grammar cache bug on issue tracker

flat krakenBOT
flat krakenBOT
flat krakenBOT
bright glacier
dense jungle
elder tusk
#

should we be thinking about 23.10?

dense jungle
#

we have had quite a few changes since 23.9, so why not?

#

I don't think there's other PRs that are close to being mergeable, maybe the mypy one

elder tusk
#

great!

white jungle
#

Hi, I'd like to contribute something to Black as part of hacktoberfest. Should I start from good-first-issues, or are there particular issues to be looked at for the fest?

#

Posted earlier, looks like it got missed. Apologies in advance!

dense jungle
white jungle
# dense jungle Thanks for your interest in contributing! The "good first issue" label is a good...

I've added some documentation to document the different installation methods and binaries. Made a draft pull reqest for it here - https://github.com/psf/black/pull/3941

GitHub

Description
Based on the comments in #2492 , I've made the following documentation additions:

Added a new page 'Ways to install Black' under Usage and Configuration
Linked to it in the...

flat krakenBOT
flat krakenBOT
slow ibex
#

the weirdest issue I've seen in a while this

raw orchid
#

wtf

mint barn
#

?

white jungle
#

I'm looking into the different extras that can be installed with Black, and I'm a little confused about the two undocumented ones.

  • jupyter - For formatting Jupyter notebooks. (Documented)
  • d - Run Black as a server. (Documented)
  • colorama - Enables colored diffs
  • uvloop - Speeds up Black when formatting multiple files concurrently

My doubts:

  • Did I miss any extras?
  • Am I correct about the descriptions of the last two?
flat krakenBOT
#

Describe the style change

Currently, black preserves the blank line before regular doc strings, but not before raw docstrings. It should preserve them before both.

Input

class TextIOWrapper(TextIOBase):
    
    r"""Character and line based layer over a BufferedIOBase object, buffer.

    [...]
    """

    _CHUNK_SIZE = 2048
    
class TextIOWrapper(TextIOBase):
    
    """Character and line based layer over a BufferedIOBase object, buffer.

    [......
earnest sequoia
#

When i try to run black over cpython it just seems to hang at some point. Is there any good way to debug this? The backtrace only shows me return self._semlock.__enter__() and -v unfortunately doesn't tell me which files it started to debug

flat krakenBOT
#

Hi,
I've switched to VS code and pyright recently, and I realized black is breaking a lot of # pyright: ignore comments.

Input (both are valid for pyright):

asm_client: SecretsManagerClient = boto3.client("secretsmanager") # pyright: ignore[reportUnknownMemberType]
asm_client: SecretsManagerClient = boto3.client( # pyright: ignore[reportUnknownMemberType]
    "secretsmanager"
)  

Output:

asm_client: SecretsManagerClient = boto3.client(
    "secretsman...
dense jungle
dense jungle
#

it might be Lib/test/test_traceback.py

#

oh I bet it's because of the function that has 800 locals assigned in a single assignment statement

late dewBOT
#

Lib/test/test_traceback.py line 3470

a791 = a792 = a793 = a794 = a795 = a796 = a797 = a798 = a799 = a800 \```
narrow sand
#

Bruh

dense jungle
#

it did eventually finish for me though. Running on CPython main I got 1662 files reformatted, 152 files left unchanged, 18 files failed to reformat.

#

oh lol test_traceback crashed with error: cannot format /Users/jelle/py/cpython/Lib/test/test_traceback.py: maximum recursion depth exceeded

earnest sequoia
#

ah thanks, i didn't wait long enough (results with -W 1 -v):

1651 files reformatted, 149 files left unchanged, 23 files failed to reformat.

real    37m51,358s
user    37m14,769s
sys    0m1,981s
flat krakenBOT
dense jungle
#

^ huh, I opened a few other PRs earlier and they didn't show up here

dense jungle
#

@elder tusk would you mind reviewing psf/black#3947 psf/black#3949 psf/black#3950 when you get a chance? after that I think we should release

dense jungle
#

3950 is most important since it fixes a parsing regression

white jungle
#

I was looking into substituting the supported Python version in the docs, and it looks like it'll require an extra Myst extension, as documented in https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#substitutions-with-jinja2. Will this be required for my PR?

(Also noticed that main got updated, so will update my fork before submitting the actual PR)

MyST Parser

MyST-Parser is highly configurable, utilising the inherent “plugability” of the markdown-it-py parser. The following syntaxes are optional (disabled by default) and can be enabled via the sphinx co...

dense jungle
white jungle
dense jungle
dense jungle
#

we maybe could have made 3.12 wheels now that mypy 1.6 is out? I forgot the exact blocker

#

anyway, that can wait for the next release

white jungle
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

I like black's default of 88-char line length, except for docs/ renderings, where code blocks may be rendered via Sphinx with 79 char width. This leads to unnecessary scrolling left/right to see the last 9 chars.

It would be useful to enable black to have sub-configurations. This was requested in https://github.com/psf/black/issues/1370, and was postponed into the future.

Describe the solution you'd like...

young sand
elder tusk
#

yeah i made sure to merge my PR in time for jukka's promised 1.7 fast follow

pallid harbor
dense jungle
flat krakenBOT
flat krakenBOT
#

input:

f(
    "lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor" 
    "incididunt ut labore et dolore magna aliqua Ut enim ad minim",
    "",
)

Expected output:

f(
    (
        "lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor" 
        "incididunt ut labore et dolore magna aliqua Ut enim ad minim"
    ),
    "",
)

Actual:

No change

Related:

...