#black-formatter

1 messages · Page 20 of 1

bright glacier
#

even before there's a bonfire?

plain atlas
#

how can you yank nothing tho?

dense jungle
#

that comes after

#

I think there's two permission levels in PyPI

bright glacier
#

but I want to cook my marshmallows :'(

dense jungle
#

hm also we have two owners on the black project that don't have 2FA enabled

#

I'm going to yank them

plain atlas
#

lmao

bright glacier
#

I should setup 2FA on my PyPI account

plain atlas
#

yanks ichard from pypi

bright glacier
#

I have it for GH already since it's required for the PyPA org

plain atlas
#

oh my god now your name makes sense

#

__r__ichard

#

i can't believe I just realised that

#

</tangent>

dense jungle
#

also @bright glacier once you have 2FA on I can add you to the Black project on PyPI

bright glacier
#

I can't actually find any docs on environment markers, apparently the relevant PEP was rejected yet we still use them?

#

unless I'm reading the wrong pep :/

#

Yup I was reading the wrong one ...

plain atlas
#

lmao

plain atlas
#

😛

dense jungle
plain atlas
#

lmao

bright glacier
#

lemme quickly run my script

plain atlas
#

to do that, I would need triage perms--
and to get those, I would need to be an active contributor of black, or at least know a bit more than I know now about how it works, and then be selected to get those

bright glacier
#

I've closed ~225 issues so far.

plain atlas
#

👁️

bright glacier
#

Jelle is still beating me tho :(

plain atlas
#

jeez

bright glacier
#

You remember those closing parties we held in the evenings 😅

plain atlas
#

me? no

bright glacier
#

we closed A LOT of issues in a short timeframe

plain atlas
#

I don't remember that, sad

#

wait I kinda do

bright glacier
plain atlas
#

god that was a great read

#

how did I miss that smh

bright glacier
#

and that's just the first half

#

if you scroll down some more you'll find day two of "closing as many issues we can"

#

Looking into the matter more closely (after getting distracted), I first thought we could ignore the issue but unfortunately possibly not

late dewBOT
#

setup.py line 82

"typing_extensions>=3.10.0.0; python_version < '3.10'",```
bright glacier
#

I would've thought this means we don't pull in typing-extensions on 3.10 but it looks like the development versions don't count

#

Is it worth excluding 3.10.0.1?

dense jungle
bright glacier
#

lol, on further inspection, 3.11 might be broken

#

on that version typing-extensions definitely shouldn't be pulled-in

late dewBOT
#

src/black/handle_ipynb_magics.py line 12

from typing_extensions import TypeGuard```
bright glacier
#

would crash on 3.11 :p

plain atlas
#

3.11 python or 3.11 typing extensions

bright glacier
#

CPython

plain atlas
#

ah

#

hmmmm, I wish we could have threads for this channel, just thought of something else

#

!pypi atoml

late dewBOT
plain atlas
#

our previous discussion about toml libs, here's a 4th one.

#

the tldr is its an updated version of tomlkit

bright glacier
#

hopefully we don't have to move from tomli

plain atlas
#

lol

#

tomli is good but the difference with tomlkit (and by extension. atoml) is that it preserves style and comments

little parrot
#

i thought tomlkit was already up to date

plain atlas
#

!pypi tomlkit

late dewBOT
dense jungle
#

preserving style doesn't matter for black because we only need to read toml files

plain atlas
#

last updates: may

#

no ik, it was just that I and ichard had a previous dicussion about all the libs

bright glacier
plain atlas
#

tomli is extremely maintained, imo

little parrot
#

it doesnt matter if youre black cause youre only parsing right?

bright glacier
#

the track record for this area hasn't been good

bright glacier
plain atlas
#

which is ironic, given that there was a pep for using pyproject.toml

#

^

bright glacier
plain atlas
#

i'm pretty sure that they were talking about revising 1.0 since implementations don't actually implement it correctly

bright glacier
#

it's probably just me not being able to read properly, but I'm just going to assume how it works

plain atlas
#

lol

#

that's worded weirdly strange

bright glacier
#

I'm going to need to exclude typing-extensions==3.10.0.1 in a lot more places than I would've expected sigh

#

why is all of our dependencies going up in flames this weekend :p

#

what a great start to my psf/black releasing career :/

plain atlas
#

look at it this way: you're more inclined to start looking at poetry

bright glacier
#

how does that help when I don't even understand how requirements work looking at this red GHA log

late dewBOT
#

setup.py line 82

"typing_extensions>=3.10.0.0; python_version < '3.10'",```
bright glacier
#

wait what

#

so the requirement is skipped on 3.10-dev

plain atlas
#

because the under 3.10 means that it doesn't use that on 3.10

bright glacier
#

but why is the test suite passing on 3.10-dev if we shouldn't be pulling it in!

plain atlas
#

something else probably uses it

bright glacier
#

I'm just going to ignore the failing pre-commit hooks for now :p

late dewBOT
#

setup.py line 58

"typing_extensions>=3.7.4",```
bright glacier
#

that doesn't look quite right

#

since the requirement in the pip log is 3.6.5

plain atlas
bright glacier
#

where is pip getting typing-extensions>=3.6.5 from?

#

the aiohttp one you just showed is too high

#

Ah, that's from main.

late dewBOT
#

setup.py line 74

"typing_extensions>=3.6.5",```
bright glacier
#

Here's the requirement from aiohttp===3.7.4.post0

plain atlas
#

aha oops

#

i got half of the way, that's good

bright glacier
#

Thanks

plain atlas
#

🙂

bright glacier
#

So wait, how am I supposed to fix this?

plain atlas
bright glacier
#

But we do need at least >=3.10.0.0

plain atlas
#

that would ensure that 3.10.0.1 does not get installed on 3.10.X

#

then

#
"typing_extensions>=3.10.0.0;",
"typing_extensions!=3.10.0.1; python_version ~= '3.10'",
#

possibly

bright glacier
#

I don't quite remember whether installers handle this well, but requirements probably have to be merged somewhere (eg. six requirements are probably specified multiple times in the dep tree) so hopefully this works

plain atlas
#

hmmm

#

to be fair, once you make a branch and the tests run, we'll know 😛

bright glacier
#

The release should probably be yanked anyway, but looks like Jelle can't do anything about it sadly

plain atlas
#

yeah...

bright glacier
#

!d sys.version_info

late dewBOT
#

sys.version_info```
A tuple containing the five components of the version number: *major*, *minor*, *micro*, *releaselevel*, and *serial*. All values except *releaselevel* are integers; the release level is `'alpha'`, `'beta'`, `'candidate'`, or `'final'`. The `version_info` value corresponding to the Python version 2.0 is `(2, 0, 0, 'final', 0)`. The components can also be accessed by name, so `sys.version_info[0]` is equivalent to `sys.version_info.major` and so on.

Changed in version 3.1: Added named component attributes.
bright glacier
plain atlas
#

ah

#

well

#

@bright glacier 😛

"typing_extensions>=3.10.0.0;",
"typing_extensions!=3.10.0.1; python_version >= '3.10'",
#

this means that 3.10.0.1 never gets installed on 3.10 or up

bright glacier
#

thanks but I changed it manually already

#

Time to wait for CI again, I'mma go and get a glass of water

plain atlas
#

lol

bright glacier
#

nvm, lint already failed

#

oh that's a dumb mistake

#
src/black/handle_ipynb_magics.py:10:4: F821 undefined name 'sys'
plain atlas
#

33 warnings

#

from one mistake

#

wow

flat krakenBOT
#

Description

re. import, the ipynb code was assuming that typing-extensions would always be available, but that's not the case! There's an environment marker on the requirement meaning it won't get installed on 3.10 or higher. The test suite didn't catch this issue since aiohttp pulls in typing-extensions unconditionally.

Checklist - did you ...

  • [x] Add a CHANGELOG entry if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
bright glacier
#

OK, now I'mma go get a glass of water.

plain atlas
#

heheheheh

bright glacier
#

fine, i'm very annoyed

plain atlas
#

😔

flat krakenBOT
bright glacier
#

watch as we get a ton of new issues after I push the release

plain atlas
#

ofc

plain atlas
bright glacier
#

you're not

plain atlas
#

wdym

bright glacier
plain atlas
#

oh uh

#

..how long does it take the ci to finish, typically?

bright glacier
#

14 minutes

plain atlas
#

oh jeez

bright glacier
#

the mainline tests only take max 5 minutes (usually because filesystem operations on GHA MacOS are painfully slow) but the primer and test uvloop ones take 10-15 minutes

plain atlas
#

jeez

#

2 left

#

1

#

yay

plain atlas
#

oh my god all 35 checks run again?

bright glacier
#

yup cause it's technically a different commit

plain atlas
#

damn

bright glacier
#

even if you do a git commit --amend --no-edit, it still gets a different SHA

plain atlas
#

how

bright glacier
#

although the different parent is already enough to cause the checks to run

bright glacier
#

the time is factored into the SHA IIRC

plain atlas
#

but amend keeps the old time

#

or

#

hmmmm

#

are there two times on every commit

#

when they were dated and when they actually made?

bright glacier
#
❯ git log -n1 --oneline
968621b (HEAD -> exclude-broken-typing-extensions, origin/exclude-broken-typing-extensions) Exclude broken typing-extensions version + fix import

❯ git commit --amend --no-edit
[exclude-broken-typing-extensions 0363c16] Exclude broken typing-extensions version + fix import
 Date: Sun Aug 29 16:02:54 2021 -0400
 3 files changed, 14 insertions(+), 5 deletions(-)

❯ git log -n1 --oneline
0363c16 (HEAD -> exclude-broken-typing-extensions) Exclude broken typing-extensions version + fix import
plain atlas
#

yeah

#

wild

#

fuck i just made a mistake from this and accidently pushed my commits

stuck vapor
#

I was gonna suggest sticking to the previous typing-extensions version and not using TypeGuard, but it looks like it's all green now 🥳

bright glacier
#

it would've broke if you used the d extra anyway so it was worth excluding

#

[d] -> aiohttp -> typing-extensions (unconditionally!)

plain atlas
#

i find it slightly funny that 3.10 broke on 3.10

bright glacier
#

I still need to add python -Xdev -b -Walways -m pytest --strict-markers --strict-config to the test suite so we actually pay attention to warnings and other issues, but I'll do that later.

#

The --strict-markers flag would've saved me some trouble if it was enabled during my mypyc work ^^

flat krakenBOT
plain atlas
#

me 5 seconds later: pre-commit autoupdate

bright glacier
plain atlas
#

gotta wait for the pypi release

#

oof

#

hmmm

late dewBOT
#

.github/workflows/upload_binary.yml lines 3 to 5

on:
  release:
    types: [published]```
bright glacier
#

it's probably because I first did a draft release and then published that instead of directly creating the release

plain atlas
#

ah

#

well, doesn't seem that way tbh

bright glacier
#

wrong workflow

#

I meant pypi_update.yml

plain atlas
#

well

#

that's a problem

bright glacier
#

I guess I'll push the distribution artifacts manually then. Good timing on Jelle giving me the keys.

late dewBOT
#

.github/workflows/pypi_upload.yml lines 3 to 5

on:
  release:
    types: created```
plain atlas
#

Note: The prereleased type will not trigger for pre-releases published from draft releases, but the published type will trigger. If you want a workflow to run when stable and pre-releases publish, subscribe to published instead of released and prereleased.

#

i have no idea what the fix is here

bright glacier
#

Sounds like the created event occured on the draft release, but since it was a draft it was ignored.

#

Probably use published since the upload_binaries.yml one fired

plain atlas
#

note: published will fire on pre-releases as well

bright glacier
#

we don't do pre-releases tho

#

draft releases are different from pre-releases FYI

plain atlas
#

ah

bright glacier
#
❯ twine check dist/*
Checking dist/black-21.8b0-py3-none-any.whl: PASSED
Checking dist/black-21.8b0.tar.gz: PASSED

that's a good sign, time to actually push this to PyPI

#

and yes, I did a wipe, clean clone, and made a new virtual environment so the artifacts shouldn't be dirty

flat krakenBOT
#

Description

Fixes pypi_upload.yml not running when @ichard26 published a draft release to release 21.8b0.

Documentation is here, https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release, and since upload_binary ran, with this: https://github.com/psf/black/blob/a8b4665e7d6eb945c47820adb1a3f8b006adce0c/.github/workflows/upload_binary.yml#L3-L5, this should fix the problem.

Checklist - did you ...

  • [] Add a CHANGELOG entry if necessary?
    -...
plain atlas
#

😛

#

I gotta go offline now cya

bright glacier
#

ugh, the checklist markdown is broken

#

cya!

#

!remind 1D update stable tag and check readthedocs

late dewBOT
#
Yeah okay.

Your reminder will arrive on <t:1630360476:F>!

dense jungle
#

thanks for making the release @bright glacier!

bright glacier
#

that took way longer than I expected 😅

#

hopefully moving the stable tag isn't as longwinded as this mess 🤞

#

Huh, I have an idea. Since 20.8b1 doesn't have a wheel, it's a bit of a pain to install. Can't we use build numbers to release a new wheel that still matches ==20.8b1 (that's why === exists!) but without breaking PyPI's static file rules?

plain atlas
#

What why did a wheel not get pushed

bright glacier
#

We deleted it due to build mistake.

plain atlas
#

Also that's uh... Gonna be the first bug report I bet

dense jungle
#

people who still use 20.8b1 should just upgrade 🙂

plain atlas
#

"black 21.8b0 doesn't work on xxx since there's no wheel"

dense jungle
#

it's 20.8 that has the problem, not 21.8

plain atlas
#

Ohhh, missed that lol

plain atlas
#

I've read that in the future, yank it and publish a new one, ex 20.8b2

bright glacier
plain atlas
#

Interesting

neon loom
#

Why do we need draft releases?

plain atlas
# neon loom Why do we need draft releases?

to be fair, if writing the release notes, but not fully ready to send it (ex need the build files to attach or something) it manes sense to save draft, as per below, but github treats ones that were saved and then published differently, apparently.

plain atlas
#

@bright glacier well, it worked

[[package]]
name = "black"
version = "21.8b0"
description = "The uncompromising code formatter."
category = "dev"
optional = false
python-versions = ">=3.6.2"

[package.dependencies]
click = ">=7.1.2"
mypy-extensions = ">=0.4.3"
pathspec = ">=0.9.0,<1"
platformdirs = ">=2"
regex = ">=2020.1.8"
tomli = ">=0.2.6,<2.0.0"
typing-extensions = [
    {version = ">=3.10.0.0", markers = "python_version < \"3.10\""},
    {version = "!=3.10.0.1", markers = "python_version >= \"3.10\""},
]
bright glacier
#

I could've done it directly but I wanted to do one more check over

plain atlas
#

ironically using a draft release messed it up 😛

bright glacier
#

eh at that point, doing a build + upload wasn't scary since I've done that with blackbench

plain atlas
#

ah, that's good

#

welp my projects are all on 21.8b0 now

#

hm

reef moth
#

Hi i need to know what is the deafult user name and password for kali linux

plain atlas
#

uh

#

What did you guys do lol

lament crow
#

search includes checking the long_description

#

and long_description contains README along with the changelog

plain atlas
#

aha nice

lament crow
#

this does look a bit weird tbf though

#

the change log being mentioned twice that is

plain atlas
#

lmao

#

towncrier

#

!pypi towncrier

late dewBOT
plain atlas
#

weird....

#

I have a location where black is not turning back on after # fmt: on

#

what the heck

#

this is wild

#

hmh

#

I think I found a bug

#

tldr # fmt: X within decorator blocks is.... i guess not supported.

stuck vapor
#

woohoo thanks for the release @bright glacier 🥳 🥳 🥳 (and all the other maintainers and contributors, of course!)

rigid abyss
flat krakenBOT
#

Description
error: cannot format /home/ddodt/rockestate_branch/api/utils.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_bp4imlkr.log

To Reproduce
I am assuming that the log will help:

Mode(target_versions=set(), line_length=88, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
...
plain atlas
#

heh nice edit

#

whups

plain atlas
#

caught another bug 😛

#

nice job with the release finding bugs-- is often my worst nightmare

bright glacier
#

Dammit, I don't have permissions to push to dockerhub IIRC.

plain atlas
#

😔

bright glacier
#

... because I don't have an account

plain atlas
#

lol

#

you might be able to manually trigger that workflow

#

eh, nope

#

primer and uvloop and then checks are done 🥳

#

why do the workflows not ignore the workflows file being edited?

#

....nvm

#

that would be really dumb to ignore them ty

#

because that would mean there would be no way to test the ones that run on pull requests

#

the only way would be to exclude files that they are not

bright glacier
#

@neon loom is it possible you could push an image for the 21.8b0 release to dockerhub manually? I'm very sorry, but it turns out the docker workflow had the same pitfall as the PyPI one. I don't have a dockerhub account ATM. Dammit my nervousness is being a jerk again sigh

#

Or we could just not push one, but I feel like we're bound to get an issue about it eventually ...

plain atlas
#

well the good news is that the workflows will be fixed 😛 and shouldn't happen again

bright glacier
#

It works by inserting standalone comments into the AST (which works since we don't touch these types of comments) but since we do newline and spacing normalization, it's really hard to get right.

plain atlas
flat krakenBOT
bright glacier
#

I don't really see how this is useful but ok.

plain atlas
#

er, sorry

flat krakenBOT
bright glacier
#

Oh well, I screwed up the commit message

plain atlas
#

¯_(ツ)_/¯

#

Draft releases don't trigger the workflows (that's good!) but since they only __

#

yay now you've done it 😛

#

My first commit had a typo so

bright glacier
#

I'm not in the mood to be graceful about this

plain atlas
#

ah

#

sorry

bright glacier
#

I'm not excited, simply doing what I planned right now. Just a dull start to the day. Maybe I'll brighten up, but that's not now.

neon loom
bright glacier
#

Thank you.

late dewBOT
bright glacier
#

Right, *inhales* hopefully this is less stressful -- it has been only moments since I've finished an hour walk, no need to get my blood pressure risen again 😄

#

ReadTheDocs is still picking up the wrong commit, but that's okay.

#

@neon loom big thanks for the release documentation, made this way less stressful and complicated!

plain atlas
#

that was fast, too

bright glacier
plain atlas
#

yeah, happened for pydis too

#

haven't had any problems with codecov 😛

plain atlas
#

huh til

flat krakenBOT
#

Describe the bug

When running the latest black binary on linux, the following error is thrown:

Traceback (most recent call last):
  File "black/__main__.py", line 1, in 
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "black/__init__.py", line 38, in 
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "black/nodes.py", line 28, in 
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
...
flat krakenBOT
#

Describe the bug

To Reproduce

Expected behavior

Environment (please complete the following information):

  • Version:
  • OS and Python version:

Does this bug also happen on main?

<!-- To answer this, you have two options:

  1. Use the online formatter at , which will use
    the latest main branch.
  2. Or run Black on your machine:
    • create a new virtualenv (make sure it's the same Python version);
    • clone this repository;
    • run...
#

Description

Add new platformdirs dependency as a hidden import when creating
PyInstaller based binaries.

This issue seems to have been introduce when switching to platformdirs
in #2375.

fixes #2464

Checklist - did you ...

  • [ ] Add a CHANGELOG entry if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
flat krakenBOT
fast basin
# neon loom If only I had docs that told you each step … I’ll try find time to manually push...

I was trying to find needed steps. General flow should be:

  • clone git repo and switch to 21.8b0
  • build docker image setting proper tags
  • login docker to Docker hub using your tokens
  • push docker images to Docker hub

I did it for for linux/amd64 but I'm stuck at building image for linux/arm64. Maybe on Raspberry Pi it would be possible...

But I have other idea - maybe separate GitHub action can be created to build both images?

plain atlas
#

have I found a bug?

#
@pytest.mark.parametrize(
    "content, footer_text",
    [(["5"], "Snap, crackle, pop"),
    (["Earthly"], "world")],
    ("There are no {self.type}s installed.", None),
)
#

black formats it to be ```py
@pytest.mark.parametrize(
"content, footer_text",
[(["5"], "Snap, crackle, pop"), (["Earthly"], "world")],
("There are no {self.type}s installed.", None),
)

#

magic trailing comma is on, too

#

wait I see what I missed

#

no its not a bug ty

neon loom
plain atlas
#

this is accurate, since in the code above, the second line is an array

#

which actually would throw a runtime error 😛

#

because parametrize only expects two positional args, and in the above its getting three

neon loom
#

Ok - I think I got it right:

crl-m1:black cooper$ docker buildx build --platform linux/arm64 --platform linux/amd64 --tag pyfound/black:latest --pull --push  .
...
crl-m1:black cooper$ docker buildx build --platform linux/arm64 --platform linux/amd64 --tag pyfound/black:21.8b0 --pull --push  .
...
#

Also added: docker buildx build --platform linux/arm64 --platform linux/amd64 --tag pyfound/black:latest_release --push .

#

All built from:

commit a8b4665e7d6eb945c47820adb1a3f8b006adce0c (HEAD, tag: 21.8b0)
Author: Richard Si <63936253+ichard26@users.noreply.github.com>
Date:   Sun Aug 29 17:04:49 2021 -0400

    Exclude broken typing-extensions version + fix import (#2460)

    re. import, the ipynb code was assuming that typing-extensions would
    always be available, but that's not the case! There's an environment
    marker on the requirement meaning it won't get installed on 3.10 or
    higher. The test suite didn't catch this issue since aiohttp pulls in
    typing-extensions unconditionally.
#

Hola if I screwed anything up

#

goes back to day job

bright glacier
#

I'm out for almost the whole day so I won't be hola-ing anytime soon 😄

#

Thanks Cooper!

nocturne hill
#

pooof, shame

flat krakenBOT
#

Description

Follow-up for #2461.

Triggering conditions changed in one more place of docker.yml.
This is triggering condition for creating pyfound/black:latest_release Docker image.

@onerandomusername and @ichard26 to take a look.

Checklist - did you ...

  • [x] Add a CHANGELOG entry if necessary? -> N/A
  • [x] Add / update tests if necessary? -> N/A
  • [x] Add new / update outdated documentation? -> N/A
heavy heron
#

Don't know if it helps much, but it is the right change according to myself :D

flat krakenBOT
bright glacier
#

So I broke 99% of the CD pipeline by using a draft release, and as a cherry on top, the appdirs -> platformdirs switch broke the only CD workflow that actually fired 😐

bright glacier
#

I can't tell whether it's the fact it's currently 10:30 PM or because it's actually genuine, but I do feel like I could be on my way to burning out with FOSS. Doesn't excite me in the same way it used to... I suppose I'll ponder over it for a bit and see how it changes tomorrow when I'm not tired. Didn't really think of this until I saw some other PyDis folks step down recently.

#

oh and before I cause worry (due to the PyDis reference), I won't be stepping down as a maintainer of psf/black, just that I *may* step back for a little while as I focus on other things ^^

plain atlas
#

this is why you have a PCSS to work on 🙃
Paid closed source software /s

bright glacier
#

I don't work as a paid software developer. I won't be discussing my career as I'm not comfortable, but I'll tell you that.

dull scroll
#

P star?

plain atlas
#

Sorry, it was a joke, see the /s

plain atlas
bright glacier
#

I can't help but feel like I have this responsibility to "finish" all of the projects I've started / am leading related to psf/black. I know it doesn't make sense especially since when it comes to personal projects it's a different story, but that's the shading of my sunglasses!

#

But yea. I've been meaning to get back to work on a bunch of stuff inc. documentation and developer experience and... I just haven't yet and I don't quite know why other than "I've been feeling meh."

plain atlas
#

man... I took a two month break (minimum) from contributing to stuff, including my own projects. Didn't respond to people, didn't touch anything, just let it all sit. Came back 1 month later and none of it was changed, but I felt refreshed and have been working on them since then.
Often, taking a break is a good thing, and if black does rely on any of your personal projects, then you could give jel or someone push access so they could fix bugs while you take a break

bright glacier
#

Often, taking a break is a good thing, and if black does rely on any of your personal projects, then you could give jel or someone push access so they could fix bugs while you take a break
I plan to give some keys out to my personal projects once they have an userbase beyond just me~ but that's always good advice

plain atlas
#

ye

#

right now one of my projects is literally only used by [no one] because it isn't usable yet

bright glacier
#

that's basically the state of diff-shades

#

blackbench needs some polishing and better docs but it's in better condition

plain atlas
#

that's good

#

docs are fun

elder tusk
#

one of the freeing (but sometimes difficult to internalise) things about FOSS is there are no hard obligations. every now and then i temporarily turn off notifications for repos i maintain and that helps make it feel less like i'm doing a $job.

errant barn
#

Yup! See psf/black#517 for more info

toxic stormBOT
flat krakenBOT
plain atlas
#

how nice

#

switching to app_dirs found a missing dependency on one of my flake8 plugins somehow

bright glacier
#

love it when you find an issue before after it breaks your deployment lemon_angrysad

plain atlas
#
[[package]]
name = "flake8"
version = "3.9.2"
description = "the modular source code checker: pep8 pyflakes and co"
category = "dev"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"

[package.dependencies]
mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.7.0,<2.8.0"
pyflakes = ">=2.3.0,<2.4.0"
#
  File "/home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/flake8/plugins/manager.py", line 164, in load_plugin
    raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "S" due to No module named 'pkg_resources'.
#

wait

#

that isn't the same package

#

I'm blind soso

#

ah, flake8-bandit

plain atlas
#

wait--

#

lovely

#

it broke from cpython version 3.8.11 to 3.8.12

dense jungle
#

^ good call

bright glacier
#

closing issues won't ever stop being satisfying ^^

plain atlas
#

Recreated my venv, everything happy now

molten hare
#

I'm glad richard is getting those dopamine hits

bright glacier
#
--- test.py    2021-09-01 18:57:14.794550 +0000
+++ test.py    2021-09-01 19:14:31.473478 +0000
@@ -3,11 +3,10 @@
 if os.name == "posix":
     import termios
 
     def foo():
         pass
-
 
 elif os.name == "nt":
     try:
         import msvcrt
 
@@ -17,13 +16,11 @@
     except ImportError:
 
         def foo():
             pass
 
-
 else:
 
     def foo():
         pass
 
-
 other_code()

I have an super duper quickly thrown together fix for this issue: psf/black#647 but I don't think it's quite good enough, I don't like how the last line is also getting its spacing cut short, ideally the fix would only apply in a block but it's unclear to me would I'd detect that ...

toxic stormBOT
bright glacier
#

I guess I could check against a list of block clauses or some other logic like that but that sounds brittle :p

plain atlas
#

Hmmm

#

Is black suggested to format stub files?

bright glacier
#

black can format stub files, yes

dense jungle
#

yes

plain atlas
#

Since typing stub files typically have different formatting

bright glacier
#

yeah, but this isn't really about that anyway

#

this is more about conditionally defined functions and how the whitespace black applies isn't ideal

plain atlas
#

Ah, yeah

#

I'm on mobile rn and have a headache, should come back later

#

Cya 👋

bright glacier
#

lol, this might actually work:

@@ -446,13 +448,20 @@ class EmptyLineTracker:
         else:
             before = 0
         depth = current_line.depth
+        # print(self.previous_defs)
         while self.previous_defs and self.previous_defs[-1] >= depth:
-            self.previous_defs.pop()
             if self.is_pyi:
                 before = 0 if depth else 1
             else:
-                before = 1 if depth else 2
+                if depth:
+                    before = 1
+                elif not depth and self.previous_defs[-1] and current_line.leaves[-1].type == token.COLON:
+                    before = 1
+                else:
+                    before = 2
+            self.previous_defs.pop()
bright glacier
#

hmm, this still doesn't quite cut it, putting a with statement at the end of a conditional function definition leads to it only getting one preceding newline :'(

#

other than hard-coding a list of names, I don't know a better way to fix this

#

it's not pretty, but it technically works :p

         while self.previous_defs and self.previous_defs[-1] >= depth:
-            self.previous_defs.pop()
             if self.is_pyi:
                 before = 0 if depth else 1
             else:
-                before = 1 if depth else 2
+                if depth:
+                    before = 1
+                elif (
+                    not depth
+                    and self.previous_defs[-1]
+                    and current_line.leaves[-1].type == token.COLON
+                    and current_line.leaves[0].value
+                    not in ("with", "try", "match", "for", "while", "if")
+                ):
+                    # We shouldn't add two newlines between an indented function and
+                    # and a non-indented clause. This is to avoid issues with
+                    # conditional function definitions that are technically top-level
+                    # and therefore get two trailing newlines, but look weird and
+                    # inconsistent when they're followed by elif, else, etc.
+                    before = 1
+                else:
+                    before = 2
+            self.previous_defs.pop()
bright glacier
#

I wonder if it'd be worth it to replace the 21.8b0 native binaries since they're functionally useless right now. Other than the effort, my major concern would be that technically it wouldn't be the same source code as 21.8b0, but given that we don't sign the binaries or anything that seems moot.

#

Yea, chances are we are going to switch to a completely new CST-like AST parser and therefore also change out the most important data structures used in black's logic.

#

I mean, technically it's all internal other than Python 3.10 syntax support so it doesn't really matter imo

dense jungle
#

We could just release 21.8b1?

#

Oh wait it's 21.9 time already

bright glacier
#

lol

#

The two possibilities I see to avoid the rewrite would be 1) write some wrappers or adapters so we can still treat the new types as like the lib2to3 types (sounds very sketchy), or 2) augment lib2to3 to support a PEG grammar (but that's effectively making us both a formatter AND parser project)

#

One would also probably hurt performance (especially with mypyc where removing layers and indirection is its bread and butter).

#

We aim for a monthly release schedule at the bare minimum but other than that it's up to Cooper and Jelle :)

dense jungle
#

and you! all I do is occasionally make noises that we should probably make a release

bright glacier
#

I'm the one who helps with making the releases, but I don't really involve myself into the discussion of when to release. Although I do now remember I do lead what issues we should get into a release... so maybe I do 😄

flat krakenBOT
#

Describe the bug

oldvalue[index + 10:] will be replaced with oldvalue[index + 10 :]

  • Pycharm will throw PEP 8: E203 whitespace before ':'

To Reproduce
create a list like this, then black .

oldvalue[index + 10:]

It will be replaced with this

oldvalue[index + 10 :]

Expected behavior
Keep it without any change.

oldvalue[index + 10:]

Environment (please complete the following information):

  • Version: 21.8...
dense jungle
#

ooo a classic

bright glacier
#

25 according to the I've been keeping 👀

neon loom
#

I vote release

#

The month is only we should release each month if there are any changes was my thought -
If we need more releases we need more

ionic nymph
#

Is it expected behaviour for black to leave some code lines (not containing comments/docstrings) as they are, despite being too long? I distilled this example from work (can't share the actual code, but black's behaviour is the same):

class SomeClass:
    def some_method(self) -> None:
        for element in some_iterable:
            some_model.objects.create(
                # The next line is 89 columns wide
                name_legacy=some_migration_data.WITH_A_REALY_LONG_NAME_AFTER.name_legacy,
            )

The line starting with name_legacy= is 89 columns/chars wide.

errant barn
#

It's not even put onto a new line after the equals, and that would make your example exactly fit.

dense jungle
#

I think this doesn't trigger the fluent style because it's only one function call

#

It just doesn't split it up because the line is too long

#

I mean the attribute name is too long

bright glacier
neon loom
#

It's less human work than manual docker uploads + binary uploads ...

bright glacier
#

Maybe I'm jaded from the nightmare that was our dependencies during the 21.8b0 release, but I feel differently :<

neon loom
#

Meh - that's releasing. Fix, ya move on. The previous 2 or 3 went flawlessly

#

This is why we release a lot, so the changes are easily identifiable ...

dense jungle
#

let's do it

stuck vapor
#

If you want to do a new release, then maybe the TypeGuard can be placed inside a TYPE_CHECKING block, so that typing-extensions is only required to be 3.7 for users who don't want the jupyter formatting?

dense jungle
#

I don't see a need, we fixed the faulty typing_extensions release

stuck vapor
#

just cause a couple of users opened issues that, due to other packages' deps, they'd ended up with typing-extensions 3.7 and so black would fail with cannot import TypeGuard from typing_extensions (though arguably it's up to whatever other package they had to remove their strict pin)

flat krakenBOT
bright glacier
#

probably one of the more hacky PRs I've made ^^

plain atlas
#

Huh.

#

OK yeah, it installs the local version

lament crow
#

is it intentional that Black only puts one line between class definition inside if statements?

if True:

    class ClassName1:
        ...

    class ClassName2:
        ...
#

It usually uses two lines, i.e.:

class ClassName1:
    ...


class ClassName2:
    ...
glacial drum
#

pep8 only says to have two blank lines on top level functions and classes

#

so i guess those aren't considered top level, since they're indented.

crisp nymph
#

!voiceverify

flat krakenBOT
stuck vapor
# flat kraken

🤔 not sure what could be the cause of this one, as I can't reproduce on Mac / Linux. Could anyone with Windows try it out?

tribal thistle
#

I was trying to, but uhh, are dependencies still broken?

[pipenv.exceptions.InstallError]: Looking in indexes: https://pypi.python.org/simple
[pipenv.exceptions.InstallError]: ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
[pipenv.exceptions.InstallError]: ERROR: No matching distribution found for dataclasses==0.8

errant barn
#

0.8 is published though lemon_thinking

tribal thistle
#

I'm on 3.9

errant barn
#

Ah I see, but you shouldn't need that on 3.9 right?

tribal thistle
#

Theoretically no

errant barn
#

I can try it in a bit as well

tribal thistle
#

Looks like it's possibly a problem with the pipfile, this seems to have fixed it:

- dataclasses = {"python_version <" = "3.7","version >" = "0.1.3"}
+ dataclasses = {"python_version" = "<3.7","version >" = "0.1.3"}

I'm yet to successfully lock it, because it's been going on for 10 minutes lol

#

The docs don't actually mention anything about python_version, they only specify markers

#

never mind, locking failed

pure sable
#

hey

#

how do i set the indents

#

because when i use black <path> it changes the indents to 4

little parrot
#

You can't

pure sable
tribal thistle
#

Alright, this one seems to have worked, which makes sense since it's the documented way:

- dataclasses = {"python_version <" = "3.7","version >" = "0.1.3"}
+ dataclasses = {markers="python_version < '3.7'","version >" = "0.1.3"}```
flat krakenBOT
#

Describe the bug

Running pipenv install, or any variation in python versions 3.7+, results in the following failure:

[pipenv.exceptions.InstallError]: Looking in indexes: https://pypi.python.org/simple
[pipenv.exceptions.InstallError]: ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
[pipenv.exceptions.InstallError]: ERROR: No matching distribution found for dataclasses==0.8

To Reproduce

  1. Cl...
errant barn
#

Could not reproduce either

stuck vapor
#

Thanks for your help - it's OK though, I'm virtually certain I see what the issue is (they're running an old version of black which doesn't have jupyter support, and the trailing commas result in invalid json)

bright glacier
#

cool, I guess we can include that in the hotfix

lament crow
#

wew

#

I guess all previous releases will fail due to that added extra in setuptools_scm now then

#

does anyone know if there's a way to force an older setuptools_scm version?

#

since this is install-only dep

#

guess nevermind then

#

this will get resolved soon™

dense jungle
#

wow it's really been dependency hell the last week

flat krakenBOT
bright glacier
#

but wait, does all of the releases allowed by the pin we added in 21.8b0 work fine without the extra?

#

I mean the wheel exists so most people shouldn't hit any issues, but still I'm scared our requirements are still broken

lament crow
#

cool, my build with black 20.8b1 works again

#

I need to update but that got delayed because we have pending PR for isort, pre-commit and other stuff, and wanted to do it all at once lol

bright glacier
#

I was talking with some folks in the PyPA discord server in particular with the setuptools-scm maintainer and it sounds like we should drop the pin + keep the toml extra. cc @rancid abyss

lament crow
#

out of curiosity, why drop the pin?

bright glacier
#

Not sure TBH, that's why I CCed Ronny ^^

rancid abyss
#

Regressions are resolved and the toml extra was for pyproject.toml support,

There are some no regression compat fixes ill push soon to deal with the rest of the details once I have a matching ci setup that won't hide specific types of regression

plain atlas
#

!pypi setuptools-scm

late dewBOT
plain atlas
#

huh, setuptools already uses tomli

flat krakenBOT
#

Describe the bug

The vim plugin does not read or does not respect the options set in pyproject.toml.

To Reproduce

  1. Create a file test.py:

    def test(arg):
        print(arg)
    
    
    test(4,)
    

    There are 2 ways that black can format this. With the --skip-magic-trailing-comma option set to false, it formats like this (the broken-line way):

    def test(arg):
        print(arg)
    
    
    test(
        4,
    )...
mint barn
#

autopep8 is not better?

lament crow
#

You're asking in Black's channel so the opinions here will obviously be biased towards Black

lament crow
dense jungle
#

Honestly I haven't used autopep8 much. Does it even format everything? I thought it just applied a couple of rules

plain atlas
late dewBOT
#

pyproject.toml line 35

black = "^21.8b0"```
plain atlas
#

futhermore given by black not following semver, but calver instead

lament crow
#

sure?

plain atlas
#

which means that pin is pretty useless lol

#

calvar is calender based versioning

lament crow
#

personally I hard-pin formatters and linters

plain atlas
#

21.8 == 2021 august -- 8th month of the year

lament crow
#

because it gives you reproducible builds

plain atlas
#

no, not necessarily, but when it is released, it will be more related to the date

lament crow
#

and it's just annoying to have to deal with random errors in unrelated PRs when something changes

plain atlas
# mint barn autopep8 is not better?

cc @dense jungle
autopep8 is usable in some cases, specifically the parts that go against what black's philosophy-- "Black reformats entire files in place."

I use autopep8 for formatting files on save, since autopep8 will format only the modified portions of the file, if using version control, since that allows me to contribute to projects that don't use black but still have somewhat formatted code. However, autopep8 only makes whitespace changes, and black does a little more than that.

#

yeah I meant to send this a while ago and got fully distracted lol

plain atlas
#

Update: I have thrown out most of the above. My editor is now configured to format with black and lint with flake8 on save.

plain atlas
#

owo I found something black does not format!

#

f-string debugs

#

f"{var = }"

bright glacier
#

IIRC we don't touch f-string expressions at all since it's prone to bugs and no one has tried to implement it yet

plain atlas
#

The positioning of the = is not touched at all --ah makes sense

bright glacier
#

the thing is that we don't actually know that there's expressions in the f-string with the parsing library we use

#
file_input
  simple_stmt
    NAME 's'
    EQUAL ' ' '='
    atom
      LPAR ' ' ''
      STRING 'f"this is a f-string with an expression {1 + 1}"'
      RPAR ''
    /atom
    NEWLINE '\n'
  /simple_stmt
  ENDMARKER ''
/file_input

so it's a bit fickle to manipulate

#

that's for s = f"this is a f-string with an expression {1 + 1}" fyi

plain atlas
#

ah... that could be screwy, i see

#

yeesh

#

although given that the parsing library breaks with match, in the near future, black will likely switch to a parsing library that knows how fstring work I presume?

bright glacier
#

I don't know honestly

#

it'd be nice to have better support for f-strings in the library we switch to but it's not that high on the list of priorities

bright glacier
#

ugh, I should really do this hotfix release

#

!remind 15H do a hotfix release since stuff is still on 🔥

late dewBOT
#
Of course!

Your reminder will arrive on <t:1630781200:F>!

plain atlas
#

what is on fire?

#

fwiw I haven't noticed any issues with 21.8b0 and any of my projects 😄

bright glacier
#

the os native binaries

plain atlas
#

ah

#

i'm on windows heh

bright glacier
#

we provide binaries for Intel MacOS, Linux, and Windows

reef wren
#

who?

bright glacier
#

sorry I don't understand, could you elaborate?

late dewBOT
bright glacier
#

re. the setuptools-scm fiasco, I've bumped the deps to avoid the toml extra as Ronny has said themself (in the open PR) but I wouldn't mind keeping the toml extra as a safety precaution. I'm mostly pleased that the pin doesn't have to exist

quick kraken
#

is there a way to get black to ignore certain pep8 guidelines

#

specifically the one that limits your lines to 79

errant barn
#

That can be changed, but generally speaking Black isn't very configurable

#

(you'd use black source -l 80 or something similar)

quick kraken
#

uhhh

#

is there any documentation on this

errant barn
quick kraken
#

tyty

quick kraken
#

what should i be looking at to see more abt this

#

honestly just have no idea what to click

errant barn
#

No worries, and the help message is a bit buried. It's under "help output"

#

Just under command line options

quick kraken
#

i wouldve never

#

founmd that

errant barn
#

Honestly I feel you 😅

quick kraken
#

is there a way to

#

make black format comments?

#

my comments go wayyyy beyond 88

errant barn
#

you might want to read the style docs once to get an understanding

#

but to answer that specific question, no, not yet at least

quick kraken
#

hmm i see

#

at least it's not hidden this time

bright glacier
#

or... actually add that click sphinx extension I've been planning to

errant barn
flat krakenBOT
flat krakenBOT
#

Describe the bug

INTERNAL ERROR

To Reproduce

A python file to trigger the bug:

# tmp.py
def foo():
    arr = (
       # fmt: on
       (3833567325051000, 5, 1, 2, 4229.25, 6, 0),
       # fmt: off
    )

Here is the command-line output:

$ black tmp.py
error: cannot format tmp.py: INTERNAL ERROR: Black produced invalid code on pass 1: unmatched ')' (, line 8). Please report a bug on https://github.com/psf/black/issues.  This invalid output m...
next minnow
#

Hi

next minnow
#

||hi||

#

||hi||

plain atlas
#

!code

late dewBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

flat krakenBOT
#

Describe the bug

When performing an in-place reformat, if the disk is full and black cannot write to disk, instead of leaving the file untouched it wipes the entire file, or corrupts it.

To Reproduce

  1. Fill up the disk
  2. Attempt to reformat a target python file
  3. Observe:
python3 -m black target.py
error: cannot format target.py: [Errno 28] No space left on device
Oh no! \U0001f4a5 \U0001f494 \U0001f4a5
1 file failed to reformat.
  1. The file is now corrupt...
mint barn
#

k

#

k

lament crow
#

Oh my

bright glacier
#

oh dear 👀

flat krakenBOT
#

Describe the bug

While fuzzing black using a self-written python grammar I encountered the following internal error. Since black encouraged me to report this bug, I gladly do so.

To Reproduce

python src/black/__main__.py -c "del [(),], [T],()"
del [(),], [T],()
error: cannot format : INTERNAL ERROR: Black produced code that is not equivalent to the source on pass 1.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_64p...
plain atlas
#

!e del [(),], [T],()

late dewBOT
#

@plain atlas :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'T' is not defined
dense jungle
#

huh II didn't know del [a, b] is valid syntax

flat krakenBOT
mint barn
#

black does not make changes when I use assert or := in the code, while using the type less than py38

bright glacier
#

technically 20.8b1 is still very vulnerable to build time issues (since none of the recent fixes obviously made it in) but we could fix it with a new wheel

#

but anyway, that's not my goal for today, I'm trying to sort things out for a hotfix release

bright glacier
#

well it turns out pipenv is killing my hopes at making such a release

plain atlas
#

hmmm

#

you aren't the first to say that about pipenv

#

therefore, I believe that pipenv should have a new tagline

bright glacier
#
diff --git a/Pipfile b/Pipfile
index 824beda..fc0176d 100644
--- a/Pipfile
+++ b/Pipfile
@@ -51,4 +51,4 @@ tomli = ">=0.2.6, <2.0.0"
 typed-ast = "==1.4.2"
 typing_extensions = {"python_version <" = "3.10","version >=" = "3.10.0.0"}
 black = {editable = true,extras = ["d"],path = "."}
-dataclasses = {"python_version <" = "3.7","version >" = "0.1.3"}
+dataclasses = {markers="python_version < '3.7'","version >" = "0.1.3"}
diff --git a/Pipfile.lock b/Pipfile.lock
index 30a4def..6eb8bbb 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "ebf216584cfb2c962a1792d0682f3c08b44c7ae27305a03a54eacd6f42df27db"
+            "sha256": "94a31a06a22678a47a6fa4596fc9fc76098631141adc2cb47baefb8bcd796606"
         },
         "pipfile-spec": 6,
         "requires": {},
@@ -769,7 +769,7 @@
                 "sha256:2480d8e07d1890056cb53c96e3de44fead9c62f2ba949b0f2e4c4345f4afa977",
                 "sha256:a65882a4d0fe5fbf702273456ba2ce74fe44892c25e42e057aca526b702a6d4b"
             ],
-            "markers": "python_version < '3.7' and python_version < '3.7'",
+            "markers": "python_version < '3.7'",
             "version": "==5.2.2"
         },
         "iniconfig": {

you would've thought the dataclasses issue would be fixed but nope!

plain atlas
bright glacier
#

for some reason it's still not skipping the dataclasses backport on 3.7+

plain atlas
#

3.7__.0__ maybe?

bright glacier
#

I honestly don't know

plain atlas
#

aha!

#

!pep 508

late dewBOT
#
**PEP 508 - Dependency specification for Python Software Packages**
Status

Active

Created

11-Nov-2015

Type

Informational

neon loom
#

I wonder if we bother to keep battling away with pipenv ... I personally don't use it.

plain atlas
#

I think it breaks a few things if its not locked, IDK for sure

#

poetry seems better to use imo

neon loom
#

Poor pipenv just lost maintainers and has been always playing catchup - it was a good idea etc.

#

It just didn't make enough easier or better for me to want to go through so many workflow changes ...

plain atlas
#

tldr; pipenv kinda dead

#

also pipenv slow

#

very slow

neon loom
#

But when black came out, it was looking to be the promise of the future we all wanted. Then Kennith stopped working on it and left it dead for a long time. People are trying to keep it going cause a lot of people started using it but I agree it's gone now. And yes, far to slow to generate lock files etc.

plain atlas
neon loom
#

setup.cfg is another move that looked promising but never became the norm - I've tried to use that for some projects but it also doesn't offer huge wins of setup.py apart from limiting the hacks people can do (which I like)

#

e.g. You can put ANY CODE in a setup.py ...

plain atlas
#

lol

neon loom
#

I often explain it as init shell scripts vs. systemd

plain atlas
neon loom
#

Wasn’t planning to. Shell scripts are full shell of choice scripts with no limits like setup.py and systemd uses ini like limited config files for Linux daemon services …

#

Makes people do more “normal” or intentionally limited things when running daemons/services on Linux.

plain atlas
#

ah

#

bad black

#
def find_local_plugins(
    detection_path: pathlib.Path = BASE_PLUGIN_PATH, /
) -> Dict[Plugin, List[pathlib.Path]]:
#

just noqaed it

tribal thistle
#

What's up

plain atlas
#

i think the answer to the problem is in pep 508

plain atlas
tribal thistle
#

Right, I'm trying to get a repro

#

Also I don't see how that PEP relates, from the description it's a different problem

plain atlas
#

that pep is the dependency specification--the format for how the python_requires thing is supposed to be formatting which I think is the problem

tribal thistle
#

I'm referring to the github issue you linked, but also, it does work locally and on docker for me, which is why I'm trying to get a repro

plain atlas
#

interesting

#

what python version are you using?

tribal thistle
#

3.9

#

Docker too

plain atlas
#

and its not installing dataclasses?

tribal thistle
#

It is not

bright glacier
#

ugh, I'm actually awake because I'm so damn restless right now, can't fall asleep :/

plain atlas
#

interesting..

#

oh hi

tribal thistle
bright glacier
#

yea it's like 3 am over here

#

I hate this

tribal thistle
#

Oh uh, yeah this isn't exactly high priority right now dude

#

Your health is way more important

plain atlas
#

huh, we're in the same timezone then 👀

bright glacier
#

est

plain atlas
#

yep

tribal thistle
#

Both of you, go to bed now

#

That's an official demand

plain atlas
#

the difference is I stay up to 4am typically out of self-hate 😄

plain atlas
bright glacier
#

I've been trying but restlessness has been saying no to that

tribal thistle
#

Because I was asleep :D

plain atlas
#

so I've been up trying to figure it out

bright glacier
#

Anyway, I guess it's time to lay and suffer and hope I get some before the sun rises; you should go to bed arl

tribal thistle
#

Night night guys

errant barn
#

What if I sing you a lullaby? :P

plain atlas
#

anyways I'm tried I'll probably look at this in the morning

#

gotta write a lotta stuff in the morning, yay.

flat krakenBOT
#

Describe the bug

Black adds extra parentheses around enum entries.

To Reproduce

Run black on the following file:

class enum(Enum):
    A = 0,

Expected behavior

I'd have expected no reformatting to take place. Instead I got:

class enum(Enum):
    A = (0,)

I don't know if those extra parentheses are intended behaviour. If so, what was the rationale behind those?
Is there an option to control this behaviour.

**Environment (please comp...

short forge
#

Does black support long string wrapping

errant barn
#

Yup! Pass in --experimental-string-processing

short forge
#

Im using a pyproject file, is there a switch for that too?

errant barn
#

I think everything can be specified in there lemon_thinking I think.

flat krakenBOT
#

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

https://github.com/dnanhkhoa/nb_black allows for formatting notebooks interactively. However:

  • last commit it from > 1 year ago, so it might be unmaintained
  • it uses regular expressions, rather than the more robust black.format_cell

Describe the solution you'd like

That black itself expose these nb_black and lab_black magics

Describe alternatives you've considered

Contributing this to...

short forge
errant barn
#

Yeah I tried that but it didn't seem to work lemon_thinking honestly I'm not sure

short forge
#

Also are there any plans for this to not be "experimental" anymore? Boss is gonna be mad if this breaks anything hehe

errant barn
#

Yep, in psf/black#2188

toxic stormBOT
short forge
#

Oo very nice, looking forward to it

errant barn
#

Yeah that's a good suggestion!

short forge
#

Mayhap i can open an issue in the repo, do you guys have a documentation label?

#

Sorry for silly questions im out for lunch and on phone

short forge
#

Excellent

errant barn
#

Also is that "maybe" and "perhaps"? :D

short forge
#

Heh kinda, im not sure myself, not british
Just like the sound and feel of it

errant barn
#

love it :D

little parrot
#

What does experimental string processing do to type aliases?

dense jungle
little parrot
#
black -c "TypeType: TypeAlias = \"Type | Literal['Invalid', 'Individual', 'Multiseat', 'GameServer', 'AnonGameServer', 'Pending', 'ContentServer', 'Clan', 'Chat', 'ConsoleUser', 'AnonUser', 'Max', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\"" --line-length=120 --experimental-string-processing 
TypeType: TypeAlias = (
    "Type | Literal['Invalid', 'Individual', 'Multiseat', 'GameServer', 'AnonGameServer', 'Pending', 'ContentServer',"
    " 'Clan', 'Chat', 'ConsoleUser', 'AnonUser', 'Max', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]"
)
```i have some monster type alias, and this formatted version breaks on pyright
dense jungle
#

I could also be persuaded to make Black somehow not format type aliases, but that seems more fragile. The result of the formatting is still a valid string so I feel like pyright should accept it

little parrot
#

yeah i dont really know why eric (i assume) decided to not allow that

#

ill open an issue

dense jungle
little parrot
#

yeah i dont think its a common use case

stuck vapor
#

fun fact: black is only ~200,000 downloads away from 100 million, meaning it'll cross the 100M threshold...tomorrow!

mint barn
#

@dense jungle black should edit assert or := when using type py27 or causing incompatibility?

dense jungle
mint barn
#

but can black propose another solution to avoid incompatibility?

dense jungle
#

Another solution for what?

flat krakenBOT
#

Description

Currently a Python source file with only whitespace (space, tab, linefeed) as well as zero-length files are not reformatted but kept intact. In #2382 the consensus was that all of these should become a file with a single empty line, i.e. just a linefeed character.

Also, currently black.format_str turns all-whitespace strings into zero-length strings, which is inconsistent compared to the command line and the black.format_file_contents() function. Wtih this patch, bot...

bright glacier
#

I've been completely MIA for pretty much a whole day, seems like there was some activity. Looks good!

plain atlas
#

I may or may not have slept last night-- lets not talk about that 👀

bright glacier
#

my sleep was terrible, hopefully today's is better

plain atlas
#

awh

#

I'm adding a bunch of error handling for bugs I implemented at 3am last night 👏

mint barn
#

when did you eat breakfast

#

can anyone change this sentence to passive?

mint barn
#

hey guys

errant barn
#

Yo! This is a channel of a specific library on a programming server 😅 But welcome, I'll give it a go: "When was the breakfast eaten?" A second langwitch disclaimer tho.

flat krakenBOT
tired shard
quick kraken
#

with -l i can change the line length to like

#

whatever integer

#

is there a way i can just

#

get rid of the cap

#

or would that be achieved by typing 999999

errant barn
#

I'd firmly advise against that, because that defeats the purpose of Black. Why do you want it off?

quick kraken
#

just the line length

#

oh it's u again

#

hello again

errant barn
#

Hi!

quick kraken
#

LOL

#

anyways

#

it doesnt rlly matter

#

i can probably set it to like 200

#

but i was just wondering

#

i dont want my notes to get fomatted

#

is all

#

it doesnt matter to me and i actually prefer that my linesa re as long as they need to be

errant barn
#

Kay, yeah for sure you can go arbitrarily large

quick kraken
#

alright

errant barn
#

But then the transformations of Black are really limited 😅

quick kraken
#

as in

#

setting it to arbitrarily large

errant barn
#

At least in my opinion most of the value is in line breaks

quick kraken
#

will stop black from working?

#

oh yea

#

that makes sense

errant barn
#

yeah 999999999999999999999999999 should do it

quick kraken
#

i just want it off for now

#

you said this last time

#

what does source do?

#

i'm seeing just black -l 999999 by the documentation

#

so a lil confused

#

^^

errant barn
#

That's just the source file, like black main.py -l oh-no

quick kraken
#

oh hmm

#

so if i dont put the

#

source file

#

can i just

#

global it?

#

so that every time black is called

#

it always does that?

#

not sure if im making any sense

errant barn
#

meaning you would not select the sources but run it for everything, say, in a folder?

quick kraken
#

so i have a sublime text extension that calls black on whatever file i have open with a keybind

#

i would like it so that when i use the extn black just ignores the line limit by default

errant barn
#

yeah, I imagine you could set parameters in the extension, or configure Black with a pyproject.toml file

quick kraken
#

hmm i see

#

i'll take a look at that

#

so that's not black's problem

errant barn
#

👍🏿

quick kraken
#

but rather the extenion's

#

alright i'll

#

take a look

#

tyvm

errant barn
#

well.. we do accept static configuration in the pyproject, but if the extension is well made it should have at least something :D

#

or maybe you could even hack it by finding out where the call is made and editing parameters there

quick kraken
#

i see it

#

!!

errant barn
#

but that'd be hacky

quick kraken
#

it is all good now

errant barn
#

nice

quick kraken
#

i didnt think abt looking at the settings

#

thinking it was a problem i could fix in the terminal

#

or smt

errant barn
#

yah

late dewBOT
#

Hey @floral ivy!

It looks like you tried to attach file type(s) that we do not allow (.html). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.

Feel free to ask in #community-meta if you think this is a mistake.

floral ivy
#

well

flat krakenBOT
mint barn
#

I like the black formatter, but today it bugged. I used black -l 79 as I always did and looking at the file it seems to fit the length of line 1

#

now I have to edit line by line

dense jungle
mint barn
#

yes

flat krakenBOT
#

Describe the bug

error: cannot format /Users/vamshi.venkataswamy/ENV/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.

To Reproduce

Expected behavior

Environment (please complete the following information):

  • Version:
  • OS and Python version:

Does this bug also happen on main?

<!-- To answer this, you have two options:

  1. Use the online f...
mint barn
#

How can I do that:

(1, 2, 3,
 4, 5, 6)

Go back to being:

(1, 2, 3, 4, 5, 6)
dense jungle
mint barn
#

done

#

is it possible to make it go back to one line and not use multiple lines?

#

@dense jungle

sour jay
#

Well, depends on the line length you have setup

mint barn
#

I put greater than 150 and there are no changes

#

It is normal?

dense jungle
#

look up the magic trailing comma feature in the docs. maybe run with --skip-magic-trailing-comma

mint barn
#

that solved my problem

#

@dense jungle Thanks!

flat krakenBOT
#

I've been finding the need to use --experimental-string-processing for a couple of projects recently. Typing it out in the console every time is cumbersome and other people in my team might struggle to understand what the flag does, where its location in a command is, etc.

It'd be nice to be able to specify this flag in the pyproject.toml file used in the project.
The issue is that the [example pyproject.toml file](https://black.readthedocs.io/en/stable/usage_and_configuration/the_b...

red sedge
#

Any chance for a black classic option that's also compatible with black magic? Currently I have to run black -C; black to get the right output

dense jungle
red sedge
#

Hold on I'll try and find some

#

But black -C sometimes produces code that black would change

dense jungle
red sedge
#

yep

#
-            assert TaskManager.add_tasks(
-                TaskWithArguments_name,
-                osirium.tasklib.TT_USER,
-                osirium.tasklib.TP_DEFAULT,
-                [
-                    {"test_argument1": "mango", "test_argument2": "banana"},
-                    {"test_argument1": "strawberry", "test_argument2": "apple"},
-                    {"test_argument1": "pinapple", "test_argument2": "tomato"},
-                ],
-            ) == [1, 2, 3]
+            assert (
+                TaskManager.add_tasks(
+                    TaskWithArguments_name,
+                    osirium.tasklib.TT_USER,
+                    osirium.tasklib.TP_DEFAULT,
+                    [
+                        {"test_argument1": "mango", "test_argument2": "banana"},
+                        {"test_argument1": "strawberry", "test_argument2": "apple"},
+                        {"test_argument1": "pinapple", "test_argument2": "tomato"},
+                    ],
+                )
+                == [1, 2, 3]
+            )
#

so red is the result of black -C and green is the result of black

dense jungle
#

interesting, that sounds like a bug to me. we should format this the same regardless of the -C option

#

could you report an issue?

red sedge
#

sure

#

maybe black -C should run the second-pass check with black when it runs?

dense jungle
#

yes, that could catch bugs like this

flat krakenBOT
#

Describe the bug

To Reproduce

<!-- Steps to reproduce the behavior:

def foo():
    assert TaskGroup.add_tasks(
        TaskWithArguments_name,
        redactium.tasklib.TT_USER,
        redactium.tasklib.TP_DEFAULT,
        [
            {"test_argument1": "mango", "test_argument2": "banana"},
            {"test_argument1": "strawberry", "test_argument2": "apple"},
            {"test_argument1": "pinapple", "test_argument2": "tomato"},
        ],
  ...
red sedge
#

does that work?

dense jungle
#

yes, thanks!

red sedge
#

I prefer the formatting that black -C chooses in this case

dense jungle
#

same

tall tiger
#

yes

flat krakenBOT
#

Description

patch("io.TextIOWrapper") wouldn't actually cause io.TextIOWrapper() to return the StringIO object created by the test. This didn't cause any problems though until I added a test in #2484 in which content= is non-empty.

Checklist - did you ...

  • [ ] Add a CHANGELOG entry if necessary?
  • [x] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
sour jay
#

What?

red sedge
sour jay
#

The issue haha

#

I don't get how it correlates to Black the linter and formstter

heavy heron
#

it relates to Black's test units

flat krakenBOT
copper hinge
#

guys how to train on exercice do you have some exercice for medium begginers

bright glacier
plain atlas
#

lmao

#

i got a notification from python

bright glacier
#

I don't remember pithink

plain atlas
#

I thought someone was using python internal eval

bright glacier
#

!kindling ?

late dewBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

mint barn
#

How can I use black formatter in pycharm?

mint barn
#

thank you very much richard

formal quest
#

I feel like this needs a new name tbh. "try the black playground" sounds like something you'd hear in the 50s

outer ferry
dense jungle
#

Also we don't directly control the playground, it's someone outside the core team

#

So renaming it will need cooperation from them

formal quest
dense jungle
formal quest
#

But. It means Black.

bright glacier
#

also technically vanta does exist on PyPI so yea..

formal quest
#

Vantablack then 😏

#

Fuck it's taken

#

Take it from them 😏

silent apex
#

Using a term like "Black Playground" or "Black Sandbox" is perfectly clear.

formal quest
#

🧐

onyx raptor
bright glacier
#

The legal fees would probably already bankrupt the project and that's assuming we don't have to pursue people in the courts which is even more expensive :p

formal quest
formal quest
plain atlas
#

The Darkest Payground 👀

onyx raptor
#

did he get away tho

flat krakenBOT
#

I want to request some features regarding quotation style.

  • [ ] Single quote for:

1. Multiline comment string

Examples in the current Black style

"""_Using if Statements with Lists_"""

Desired style

'''_Using if Statements with Lists_'''

2. String inside list, tuple, dict, and any collection data type:

Examples in the current Black style

available_toppings = [
    "mushrooms",
    "olives",
    "green pepper...
red sedge
#

uhh is that one a troll post?

#

the main use of black is to stop people indenting those brackets

austere lava
#

I'm not sure I'd spend this much energy convincing OP

stuck vapor
flat krakenBOT
#

Running Black on the following code makes no changes:

(
    "whatever" == "a very long string broken across two lines.  "
    "If you put this on one line it would be too long."
)

unless you add --experimental-string-processing, in which case a newline is added before ==

(
    "whatever"
    == "a very long string broken across two lines.  "
    "If you put this on one line it would be too long."
)

I don't have a strong view on which is...

flat krakenBOT
dense jungle
mint barn
#

Add support for cython grammar

dense jungle
little parrot
halcyon latch
#

Just wanted to say thanks to y'all for that AMA! It was wonderful to read through and it gave me some more stuff to think about.

plain atlas
#

lol nice

The "b" doesn't mean beta, it just stands for Black.

ionic rain
#

What is "black formatter"? 😅

rose pivot
#

¯_(ツ)_/¯

mint barn
ionic rain
tired shard
#

How did you come across that after an year lol

bright glacier
#

I had a notification on psf/black#1352

bright glacier
#

Hmm seems the test suite is still sensitive to the current working directory, running pytest in /tests/ breaks quite a few tests :/

#

Pretty sure you got the wrong channel ^^

analog zodiac
#

ah yes sorry 'bout that

bright glacier
#

no worries, it happens

plain atlas
#

what does black use to release to pypi again?

#

!pypi twine

late dewBOT
#

Collection of utilities for publishing packages on PyPI

plain atlas
#

thanks!

bright glacier
#

I honestly kinda wish flit would use twine instead of implementing its own HTTP post logic

#

speaking of flit, I wonder if they made a release with the bugfix whose bug report I submitted a month-ish ago~

plain atlas
#

lol

#

wait huh

#

i'm confused

#

what does the black workflow look like?

bright glacier
#

takluyver/flit#432

bright glacier
outer ferry
#

It was so much fun having everyone! So many great answers to just as many interesting questions! We're going to keep it pinned up top on the subreddit for a chunk of this week as well to make it easy to find for anyone late to the party

stuck vapor
#

From the AMA:

Black recently gained native support for formatting .ipynb files! Not sure if that fully replaces tools like nb_black though.

This is what the issue https://github.com/psf/black/issues/2483 is about. Any thoughts on it?

As mentioned in the issue, nb_black has some limitations (e.g. doesn't preserve "quiet mode" semicolons) and seems unmaintained

bright glacier
#

I don't have much experience in the Jupyter Notebook world and don't understand the terminology... so does the issue boil down to exposing an API / entry-point in the black root namespace?

late dewBOT
#

nb_black.py lines 4 to 11

from lab_black import BlackFormatter, black_formatter, unload_ipython_extension


def load_ipython_extension(ip):
    global black_formatter
    if black_formatter is None:
        black_formatter = BlackFormatter(ip, is_lab=False)
        ip.events.register("post_run_cell", black_formatter.format_cell)```
stuck vapor
#

yes, exactly! that should be all that's necessary

And instead of black_formatter.format_cell, black.format_cell could be used

stuck vapor
flat krakenBOT
bright glacier
#

hmm I wanna bet that this won't work for pre-commit because it does a shallow clone

#

That's unfortunate for --required-version

#

the problem FYI with shallow clones is that there isn't enough history so setuptools-scm can figure out that's it's a tagged version

tribal thistle
#

Could an environment variable or something override scm?

stuck vapor
#

I guess a workaround, if they need to use required-version, would be to specify black as a local pre-commit hook, so that it gets installed via PyPI and will have the right version?

e.g. something like

- repo: local
  - hooks:
    - id: black
      name: black
      language: python
      entry: black
      additional_dependencies: [black==21.8b0]
      types_or: [python, pyi]
plain atlas
#

i don't think that additional_dependencies is valid for local hooks

#

wow

#

just was looking into it

#

since I have to contribute to a program that uses tabs instead of spaces

#

and trying to get a formatter for it

#

black won't work, because of its core

#

but an interesting thing to note: yapf breaks pep 518

#

that is all.

plain atlas
#

oh black has spoiled me

bright glacier
#

Can anyone else do a release? I was planning to do one but I'm just too busy to do so

#

The packaging woes are still hitting people unfortunately

plain atlas
#

the thing that people complain about is probably my favorite part

#

black is not configurable

#

after just trying to configure yapf because this project uses tabs 🤮 I wish it I could use black

dense jungle
#

I haven't done a release before but we have instructions, right?

#

I can do it (unless @neon loom is around and has time)

bright glacier
dense jungle
#

lesson: don't do release candidates 😄

neon loom
#

Go hard or go home.

#

Happy to do later but we do have instructions. Just don’t go adding steps …

dense jungle
#

here we go

bright glacier
#

hopefully it goes more smoothly for you :😄

bright glacier
#

wow, not even going to let me review, confidence much? /j

#

It was going to be green though so no biggie in all seriousness.

flat krakenBOT
bright glacier
#

One thing I'll note is that RTD still has broken behavior picking up the wrong commit when the stable tag is updated but thankfully fixing that is literally only a few button clicks

dense jungle
#

we should update the stable tag tomorrow probably?

#

what are the clicks we'll have to do? is that in the readthedocs admin interface?

bright glacier
#

well okay the clicks aren't a fix but it does resolve the problem ome-time

dense jungle
bright glacier
#

Hopefully you have access, Lemme check real quick

#

Yup you do!

bright glacier
#

hopefully not :)

#

!remind 18H check release status + finalize release process

late dewBOT
#
Sure thing!

Your reminder will arrive on <t:1631651389:F>!

bright glacier
#

Thanks @dense jungle! To be honest I'm jealous of 1) your luck, and 2) your speed :>

flat krakenBOT
zealous frost
#

Thanks for the new release everybody!

dense jungle
#

mostly thank @neon loom for making the release process so easy 🙂

neon loom
#

@bright glacier always so negative 😅

#

When you can’t code, you have to have other skills.

flat krakenBOT
neon loom
#

@dense jungle I haz commit but for flake8-bugbear

#

Can push a fix in 30 mins or so