#black-formatter
1 messages · Page 20 of 1
how can you yank nothing tho?
but I want to cook my marshmallows :'(
hm also we have two owners on the black project that don't have 2FA enabled
I'm going to yank them
lmao
I should setup 2FA on my PyPI account
yanks ichard from pypi
I have it for GH already since it's required for the PyPA org
oh my god now your name makes sense
__r__ichard
i can't believe I just realised that
</tangent>
also @bright glacier once you have 2FA on I can add you to the Black project on PyPI
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 ...
lmao
I have 2fa on if you want to add me /s
😛
first you need to get as many closed issues as richard
lmao
lemme quickly run my script
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
I've closed ~225 issues so far.
👁️
Jelle is still beating me tho :(
jeez
You remember those closing parties we held in the evenings 😅
me? no
we closed A LOT of issues in a short timeframe
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
setup.py line 82
"typing_extensions>=3.10.0.0; python_version < '3.10'",```
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
this is proven here: https://github.com/psf/black/runs/3453833910?check_suite_focus=true#step:6:54
Is it worth excluding 3.10.0.1?
I think so
lol, on further inspection, 3.11 might be broken
on that version typing-extensions definitely shouldn't be pulled-in
src/black/handle_ipynb_magics.py line 12
from typing_extensions import TypeGuard```
would crash on 3.11 :p
3.11 python or 3.11 typing extensions
CPython
ah
hmmmm, I wish we could have threads for this channel, just thought of something else
!pypi atoml
our previous discussion about toml libs, here's a 4th one.
the tldr is its an updated version of tomlkit
hopefully we don't have to move from tomli
lol
tomli is good but the difference with tomlkit (and by extension. atoml) is that it preserves style and comments
i thought tomlkit was already up to date
!pypi tomlkit
preserving style doesn't matter for black because we only need to read toml files
last updates: may
no ik, it was just that I and ichard had a previous dicussion about all the libs
I'm just more worried about lack of maintenance.
tomli is extremely maintained, imo
it doesnt matter if youre black cause youre only parsing right?
the track record for this area hasn't been good
unless the TOML folks release a new spec of TOML
this is one of the most confusing examples I've read in a PEP: https://www.python.org/dev/peps/pep-0440/#version-exclusion
i'm pretty sure that they were talking about revising 1.0 since implementations don't actually implement it correctly
it's probably just me not being able to read properly, but I'm just going to assume how it works
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 :/
look at it this way: you're more inclined to start looking at poetry
how does that help when I don't even understand how requirements work looking at this red GHA log
why is the version requirement >=3.6.5 https://github.com/psf/black/runs/3456231516?check_suite_focus=true#step:6:41
when it's specified as https://github.com/psf/black/blob/16275d24e3c2ad88d953d67e7d8795fd7f73f7cb/setup.py#L82
setup.py line 82
"typing_extensions>=3.10.0.0; python_version < '3.10'",```
because the under 3.10 means that it doesn't use that on 3.10
but why is the test suite passing on 3.10-dev if we shouldn't be pulling it in!
something else probably uses it
I'm just going to ignore the failing pre-commit hooks for now :p
setup.py line 58
"typing_extensions>=3.7.4",```
no, but given that https://github.com/psf/black/runs/3456231516?check_suite_focus=true#step:6:11 is installing [d] i looked in those deps first
where is pip getting typing-extensions>=3.6.5 from?
the aiohttp one you just showed is too high
Ah, that's from main.
setup.py line 74
"typing_extensions>=3.6.5",```
Here's the requirement from aiohttp===3.7.4.post0
Thanks
🙂
So wait, how am I supposed to fix this?
I think if you add: "typing_extensions!=3.10.0.1; python_version ~= '3.10'",
But we do need at least >=3.10.0.0
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
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
The release should probably be yanked anyway, but looks like Jelle can't do anything about it sadly
yeah...
!d sys.version_info
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.
I think I'm going to use the old python environment marker since I doubt 3.11+ works too
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
thanks but I changed it manually already
Time to wait for CI again, I'mma go and get a glass of water
lol
nvm, lint already failed
oh that's a dumb mistake
src/black/handle_ipynb_magics.py:10:4: F821 undefined name 'sys'
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?
OK, now I'mma go get a glass of water.
heheheheh
fine, i'm very annoyed
😔
LGTM, lets hope that the Fuzz passes this time! 😄
watch as we get a ton of new issues after I push the release
ofc
sorry 😔
you're not
wdym
^
14 minutes
oh jeez
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
oh my god all 35 checks run again?
yup cause it's technically a different commit
damn
even if you do a git commit --amend --no-edit, it still gets a different SHA
how
although the different parent is already enough to cause the checks to run
but amend keeps the old time
or
hmmmm
are there two times on every commit
when they were dated and when they actually made?
❯ 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
I was gonna suggest sticking to the previous typing-extensions version and not using TypeGuard, but it looks like it's all green now 🥳
it would've broke if you used the d extra anyway so it was worth excluding
[d] -> aiohttp -> typing-extensions (unconditionally!)
i find it slightly funny that 3.10 broke on 3.10
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 ^^
me 5 seconds later: pre-commit autoupdate
uhm why is the PyPI workflow not firing? https://github.com/psf/black/actions/workflows/pypi_upload.yml
.github/workflows/upload_binary.yml lines 3 to 5
on:
release:
types: [published]```
it's probably because I first did a draft release and then published that instead of directly creating the release
I guess I'll push the distribution artifacts manually then. Good timing on Jelle giving me the keys.
.github/workflows/pypi_upload.yml lines 3 to 5
on:
release:
types: created```
Note: The
prereleasedtype will not trigger for pre-releases published from draft releases, but thepublishedtype will trigger. If you want a workflow to run when stable and pre-releases publish, subscribe topublishedinstead ofreleasedandprereleased.
i have no idea what the fix is here
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
note: published will fire on pre-releases as well
ah
❯ 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
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?
-...
ugh, the checklist markdown is broken
cya!
!remind 1D update stable tag and check readthedocs
Your reminder will arrive on <t:1630360476:F>!
thanks for making the release @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?
What why did a wheel not get pushed
We deleted it due to build mistake.
Also that's uh... Gonna be the first bug report I bet
people who still use 20.8b1 should just upgrade 🙂
"black 21.8b0 doesn't work on xxx since there's no wheel"
it's 20.8 that has the problem, not 21.8
Ohhh, missed that lol
If you can delete it I doubt that you can make another one since that would be effectively replacing
I've read that in the future, yank it and publish a new one, ex 20.8b2
I'm basing my thoughts off of this tweet: https://twitter.com/brettsky/status/1423360362754232320
If you have a package on PyPI that doesn't have a wheel that will install on Python 3.10 for your latest release, please consider producing one now so your dependencies can test against Python 3.10 appropriately (you can always push another wheel w/ a higher build number later) https://t.co/hBE2MAKaHk
See "build tag" under this: https://www.python.org/dev/peps/pep-0427/#file-name-convention
Interesting
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.
@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\""},
]
I was just scared 😅
I could've done it directly but I wanted to do one more check over
ironically using a draft release messed it up 😛
eh at that point, doing a build + upload wasn't scary since I've done that with blackbench
Hi i need to know what is the deafult user name and password for kali linux
uh
What did you guys do lol
search includes checking the long_description
and long_description contains README along with the changelog
aha nice
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.
woohoo thanks for the release @bright glacier 🥳 🥳 🥳 (and all the other maintainers and contributors, of course!)
root is the username and toor is the password
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
...
Part of me wants to consolidate the OS native binaries and PyPI build+ upload workflows into one file, but this fixes a possible pitfall with the release system. This is already a win. Thanks @onerandomusername! You're awesome!
caught another bug 😛
nice job with the release finding bugs-- is often my worst nightmare
Dammit, I don't have permissions to push to dockerhub IIRC.
😔
... because I don't have an account
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
@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 ...
well the good news is that the workflows will be fixed 😛 and shouldn't happen again
I don't even know at this point, the fmt: off/on/skip logic is a pain to work with and improve.
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.
yeah it was extremely weird behavior. If i put a second # fmt: on it was seemingly inverting all of the comments above, so off was on!
Describe the bug
Dockerhub does not have the most recent version, 21.8b0.
To Reproduce
View https://hub.docker.com/r/pyfound/black/tags?page=1&ordering=last_updated, notice it is not there.
Expected behavior
21.8b0 is on dockerhub
Environment (please complete the following information):
N/A
- Version:
- OS and Python version:
Does this bug also happen on main?
N/A
I don't really see how this is useful but ok.
er, sorry
well, I can't recreate this
Oh well, I screwed up the commit message
¯_(ツ)_/¯
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
I'm not in the mood to be graceful about this
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.
If only I had docs that told you each step … I’ll try find time to manually push tonight …
Thank you.
Here's your reminder: update stable tag and check readthedocs
[Jump back to when you created the reminder](#black-formatter message)
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.
Success, other than dockerhub still being outdated, everything is done on my side 🎉 https://black.readthedocs.io/en/stable/change_log.html is correct phew
@neon loom big thanks for the release documentation, made this way less stressful and complicated!
that was fast, too
Coveralls is 504ing a lot today: https://github.com/psf/black/actions/runs/1184054686
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
...
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:
- Use the online formatter at , which will use
the latest main branch. - 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?
Describe the bug
I'm using black, version 20.8b1 and I have an error on a specifi file.
black -l 120 myfile.py
`--- src
+++ dst
@@ -9854,11 +9854,11 @@
value=
Constant(
kind=
None, # NoneType
value=
-
'\n\n\n\n\n\n\n\nBits \tDescription\n0-3 \tSquawk Mode - indicates the meaning of the required ‘squawk’:\n0 - System is armed\n1 - System is disarmed\nAll othe...
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?
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
Docker can cross compile. I’ll do it soon.
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
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
I'm out for almost the whole day so I won't be hola-ing anytime soon 😄
Thanks Cooper!
pooof, shame
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
For what is worth, this is the right trigger to use
Don't know if it helps much, but it is the right change according to myself :D
77d11bb Change docker workflow for latest_release tag (... - pszlazak
Just asking a question to see if we should maybe inform (via an issue) platformdirs about this? This is a change of behavior from appdirs.
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 😐
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 ^^
this is why you have a PCSS to work on 🙃
Paid closed source software /s
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.
P star?
Sorry, it was a joke, see the /s
You do maintain a lot of stuff for black, which would probably burn out most people in your position much faster. Whatever you do choose, no matter the duration, its all fine and I don't think anyone will be worried. 😄
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."
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
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
ye
right now one of my projects is literally only used by [no one] because it isn't usable yet
that's basically the state of diff-shades
blackbench needs some polishing and better docs but it's in better condition
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.
Yup! See psf/black#517 for more info
Describe the bug
When attempting to format the attached (problematic) file, black outputs INTERNAL ERROR: Black produced code that is not equivalent to the source
To Reproduce
- Take the attached file
- Run Black on it with these arguments
run black -l 120 --target-version py38 src(wheresrcis the parent directory of the file) - See error
how nice
switching to app_dirs found a missing dependency on one of my flake8 plugins somehow
love it when you find an issue before after it breaks your deployment 
[[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
I would have probably found this sooner if workflows were running for this 👀
wait--
lovely
it broke from cpython version 3.8.11 to 3.8.12
^ good call
closing issues won't ever stop being satisfying ^^
Recreated my venv, everything happy now
I'm glad richard is getting those dopamine hits
--- 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 ...
I guess I could check against a list of block clauses or some other logic like that but that sounds brittle :p
black can format stub files, yes
yes
Since typing stub files typically have different formatting
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
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()
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()
Tested the generated binary on Windows and it works totally fine. Beautiful, thank you!
72de89f Add hidden import to PyInstaller build (GH-2466) - jalaziz
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
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 :)
and you! all I do is occasionally make noises that we should probably make a release
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 😄
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...
ooo a classic
We're probably on duplicate #20 or whatever
25 according to the I've been keeping 👀
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
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.
Hmm, we do have behavior for "fluent interfaces": https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#call-chains This seems like it should fall under the same umbrella
which it is not, I can confirm
It's not even put onto a new line after the equals, and that would make your example exactly fit.
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
Another follow-up from https://github.com/psf/black/pull/2357 , adding a test for uncovered code
Alright, I can do a hotfix release if Jelle is also in favour.
It's less human work than manual docker uploads + binary uploads ...
Maybe I'm jaded from the nightmare that was our dependencies during the 21.8b0 release, but I feel differently :<
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 ...
let's do it
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?
I don't see a need, we fixed the faulty typing_extensions release
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)
Description
One curveball is that we still want two preceding newlines before blocks
that are probably logically disconnected. In other words:
if condition:
def foo():
return "hi"
# <- aside: this is the goal of this commit
else:
def foo():
return "cya"
# <- the two newlines spacing here should stay
# since this probably isn't related...
probably one of the more hacky PRs I've made ^^
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:
...
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.
!voiceverify
Hi I install black to use it to format my notebooks using the following command: pip install black[jupyter].
When I run the command black notebook.ipynb it formats the notebook correctly. However when I open my notebook I get the following error message:

Can anyone help thank you
🤔 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?
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
0.8 is published though 
I'm on 3.9
Ah I see, but you shouldn't need that on 3.9 right?
Theoretically no
I can try it in a bit as well
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
hey
how do i set the indents
because when i use black <path> it changes the indents to 4
You can't

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"}```
No reproduction on windows
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
- Cl...
Could not reproduce either
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)
cool, I guess we can include that in the hotfix
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™
wow it's really been dependency hell the last week
Sigh, this past week has been terrible for our dependencies, hopefully this is the last mini-fire out of the bunch. Thank you for noticing and fixing! I'll try to push out a hotfix release later today containing both this fix and the other one for the OS native binaries.
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
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
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
out of curiosity, why drop the pin?
Not sure TBH, that's why I CCed Ronny ^^
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
!pypi setuptools-scm
huh, setuptools already uses tomli
Describe the bug
The vim plugin does not read or does not respect the options set in pyproject.toml.
To Reproduce
-
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-commaoption set tofalse, it formats like this (the broken-line way):def test(arg): print(arg) test( 4, )...
autopep8 is not better?
You're asking in Black's channel so the opinions here will obviously be biased towards Black
No, it's not.
Glad we have it sorted out :D
Honestly I haven't used autopep8 much. Does it even format everything? I thought it just applied a couple of rules
Meh, As a user of both, I can probably give an opinion on it.
pyproject.toml line 35
black = "^21.8b0"```
futhermore given by black not following semver, but calver instead
sure?
personally I hard-pin formatters and linters
21.8 == 2021 august -- 8th month of the year
because it gives you reproducible builds
no, not necessarily, but when it is released, it will be more related to the date
and it's just annoying to have to deal with random errors in unrelated PRs when something changes
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
Update: I have thrown out most of the above. My editor is now configured to format with black and lint with flake8 on save.
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
The positioning of the = is not touched at all --ah makes sense
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
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?
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
ugh, I should really do this hotfix release
!remind 15H do a hotfix release since stuff is still on 🔥
Your reminder will arrive on <t:1630781200:F>!
what is on fire?
fwiw I haven't noticed any issues with 21.8b0 and any of my projects 😄
the os native binaries
we provide binaries for Intel MacOS, Linux, and Windows
who?
sorry I don't understand, could you elaborate?
Here's your reminder: do a hotfix release since stuff is still on 🔥
[Jump back to when you created the reminder](#black-formatter message)
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
is there a way to get black to ignore certain pep8 guidelines
specifically the one that limits your lines to 79
That can be changed, but generally speaking Black isn't very configurable
(you'd use black source -l 80 or something similar)
There is.. the documentation :D https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html
tyty
im not very good at looking through documentation to be honest
what should i be looking at to see more abt this
honestly just have no idea what to click
No worries, and the help message is a bit buried. It's under "help output"
Just under command line options
Honestly I feel you 😅
you might want to read the style docs once to get an understanding
but to answer that specific question, no, not yet at least
Sounds like I should really unhide that since people keep missing it
or... actually add that click sphinx extension I've been planning to
Yep that could improve it quite a bit. The help message is more or less equivalent, but I imagine the rendered docs look better 😄
This package seems to be unmaintained (last commit is from > 2 years ago), and black now runs on Jupyter Notebooks directly
Description
Checklist - did you ...
- [x] Add new / update outdated documentation?
Seems legit to me to no longer recommend this …
8b0c7bc Remove blackcellmagic reference (#2477) - MarcoGorelli
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...
Playground for Black, the uncompromising Python code formatter.
Hi
how do you guys put your code in this box
||hi||
||hi||
!code
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.
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
- Fill up the disk
- Attempt to reformat a target python file
- 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.
- The file is now corrupt...
Oh my
oh dear 👀
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...
!e del [(),], [T],()
@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
huh II didn't know del [a, b] is valid syntax
Description
I believe this was forgotten in #2430
Checklist - did you ...
- [ ] Add a CHANGELOG entry if necessary?
- [ ] Add / update tests if necessary?
- [x] Add new / update outdated documentation?
black does not make changes when I use assert or := in the code, while using the type less than py38
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
well it turns out pipenv is killing my hopes at making such a release
hmmm
you aren't the first to say that about pipenv
therefore, I believe that pipenv should have a new tagline
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!
pipenv: killing..... your.... hopes...... and..... dreams...... one..... slow..... action..... at...... a...... time.......
for some reason it's still not skipping the dataclasses backport on 3.7+
3.7__.0__ maybe?
I honestly don't know
https://github.com/pypa/pipenv/issues/3786 @bright glacier might be a useful thing to view
aha!
!pep 508
I wonder if we bother to keep battling away with pipenv ... I personally don't use it.
I think it breaks a few things if its not locked, IDK for sure
poetry seems better to use imo
https://discord.gg/bnJpt28N for the curious
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 ...
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.
i cracked a joke about it here lol
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 ...
I often explain it as init shell scripts vs. systemd
are you going to explain it?
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.
ah
bad black
def find_local_plugins(
detection_path: pathlib.Path = BASE_PLUGIN_PATH, /
) -> Dict[Plugin, List[pathlib.Path]]:
just noqaed it
Hey, I've got some time to play around with it
What's up
i think the answer to the problem is in pep 508
for some reason it's still not skipping the dataclasses backport on 3.7+
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
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
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
and its not installing dataclasses?
It is not
ugh, I'm actually awake because I'm so damn restless right now, can't fall asleep :/
Oh uh, yeah this isn't exactly high priority right now dude
Your health is way more important
huh, we're in the same timezone then 👀
est
yep
the difference is I stay up to 4am typically out of self-hate 😄
smh I asked you for help with testing and you didn't give me any
I've been trying but restlessness has been saying no to that
Because I was asleep :D
so I've been up trying to figure it out
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
Night night guys
never
I WILL NEVER SLEEP
What if I sing you a lullaby? :P
anyways I'm tried I'll probably look at this in the morning
gotta write a lotta stuff in the morning, yay.
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...
Does black support long string wrapping
Yup! Pass in --experimental-string-processing
Im using a pyproject file, is there a switch for that too?
I think everything can be specified in there
I think.
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...
Same format? So
experimental-string-processing = true
Yeah I tried that but it didn't seem to work
honestly I'm not sure
Also are there any plans for this to not be "experimental" anymore? Boss is gonna be mad if this breaks anything hehe
Yep, in psf/black#2188
Oo very nice, looking forward to it
One more minor thing, it'd be nice if we had an exhaustive black section in
https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-format
But this isnt that important tbqh
Yeah that's a good suggestion!
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
Yup, we do and go ahead!
Excellent
Also is that "maybe" and "perhaps"? :D
Heh kinda, im not sure myself, not british
Just like the sound and feel of it
love it :D
What does experimental string processing do to type aliases?
Nothing, hopefully.
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
Oh wow, that's indeed a monster. Maybe you should report this as a bug to pyright?
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
yeah i dont really know why eric (i assume) decided to not allow that
ill open an issue
Probably just an oversight. Thanks!
yeah i dont think its a common use case
fun fact: black is only ~200,000 downloads away from 100 million, meaning it'll cross the 100M threshold...tomorrow!
@dense jungle black should edit assert or := when using type py27 or causing incompatibility?
I don't know what you mean. := obviously shouldn't work in 2.7 mode, it won't parse. assert is the same in all supported Python versions as far as I know
but can black propose another solution to avoid incompatibility?
Another solution for what?
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...
I've been completely MIA for pretty much a whole day, seems like there was some activity. Looks good!
I may or may not have slept last night-- lets not talk about that 👀
my sleep was terrible, hopefully today's is better
hey guys
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.
Black https://github.com/python/black/commit/06ccb8
Options
--line-length=88
--safe
Input
def _print(*args, **kwargs):
print...
was probably a homework/exam question
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
I'd firmly advise against that, because that defeats the purpose of Black. Why do you want it off?
Hi!
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
Kay, yeah for sure you can go arbitrarily large
alright
But then the transformations of Black are really limited 😅
At least in my opinion most of the value is in line breaks
yeah 999999999999999999999999999 should do it
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
^^
That's just the source file, like black main.py -l oh-no
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
meaning you would not select the sources but run it for everything, say, in a folder?
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
yeah, I imagine you could set parameters in the extension, or configure Black with a pyproject.toml file
👍🏿
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
but that'd be hacky
it is all good now
nice
i didnt think abt looking at the settings
thinking it was a problem i could fix in the terminal
or smt
yah
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.
well
I love making this a common black practice.
I only have a question about if we come across windows empty text files - Should we maintain them or just say "black "\n's" all empty .py files etc. - I'm fine with the latter - Just want to see if others are ...
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
sorry to hear that! please report a bug with a way to reproduce the issue
yes
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:
- Use the online f...
How can I do that:
(1, 2, 3,
4, 5, 6)
Go back to being:
(1, 2, 3, 4, 5, 6)
Put a comma after the 3 so you don't have a syntax error
done
is it possible to make it go back to one line and not use multiple lines?
@dense jungle
Well, depends on the line length you have setup
look up the magic trailing comma feature in the docs. maybe run with --skip-magic-trailing-comma
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...
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
can you clarify why you want this? what are some examples?
Hold on I'll try and find some
I want to avoid redundant explosions like in https://github.com/psf/black/issues/1288#issuecomment-593872733
but also I want to produce the same canonical output as any other black run would do
But black -C sometimes produces code that black would change
can you give an example?
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
interesting, that sounds like a bug to me. we should format this the same regardless of the -C option
could you report an issue?
yes, that could catch bugs like this
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"},
],
...
does that work?
yes, thanks!
I prefer the formatting that black -C chooses in this case
same
yes
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?
What?
?
it relates to Black's test units
Can you clarify why the previous way didn't work? It looks to me like it should.
guys how to train on exercice do you have some exercice for medium begginers
!kinding -- also fyi this is a little off-topic here ^^
I don't remember 
I thought someone was using python internal eval
!kindling ?
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.
How can I use black formatter in pycharm?
thank you very much richard
I feel like this needs a new name tbh. "try the black playground" sounds like something you'd hear in the 50s
As this channel might be interested, (for some.. unknown reason..)
We're hosting an AMA with this dev team over on reddit: https://www.reddit.com/r/Python/comments/plvtlx/were_the_core_team_behind_the_popular_python/
If you've got some questions you've been itching to ask, now's a great time to ask them! We'd love for you to join us!
That name does sound a bit unfortunate. Does anyone here have suggestions for a better name that covers what it's about?
Also we don't directly control the playground, it's someone outside the core team
So renaming it will need cooperation from them
Vanta, means black, makes sense as it's a super dark black, considered the "blackest black"
I don't think that covers what the tool is for (a website where you can see how Black formats some code)
But. It means Black.
also technically vanta does exist on PyPI so yea..
Yes, but it should be obvious what the purpose is.
Using a term like "Black Playground" or "Black Sandbox" is perfectly clear.
🧐
50 cease and desist letters later
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
Just say no 😏
Snowden got away with leaking NSA secrets, I'm sure you can get away with some copyright infringement smh
The Darkest Payground 👀
did he get away tho
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...
uhh is that one a troll post?
the main use of black is to stop people indenting those brackets
I'm not sure I'd spend this much energy convincing OP
How about "Black formatter playground"?
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...
The documentation doesn't say anything about our PyInstaller binaries (or if it does I can't find it). Let's fix that.
re https://www.reddit.com/r/Python/comments/plvtlx/were_the_core_team_behind_the_popular_python/hcfvaor/?context=3, maybe we should just do a release now? It's September after all
Add support for cython grammar
PRs are welcome!
why not use the new types for cython stuff which is supported in base python? ie x: cython.int = 10
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.
lol nice
The "b" doesn't mean beta, it just stands for Black.
What is "black formatter"? 😅
¯_(ツ)_/¯
One more over-evolved code formatter than us
😶
How did you come across that after an year lol
I had a notification on psf/black#1352
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 ^^
ah yes sorry 'bout that
no worries, it happens
thanks!
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~
takluyver/flit#432
if anyone wants to burn some time learning more about Black and the FOSS project behind it, feel free to head over to this AMA we did on r/Python: https://www.reddit.com/r/Python/comments/plvtlx/were_the_core_team_behind_the_popular_python. The discussion was quite fun! Even I, a core contributor for over a year now, learned new things!
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
From the AMA:
Black recently gained native support for formatting
.ipynbfiles! Not sure if that fully replaces tools likenb_blackthough.
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
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?
Oh, something like this I suppose? https://github.com/dnanhkhoa/nb_black/blob/50c0f1bbfee53a7dfd76b00a6b0a5ac82a729386/nb_black.py#L4-L11
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)```
yes, exactly! that should be all that's necessary
And instead of black_formatter.format_cell, black.format_cell could be used
Actually, a bit more than that is needed: this class needs to be defined:
Still though, doesn't seem like that much, and the rest of the logic in nb_black is for handling Jupyter Magics, which black now already does
I've just tried emailing the author about this, hope I'm able to get through
This is attempting to use the pre-commit hook as described under version control docs along with setting --required-version in a configuration file. The pre-commit hook fails with:
Oh no! 💥 💔 💥 The required version `21.8b0` does not match the running version `0.1.dev1+ga8b4665`!
To Reproduce
First, a ...
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
Could an environment variable or something override scm?
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]
that's valid?
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.
oh black has spoiled me
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
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
I haven't done a release before but we have instructions, right?
I can do it (unless @neon loom is around and has time)
yea and theoretically me being a special little flower we should've found hopefully all of the major pitfalls of the process :p
lesson: don't do release candidates 😄
Go hard or go home.
Happy to do later but we do have instructions. Just don’t go adding steps …
here we go
hopefully it goes more smoothly for you :😄
wow, not even going to let me review, confidence much? /j
It was going to be green though so no biggie in all seriousness.
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
now nervously watching https://github.com/psf/black/actions 🙂
we should update the stable tag tomorrow probably?
what are the clicks we'll have to do? is that in the readthedocs admin interface?
well okay the clicks aren't a fix but it does resolve the problem ome-time
ooo it's there https://pypi.org/project/black/#history
basically go to "builds" and rebuild the stable version
Hopefully you have access, Lemme check real quick
Yup you do!
watch and see one of our dependencies go on fire again in the following days 😅
hopefully not :)
!remind 18H check release status + finalize release process
Your reminder will arrive on <t:1631651389:F>!
Thanks @dense jungle! To be honest I'm jealous of 1) your luck, and 2) your speed :>
Description
Checklist - did you ...
- [ ] Add a CHANGELOG entry if necessary?
- [ ] Add / update tests if necessary?
- [ ] Add new / update outdated documentation?
Thanks for the new release everybody!
mostly thank @neon loom for making the release process so easy 🙂
@bright glacier always so negative 😅
When you can’t code, you have to have other skills.
Weird - I format with black … maybe I should have CI use black from main since it’s in our CI …
I’m happy to quickly push fixes to the formatting if you want.