#black-formatter
1 messages ยท Page 18 of 1
and?
requirements/tests-cov.txt line 1
pytest-cov>=2.12.1```
lol
I started another mini-project so my open source time has been limited
awh, you started a closed source project? ๐
I basically started a new and improved version of black-primer using ideas from mypy-primer
which originally took ideas from black-primer
so in a way, I'm trying to be even better than mypy-primer
lol
nope, just another tooling project for psf/black as usual
ah lmfao
I have uh
2 repos for one project as it stands right now, soon to be 3 or 4 repos lolol
the first major improvement is much prettier output (although if I want to be mostly feature compatible with black-primer this may have to go, but hopefully not)
that sounds like a pain to manage
its not
one repo is the main project
but due to the nature of the project, default assets will likely on a seperate repo
configurave is a repo too
and then there will project extensions in another repo
ah, so this is how you were going to rope me into talking about configurave
eh
tl;dr configurave is basically a helper to be able to define a configuration and have it sourced from .env, terminal environment vars, multiple toml files, and other sources
no! why would I do that?
configurave is still in alpha and was written in 30 minutes out of annoyance, or so I was told.
I am quite slow when it comes to anything
that sort of development speed sounds amazing
diff-shades is like 513 lines of somewhat maintainable code
it's basically the core logic of the file that's sorta of a mess
ah
lol
huh
you just taught me something lol
i did not realise that http.server could easily just... serve... a directory
looking at next-pr-number ?
yes
i'm now adding an action to my taskipy tasks
python -m http.server --directory htmlcov -b 127.0.0.1
I just use alias wb "python -m webbrowser"
lol
reason to have the taskipy tasks is now its for everyone on the project
oh
I've been meaning to ask
how can I make black ignore a folder
current config
[tool.black]
line-length = 110
target-version = ['py38']
include = '\.pyi?$'
--exclude=/folder/
how to exclude multiple folders, in the toml then?
pyproject.toml lines 12 to 19
extend-exclude = '''
/(
# The following are specific to Black, you probably don't want those.
| blib2to3
| tests/data
| profiling
)/
'''```
i uh, need to read more docs because
target-version = ['py36', 'py37', 'py38']
I was setting this to the lowest version supported by the project its formatting
honestly, I don't know why black needs all of the versions
but you work on it
there's an issue on the tracker about it, but we semi agreed that making it a lower bound is probably a good idea
I thiiink its so it tests its valid ast on all of those interpreters if it can find one??
i have no idea
that's something that would make sense if that's what it does
:=
other than some syntax changes, nothing special
src/black/parsing.py lines 37 to 48
def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
if not target_versions:
# No target_version specified, so try all grammars.
return [
# Python 3.7+
pygram.python_grammar_no_print_statement_no_exec_statement_async_keywords,
# Python 3.0-3.6
pygram.python_grammar_no_print_statement_no_exec_statement,
# Python 2.7 with future print_function import
pygram.python_grammar_no_print_statement,
# Python 2.7
pygram.python_grammar,```
it's also used for Feature.*
so black knows whether it can do a certain thing or not
3.4 and 3.5 introduced trailing comma support for func signatures and calls
but sadly does change the ast in a few places
like
isn't --strict supposed to keep ast identical?
or was that added as a result of that conversation
we don't have such a flag right now
did it at some point?
never did
i don't use mypy LOL
[tool.poetry.dev-dependencies]
black = "^21.7b0"
codecov = "^2.1.11"
coverage = { extras = ["toml"], version = "^5.5" }
flake8 = "~=3.8"
flake8-annotations = "~=2.3"
flake8-bandit = "^2.1.2"
flake8-bugbear = "~=20.1"
flake8-docstrings = "~=1.5"
flake8-isort = "^4.0.0"
flake8-string-format = "~=0.3"
flake8-tidy-imports = "~=4.1"
flake8-todo = "~=0.7"
isort = "^5.9.2"
pep8-naming = "~=0.11"
pre-commit = "~=2.1"
pytest = "^6.2.4"
pytest-asyncio = "^0.15.1"
pytest-cov = "^2.12.1"
pytest-dependency = "^0.5.1"
pytest-docs = "^0.1.0"
pytest-xdist = { version = "^2.3.0", extras = ["psutil"] }
taskipy = "^1.6.0"
we added this docstrings handling code that was supposed to handle the case where black is converting 2-space indentation to 4-space incorrectly
but it turns out it touches a lot of whitespace within docstrings
related: i cannot wait for poetry 1.2.0 to release, for the dependency groups
Can move all 7+ test deps above to a second group
yeah, you're not the first person to complain about it
uh uh uh waht, I didn't know about this
I personally don't think we should be even touching docstrings (except for maybe the quotes placement) since everything in 'em matter
but I don't feel strongly, I don't really make these sort of decisions here
I'll explain in the other server
Yeah same
@bright glacier I didn't read all of the above but mypy ended up pinning tomli to a version that doesn't have the annoying CR thing, that may make your life easier too with mypyc
From the pre-commit docs
Using a branch name (or HEAD) for the value of rev is not supported and will only represent the state of that mutable ref at the time of hook installation (and will NOT update automatically).
I'd suggest that the docs just use the latest tag in their example
closes #2415
addresses part of #2413
woohoo, thanks for the merge!
I've made a PR to address the first TODO you've brought up, but I don't understand the second one.
just document the quirk
Which quirk are you referring to?
For the purpose of documenting the new pre-commit hook, what would be the next version of black? 21.8b0?
(we can always deal with any remaining issues as they get reported).
Yes!
I really like the code formatter
Well, there are styling issues in doc-strings you should uniform. Namely:
"""Testing something
This function tests something
"""
Vs ```py
"""
Testing something
This function tests something
"""
And well, anyone using anything else in terms of styling of doc-strings.
I read docstrings in slow mode so their formatting doesn't really bother me
I mean that's true, it's not a styling thing that bothers me as much as other stuff. But it's something I definitely notice and should be enforced by an opinionated doc-string.
There's something enforcing it in most codebases I'm using. Maybe flake8?
There's pydocstyle which can be plugged into flake8 with flake8-docstrings
Yeah I'm pretty sure I'm not using it...
I think people are just formatting these by hand
Yes, pydocstyle only checks the style and complains if it's wrong
it doesn't know how to fix it
I'm not aware of any commonly used docstring formatters... it probably makes sense that this is something humans should do
:lem
Hey hey black team, does black load the entirety of the pyproject file or can it just load the part that it needs?
That sounds more like a feature of the TOML library we're using, and as far as I know tomli does not support that
here's a progress update on the libcst rewrite: https://github.com/Instagram/LibCST/issues/285#issuecomment-894699168
Oooo nice! I wonder how hard that last 1% is going to be ๐
# HACK: I know this is hacky but the benefit is I don't need to copy and
# paste a bunch of black's argument parsing, file discovery, and
# configuration code. I also get to keep the pretty output since I can
# directly invoke black.format_file_contents :D
def get_project_files_and_mode(
project: Project, path: Path
) -> Tuple[List[Path], black.FileMode]:
import black
files = []
mode = None
def shim(sources: List[Path], *args: Any, **kwargs: Any) -> None:
nonlocal files, mode
files.extend(sources)
mode = kwargs["mode"]
with suppress_output(), patch("black.reformat_many", new=shim):
black.main([str(path), *project.custom_arguments], standalone_mode=False)
assert isinstance(mode, black.FileMode)
return files, mode
One of the more hacky bits of code I've written lately ๐
I'm hoping not very hard ๐
Yes, I was asking what black does lolol
Sometimes black doesn't add a trailing comma after the last function argument. This happens e.g. when there is a star (*) argument in the argument list.
black_trailing_comma_bug_1.py
def a_function_with_a_star_argument(*, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb):
pass
def a_function_without_a_star_argument(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb):
pass
$...
what is formatter? what the function of it?
dev-requirements.txt line 2
black==20.8b1```
The goal of a formatter is to change the structure of your source code to conform to certain rules, so you can have a common style everywhere
All sounds good to me. Many thanks for this! Once @JelleZijlstra is happy lets merge.
error: cannot format schoolroom.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_gfkfesa1.log
Oh no! ๐ฅ ๐ ๐ฅ
1 file failed to reformat.
black, version 20.8b1
Mode(target_versions={}, line_length=105, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -169,25 +169,29 @@
{...
what is black fromatter
!pypi black
@dense jungle what was the bug?
I think it was the big magic trailing comma thing that Lukasz eventually fixed by just formatting twice
๐
And this is why I don't run black-primer locally, running black over the whole project selection takes 30+ minutes ๐ฎ (although this is actually diff-shades in this screenshot)
just format correctly to begin with ๐ /s
I'm confused, what do you mean by that?
It's kinda half the point of diff-shades & black-primer to run on projects that have never interacted with Black so we can catch issues never seen before.
Unless the joke is that Black's style isn't good enough?
im just joking lol
My point was that to me it wasn't the best joke since it wasn't clear ๐
ahh, i didn't really look much at what you said
diff-shades meaning it is only doing a dry-run or what does it mean in this case?
so diff-shades / black-primer (the latter is the current utility in use, although I wrote the former to be an much improved version) basically takes a list of open source projects, clones them, runs black over them recording the results
ahh interesting
we use it to compare differences in behaviour between versions of black, check how big the impact of something will be, etc.
is there a black command to see if running black would cause any changes
potentially want to add this as part of a CI/CD pipeline to make sure that black was run for the whole project
ahh nvm i see --check
-c key, I believe
yeah, thanks
so having large code bases not blacked is actually good for black, interesting...
That's the short form of --code not --check FYI
Not necessarily. We want to see how changes in Black itself affect its formatting
black-primer is much better suited at gauging the impact of black on projects in general while diff-shades aims to better gauge the differences between two versions of black. The former is helpful to us too but it's not as helpful. Especially since that sort of data is more for when you're (considering) adopting Black BUT not when you're a developer of Black.
how can I tell black I would like no line length limit?
tried black -l 0 and black -l -1
black -l 9999999999999999999999999 shoud get the job done at least :D
But on a more serious note, I don't think that's an option we want to provide to users. Where would that be beneficial?
if there is no line length limit, what's even there to style, quotes? :)
if someone dared to use multiple lines for something, black would just join it back together in a single line lol
I suggest no magic trailing comma handling for the full hands-on experience of lines with no limits /s
๐ ๐
Where would that be beneficial?
I'd rather scroll to the right in my editor than see the tool try to apply line wrapping. I don't know why my config file should have some large number of nines in a row to get this.
Why not just interpret -l 0 as no length enforcement?
Fair enough! Can't argue with preference, but I think the overwhelming majority of people would prefer a reasonable line length limit and wrapping lines longer than that. -l -1 or such could encourage using it, and since Black is opinionated, I don't think we should do that. Does that make sense? Out of curiosity, do you prefer no wrapping in every scenario (list items, strings, long nested collections or calls), or a specific one?
I generally think not wrapping makes my code more readable and easier to understand how the program flows. I really like being in control of the wrapping by placing , at the end of the thing and I do that in the cases when I think each element on its own line makes understanding easier.
I can definitely see your point, but I'm afraid you're swimming against the current because we try to not take previous formatting into account ๐
I mostly place the a , at the end for function calls where I set a bunch of kwargs
oh well, not the end of the world to have some nines together in my pyproject.toml!
Black is not for everyone, especially if you like to be the one in control :D
That was a joke, please don't actually do it
What do you mean?
(I actually had it this way to begin with)
I was just saying if you think people shouldn't do
[tool.black]
line-length = 999999
Then maybe limit the allowable max line length limit or remove the line-length option all together! I mean Henry Ford only offered one shade of black, right? ๐
Or rename the tool to "black (with a configurable opacity)" ๐
Touchรฉ, but the exact value has been a bit controversial :D see https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
I love the concept of the tool and I'm sick of wading through diffs, so I'm thinking today that the loss of control is worth it!
That's a realisation I've come to as well ๐
We are waiting with open arms in the "no formatting worries" land for you
\o/
One other black question I have: is it a bug if black doesn't enforce the configured line length limit?
Like, should it break up long strings?
Pass in --experimental-string-processing and it will! It's being developed.
ah cool
more generally we do consider it a bug when Black doesn't obey the line length limit. such bugs are tracked in https://github.com/psf/black/issues?q=is%3Aopen+is%3Aissue+label%3A"F%3A+linetoolong"
xref #2413
I added jupyter to Pipfile and then, in a new virtual environment, ran pipenv install --dev, and committed. Is this what's required for that issue?
whelp.
tl;dr github crashed
yeah, was trying to look at a pypa/pip PR and it 500ed twice, looks pretty crashed to me
oh wow, all of the services are yellow
๐
IIRC it wasn't actually super clear whether pip would do this, there was an issue where automated code formatters were being debated. I'm impressed and surprised there isn't as much pushback.
Is it just me or do we all feel a bit more responsible for not messing up black's style now ๐
Oh well, I'm sure we'll be informed very thoroughly if we get it wrong :p
noooooo not GitHub ;-;
โฏ pyperf compare_to fmt-fast-clang.json fmt-fast-gcc-10.json -G
Slower (15):
- fmt-fast-flit/sdist: 84.6 ms +- 5.2 ms -> 95.8 ms +- 7.4 ms: 1.13x slower
- fmt-fast-black/output: 38.4 ms +- 2.7 ms -> 43.1 ms +- 3.8 ms: 1.12x slower
- fmt-fast-black/__init__: 409 ms +- 22 ms -> 453 ms +- 31 ms: 1.11x slower
- fmt-fast-black/lines: 283 ms +- 17 ms -> 313 ms +- 21 ms: 1.10x slower
- fmt-fast-comments: 37.5 ms +- 1.9 ms -> 41.3 ms +- 3.1 ms: 1.10x slower
- fmt-fast-nested: 27.5 ms +- 1.6 ms -> 30.3 ms +- 2.9 ms: 1.10x slower
- fmt-fast-black/linegen: 397 ms +- 24 ms -> 431 ms +- 35 ms: 1.08x slower
- fmt-fast-black/mode: 41.9 ms +- 2.6 ms -> 45.3 ms +- 3.6 ms: 1.08x slower
- fmt-fast-dict-literal: 55.2 ms +- 2.8 ms -> 59.3 ms +- 4.8 ms: 1.07x slower
- fmt-fast-black/strings: 72.5 ms +- 3.7 ms -> 77.5 ms +- 6.2 ms: 1.07x slower
- fmt-fast-flit/install: 182 ms +- 12 ms -> 194 ms +- 16 ms: 1.07x slower
- fmt-fast-list-literal: 33.2 ms +- 1.6 ms -> 35.4 ms +- 3.0 ms: 1.07x slower
- fmt-fast-flit_core/config: 285 ms +- 16 ms -> 304 ms +- 25 ms: 1.07x slower
- fmt-fast-black/nodes: 329 ms +- 16 ms -> 347 ms +- 29 ms: 1.06x slower
- fmt-fast-black/brackets: 120 ms +- 7 ms -> 125 ms +- 11 ms: 1.05x slower
Benchmark hidden because not significant (2): fmt-fast-black/comments, fmt-fast-strings-list
Geometric mean: 1.08x slower
So gcc takes longer to compile while using twice as much memory to do so, produces binaries that are basically no smaller than clang's, is more picky about the C code it's given, and finally is slower ... what was I thinking gcc was viable :>
Anyway it seemed like the last set of optimizations have netted me a ~3-6% additional perf win which is nice! Especially since I got lazy and didn't do as much analysis for this optimization pass ๐
hello ichard
hey arl
is blackbench or diff-shades useful for a end user of black?
I mean you could use diff-shades to see the impact of a different revision of black but like it would be easier to just run black with the diff flag
And blackbench is purely focused on benchmarking black's performance, not quite sure how that would be useful to an end user
Maybe I'll publish it but maybe not (probably not)
It's in the black-mypyc-wheels project
ah
contemplating using mypy on my project
like
it caught a few incorrect typings the other day when I tried it for fun
Hey, working on a project to automate some of my stuff at my job. Do i need to make a channel under open-source projects?
via setuptools-scm
ah
Nope, that's specifically for open source projects partnered with this server (also, you shouldn't be able to make a channel, only admins can do that)
Describe the bug
black does not add the two newlines between these two definitions when there's a comment in the way
a = 1
# adsf
def bar() -> None:
...
this causes the following error in flake8:
E302 expected 2 blank lines, found 0
Expected behavior
a = 1
# adsf
def bar() -> None:
...
Environment (please complete the following information):
- Version: 21.7b0
- OS and Python version: macos 11.4, python 3.10.0...
Describe the bug
Dear black developers,
First of all, thank you for this wonderful package!
I wanted to skip one line using # fmt: skip. Unfortunately for my case this "skip"-statement seems to be "ignored" by black. I think the following example to reproduce makes it more clear.
To Reproduce
Consider the following code:
def somefunction(clusters):
return bool(x)
if __name__ == "__main__":
class A:
foooooobaaar = "foobar"
...
@bright glacier Hey mate - Long time, I've been busy with travelling and life for a change so haven't been around
Did you ever do any benchmarking with black using uvloop and not using uvloop. Especially blackd - I'd expect maybe less memory usage and maybe lower latency on a busier blackd server more so than a reduction - e.g. 5 files vs. 1 being formatted together (if it can even do that - Never used it directly - Pretty sure my vscode does tho)
I hope you had as much fun as COVID would let you!
That's all @austere lava's doing tho (He does that for FB or has helped with it)
I have - Rubicon off roading, when to chicago to see in laws, wedding in the Bay Area, been fun ๐
*went
Ah no, I've been exclusively focused on benchmarking "how fast can black format predefined input". That sounds interesting tho!
I've never really used it so I have no feel for that, bandersnatch uses it tho and we haven't had any major fires
@plain atlas I've used it with great success on big busy python services @ Facebook (I work there)
And other open source projects
As ichard alluded to
ah
I've just not seen if it's a win or not for Black
I mean
I've seen memory 1/2 and latency drop on some services @ FB using it
pls be an optional dependency for black, if considered at all
I'd guess it doesn't matter as much since Black doesn't interact with the event loop all that much
It is
But worth trying
Already
I presume more nerdy drone footage was taken during this adventure ๐
ah
Only off roading + Chicago ... Didn't take to wedding. Feel that's rude.
i mean, black takes like 0.64s for me so Ig having the uvloop dependency isn't worth it lolol
hm......
I think I just found a bug.
Well OK I thought it was clear drones would be a no-go at a wedding haha
black just formatted a file I have gitignored
From docs, and previous experience, I don't think its supposed to do this
it's probably mostly the import time being costly
The photographer had his own to get the shots outside the ceremony
is this probably a bug?
@bright glacier All the drone footage is shared on my Facebook of course ๐
Haven't heard of many weddings due to COVID, so it's nice to hear at least one happened ๐
I keep complaining to my friends in the video team about how the downsample my 4k video to crappy 1080p. ๐ฆ
*they
They live in the 80s
What does running black with verbose tell you, is at least one file being ignored via .gitignore or is .gitignore MIA?
I have an internal task to my mate in the team "Give Cooper 4k"
We recently made a change to not listen to gitignore if you also have exclude set up in your pyproject.toml I believe
Haha, downsampled 4k is probably better than native 1080p so it could've been worse
is 1080p really the 80s these days? /hj
I got married last November with no guests. We plan to hold an actual wedding with our family and friends at some point but I don't know when if ever that will happen
my config
[tool.black]
line-length = 110
target-version = ['py38']
include = '\.pyi?$'
its a nested .gitignore file
Congrats mate!
Hurts my eyes
(Even tho 99% of what I watch is 1080p) ๐
since according to https://git-scm.com/docs/gitignore, you can have multiple .gitignore files and I use that to my benefit
I'm pretty someone added support for nested .gitignore support some time back so that shouldn't be a problem hmm
Oh nice, congrats! ๐
I held my wedding off till May 2022 to try and hope we're sorted by then. And to hope my parents can come from Australia ๐ฆ Does not look good
Big congrats!
The delta strain is really unfortunate, we're probably on our fourth wave at this point :/
hm
well i have a different git problem right now so I'll try and fix that and get back to you
also I just deleted those untracked files, FML
I did once a week ago and my goodness you don't know how happy I was I had a backup
Yeah international travel makes it even harder ๐ฆ The US is still closed to European travelers so my family wouldn't even be able to come
i don't have those files backed up
fun.
And apparently Australia just doesn't let anyone in?
thankfully i copied it from a previous project and it took minor changes
and their point was to demonstrate how easy it was to convert other project stuff to this project lolol
so its easy to get back, but annoying
do any of you use visual studio code?
I do
my vscode isn't set as the default editor for cli actions
Even if travel is allowed, I fear delta will spread even among the vaccinated folks which would be not great
Yup - both at the moment without exemptions
and I need to figure out how to set it as said default editor again
I live in vscode
I switched to Vim a long time ago ๐
my setup is a device over ssh
the problem is its using vim instead of vscode for all terminal editing actions
specifically git
and github's cli too
$EDITOR is not set to anything
I remember setting up a git config in my vscode user settings that sets vscode as the git editor
fun thing is editor runs nano, and not vim
I have vim plugin on vscode and still live in vim
I'm an old Linux BOFH
UNIX even - use to run solaris etc.
I was upset but understand when fedora changed editor default to nano ๐ฆ
"terminal.integrated.env.linux": {
"GIT_EDITOR": "code --wait",
// this exists so the starship prompt isn't enabled which is broken in VSCODE
"IN_VSCODE": "indeed!"
},
that's my solution to using vscode with git relatively painfree
:O
how can i test the git editor is correct now?
I don't remember at all lemme find the issue
(basically whats a command that makes git open something to edit without going in to any mode)
eh
You can probably just do an interactive rebase then abort
Now that I did backread, I can be more confident it hasn't been answered ๐
just make a random edit, commit it, then reset head~1
here's the issue https://github.com/psf/black/issues/2164
Oh yes, the "gitignore everything" use case, never would have thought of that ๐
that's an interesting use of gitignore lol
ah, then I don't really care
just a comment on it: I often look at a gitignore file to see what configuration files the project uses
personally I'm interested in using existing gitignore but I also want to exclude vendored stubs from black
TL;DR:
Changes behavior of how .gitignore is handled. With this change, the rules in .gitignore are only used as a fallback if no exclusion rule is explicitly passed on the command line or in pyproject.toml. Previously they were used regardless if explicit exclusion rules were specified, preventing any overriding of .gitignore rules.
Those that depend only on .gitignore for their exclusion rules will not be affected. Those that use both .gitignore and exclude will find that exclude will act more like actually specifying exclude and not just another extra-excludes. If the previous behavior was desired, they should move their rules from exclude to extra-excludes.
awesome!
IMHO to not have a breaking change, USE_GITIGNORE would've been nice lol
Any signs of when those restrictions will be lifted or weakened?
I don't want to mess up my local modmail branch lol
not until its reviewed ๐
oh, well that doesn't bode well
So slow
Australia says not until the new year. They still having 100s of cases a day in the bigger states (that's a lot for us - 25 million people country that's an island)
Half of that is probably python startup time ๐
Are those numbers published anywhere? Otherwise I'm gonna Bug report that Python in residence engineer ..
IIRC python startup time is measured on speed.python.org
or whatever the benchmarking website URL is
that's the one
Guido's faster cpython project has been working specifically on startup time
I can't remember too
He's been trying to speed up pyc loading
Nice
That will be H U G E
I wish Instagram would/could upstream its runtime improvements
And I'm working on better black performance heh (I know, 100% less cool)
That sounds awesome, import time is such a big issue
Me too. And make it available generally internally ๐
๐
Make my CLIs great again
Eggsactly
@solid adder You got any time for black anymore? Any love for us? ๐
I've found the DIR weekly reports fascinating. Oh and I'm particularly excited about the issue and PR stats that are apparently coming next week ๐
Yeah they have been good
I think out of my few python contributions ambv has merged all but 1. lol
I saw some changes get merged into lib2to3 a few days ago lol
I wouldn't be surprised if zsol already implemented the changes (or the functionality of the changes) in blib2to3 a long time ago :p
Yes, Lukasz's work has been great, I've been seeing a ton of old PRs getting merged
Yeah they were just backports of fixes I made in blib2to3
Nice! That reminds me that we still need to address the "new parser" issue don't we lol sigh
This is cool, thanks!
Yeah so about that
I've a few people helping me with the rewrite by now, but am gonna go on vacation end of next week
So not sure how much progress there's going to be
Your rewrite is for LibCST's parser, right? Or are you also working directly on Black?
CPython really gets a lot of PR traffic doesn't it, I would've expected a more noticeable dip from ลukasz's help but nope!
Nono just libcst
So we'd still have to totally rewrite black to work on top of LibCST ๐
how's using rust with python? or have you not reached that stage yet?
I probably won't have the bandwidth to do that yeah
I ask that because someone just said they made a blackd client in rust lol
But more than happy to dedicate time to support someone who wants to do it ๐
Oh really?
We still have some money and if libcst seems best we can tender out spending that money on getting it done or ask for donations etc.
How will that help?
A client in rust would work ...
Less startup cost
I missed client in the original message from richard and thought someone said they'd make blackd in rust ...
Sure - as long as they add CI and documentation ...
building, unittests + integration testing with blackd
To anyone reading this: I can't in good conscience recommend this cli as it was my "let's learn rust" project ๐
too bad, it seems really neat for whenever im gonna try to turn on format on save
I'm a bit worried with how we could integrate it with our build system but apparently PyO3 has a setuptools plugin as I've heard?
The argument we shouldn't distribute native binaries is already out of the window due to my mypyc work tho
unless we decide not to, but I hope not ๐
Is your feature request related to a problem? Please describe.
I am using the VisualStudio Code extension Better Comments, which works by coloring comments based on a specific symbol/string right after the comment start. The frustrating part is that Black always adds a space in between, which would turn this:
a = 10 #? Should we change this
into this:
a = 10 # ? Should we change th...
that was close
imagine running black / and not black .
temptation got to the best of me
turns out what happens is it ||runs in to a .gitignore file it doesn't have permission to read and fatally errors before it does anything||
hmm maybe we need go of the way of the warning rm -rf / does
yeah, might be worth it
at the risk of looking like i reformatted all of the pythons on my machine at one point, I'll make an issue on the repo
psf/black#1
^ ignore, just a short link to get my browser open
When making an issue, there's an extra \ that shouldn't be there, and it doesn't need to be escaped in the .yml file.

Is your feature request related to a problem? Please describe.
The . and / characters are very close together, and this can lead to accidentally reformatting from the wrong directory.
Describe the solution you'd like
@ichard26 suggested to have a warning like with rm -rf /, and I agree with this suggestion.
Describe alternatives you've considered
Additional context
nice
i'm curious, do you wait for checks to complete and then merge, or do you need someone else to approve it too?
LOL
waiting for checks even although it's only the lint one that matters here
you don't have automerge enabled?
larger changes usually have two reviews but one review is enough for those sort of changes
nope.
that allows you to turn on automerge and then once all checks pass the branch will be merged :)
hi
salut
Why didn't black pick up the CamelCase as an error in https://github.com/Gweno/tutolibro.tech/blob/master/lopy/part9/ReverseRange.py ?
why would CamelCase be an error?
holy shit lol
okay wow
I have to share this project here, its very impressive
formats all markdown files
now, the reason to share it here, is that it has a plugin system, and there is a plugin for formatting python code within the markdown file
!pypi mdformat-black
Now I can format all of the code blocks in my markdown files with black as well!
have you heard of blacken-docs for reStructuredText?
!pypi blacken-docs
yeah, makes sense for auto formatting of whole markdown files
yeah
I know that when it comes to reStructuredText, there's rstfmt but it's in a very, very early stage
not sure that using blacken-docs is worth it if I'm already using mdformat
except for one thing
mdformat-black requires the code block to be labeled with python
pydoesn't count
seems like a bug
yeah
You can just use both
@lament crow https://stackoverflow.com/a/160830/4539999
I'd expect it to be identified
i mean yeah but also like, if i use blacken-docs I'll cut the mdformat-black from pre-commit
Black doesn't enforce this. It's too unsafe. We'd have to have a way to rename the variable everywhere it's referenced, and we don't
also uh, dynamic getattr
yes, there's lots of ways it's unsafe
imo snake_case is rubbish but that's the way python specs were written. Seems it's often just ignored.
i mean, how pep8 was written but yeah
has it formally changed since pep8?
PEP 8 is just the style guide for the standard library. You can do whatever you want in your own code
If it was feasible, Black would enforce snake_case, but it's not feasible so we don't
and even more so, the logging class exists
yes, even in the stdlib there is lots of legacy code that doesn't follow the conventions
Which is crap when you start mixing code from different sources, the whole point of a style guide.
logging.basicConfig smh
legacy code is a different issue
All the names for logging I thought were copied from Java
yeah
In which case you wouldn't expect them to change
I feel like they could be changed though they did it with the threading module
TBH
blacken-docs looks a lot better than mdformat-black so yeah
ah yes
gotta update it all
@bright glacier
Here's your reminder: maybe, just maybe ask about configurave
[Jump back to when you created the reminder](#black-formatter message)
not sure I summarized it yet but tl;dr take inputs from env, toml, default toml, and put it into models so it can be used.
i
did i
noooooooo
I misspelled unnecessary.
wow
@bright glacier I regret my life.
This seems fine to me, but I will note that code wasn't immediately clear and I was quite scared about "if gitignore is None: sys.exit(1)" bit since I thought it would also exit on cases where a gitignore file didn't exist.
Nevertheless, thank you!
it's ok, I'm sure I have my fair share of regrettable commit messages that are now out in public ... forever ๐
force pushes tho
not an option on a repo like psf/black
i mean, you can on pull requests
but yeah, once something gets to main its too late.
$ black -c "print("
print(
error: cannot format <string>: ('EOF in multi-line statement', (2, 0))
Haha, I found a unrelated regression while reviewing a PR. Looks simple enough to fix.
The input should definitely be not printed if an error occurs :)
should it tho?
I guess with an EOF its worth not printing
but other errors some of it should?
Why should it give back the user what it gave quite explicitly?
It's unnecessary and noisy if there's an error blocking black from doing its thing.
I haven't closed an issue in a long time haha, feels good to know I'm still reasonably decent at finding duplicates ๐
Describe the bug
Black failed to format a valid python file. Appears to be something to do with inline comments on a multi-line statement.
To Reproduce
Diff is below:
--- source
+++ first pass
@@ -118,14 +118,14 @@
def _get_rates(product: market_supply_models.Product) -> List[GasRateRow]:
# Gas rates have stepped consumption and one standing charges for each zone identifier.
rates_rows: Dict[Tuple, GasRateRow] = dict()
- for rate in (
- ...
What's the best way of getting the latest released version of black from within the codebase? (this is for the issue of keeping the pre-commit example's rev in sync with the latest version of black)
One way would be to parse it from the CHANGES.md file, but that feels brittle.
I considered using black.__version__ but that gives e.g. 21.7b1.dev9+gb1d0601.d20210810, rather than the latest released version.
Finally, I considered looking at the latest git tag, but figured that that might not fit in with the release process - if a tag triggers a release, then the check to ensure that the rev in the pre-commit example from the docs is synced with the latest release of black would be triggered too late.
have you looked at how the black --version command gets the version? alternatively, could you use the black release rss feed frm pypi?
for the former, it's setuptools-scm, but it only gives the "development" version (e.g. 21.7b1.dev9+gb1d0601.d20210810 as opposed to 217.b0)
as for taking the rss feed - this wouldn't work as a CI check
Thanks anyway for your suggestions!
are emojis still not acceptable for a command line tool in certain environments?
one idea would be to use that development version, parse it with packaging.versions.Version and then get the main version out from that. Not sure how well that would work tho!
I would get the latest tag from git. That's what setuptools-scm does too
Thanks - tried that but it doesn't seem to work in CI. Will take another look anyway, I might have done something wrong
I mean you can always use the github api to get the latest release
git checkout $(curl -sSL api.github.com/repos/psf/black/releases/latest | jq -r .tag_name)
Or something like that
Thanks @austere lava - I tried
latest_tag = subprocess.run(
shlex.split(
"curl -sSL api.github.com/repos/psf/black/releases/latest "
'| grep \'"tag_name":\' | sed -E \'s/.*"([^"]+)".*/\1/\''
),
universal_newlines=True,
stdout=subprocess.PIPE,
).stdout.rstrip()
but then in CI get
fatal: No names found, cannot describe anything.
curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)
Not sure what this is but I'll investigate
There are supported enough to be used I would say, since the new Windows Terminal now adds emoji support natively.
I meant this ๐
so you meant acceptable socially, not acceptable technically?
yep!
like I get they can look out of place, but it feels a bit silly to add a toggle to disable them
I'm surprised at how much traffic we've gotten over this tho
not managing to get this to work in CI, for now I'll go back to getting the version from the CHANGES.md file
INTERNAL ERROR: Black produced different code on the second pass of the formatter
To Reproduce
Black this file
def black(foo):
assert pythoncontent.content_from_environment(
{
"File": tmpdir / "FilePath.ptest",
"Environment": {
"Virtualenv": {
"RequiredPackages": {
'package': "1.0"
},
"RequirementsFile": "r.txt"
...
If I'm fired tomorrow, then we've learned it's better to ask for permission and not forgiveness

you can't be fired, its always better to ask for forgiveness over permission, its the pythonic way
Well that didn't last long https://github.com/pytorch/pytorch/commit/1022443168b5fad55bbd03d087abf574c9d2e9df
Test Plan: revert-hammer
Differential Revision:
D30279364 (https://github.com/pytorch/pytorch/commit/b0043072529b81276a69df29e00555333117646c)
Original commit changeset: c1ed77dfe43a
fbshipit-so...
not surprised :p
I think it is fair to be able to disable them. Some systems just don't like emojis at all and produce garbage data when they are used.
Arguably the system should be updated rather than the app, but who am I to judge ๐
Hello hello. I'm here to be disruptive again: anyone tried Furo with black's documentation yet? ๐
Aye. Nice!
Lemme know if y'all see anything disruptive/concerning with Furo.
Most of my Discord channels are muted, but @-mentioning me in this channel (or on the PyPA discord) will reach me.
Anything I can do to help get https://github.com/psf/black/pull/2237 moving again?
I've seen furo has recently been added as an example theme to sphinx's tutorial so that's nice
I think the best-looking uses of Furo (that I've seen so far) has been Black's documentation built with it, from one of the maintainers trying it out.
In case someone does not follow Pradyun or just doesn't use Twitter
glad we got the update, now we just need to know if you still got your job ๐
so far so good ๐
@dense jungle is there an issue on the mypy issue tracker about renaming the default branch to main or something else? I'm asking rather selfishly because mypy is the only repository I've regularly been developing for that stills uses master but my muscle memory has already learned main so mypy using master is annoying :p
I tried looking but tbh the 1700+ issues were impossible to dig through :/
No there isn't. Last I heard the Steering Council would make a call on when to do it for all python repos but that hasn't happened yet
@bot.command()
async def avatar(ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
Hey! Welcome to the server. We cover most info you need to know in #welcome.
This channel is meant to discuss the package โblackโ.
For general discord.py help, try #โ๏ฝhow-to-get-help or #discord-bots
why have you the role "muted"
This whole server uses English, please see #rules. If you canโt speak English, itโs fine to use something like Google Translate
hey how's it going, I'm trying to use black on python 3.9.6, for some reason it won't work without the --fast param.
receiving errors when integrating with vim/nvim plugins (Neoformat/Formatter.nvim) as well.
What's the error you're getting without the flag @quartz flicker ?
It shouldn't be crashing due to the integration, I suspect black is buggy on a particular input or your input isn't actual valid python code.
In other news, I just finished the last set of changes I wanted before releasing blackbench 21.8a1. This release is special since it's the first one that's going to be published to PyPI. It also will be my first project on PyPI. I don't know if I should be worried or scared, but I am :p
CI is green so I guess it's time to try out my release automation and hope nothing breaks. Afterall, what's the worst that could happen?
Oh wait, step one is first remembering my PyPI password lol, it's been too long since I've last signed in ๐
nox > git commit -m Let's get back to development
nox > Alright, just do a push to GitHub and everything should be done
nox > If you're paranoid, go ahead, verify that things are fine
nox > If not, sit back and relax, you just did a release ๐
nox > Session do-release was successful.
ahhhhhhhhhhhhhhhhhhhhhhh my blood pressure is still very high right now but I'm excited!
I'm too lazy to setup an account for test.pypi.org
Hmm, does readthedocs not create a stable version automatically for you if there's only prereleases
I guess I'll just make a stable branch for the time being then.
Alright, time to benchmark a lot so I can open a PR for my mypyc work soon, but first a break ๐
yay
how can i delete a project from there so I can test again?
well the versions won't be freed, once used they are done forever
yeah ;-;
even though it promises its a test pypi
its not actually a "test"
its a second index lol
that's meant for testing, so in a way, it serves its purpose, not well tho IMO
yeah
i agree its not well
also poetry is buggy rn
and I actually don't have a keychain on my device so I have to delete poetry's config every time since it stores creds in a plaintext file lol
may see about using twine for publishing instead of poetry NGL
If youโre really concerned about messing up the test index, spin up your own copy
Eh, I'm just happy I've done a release on PyPI. I'll deal with security later ๐
(disclaimer: I'm not liable for any damages that may occur if you follow my "advice", this is not intended as advice)
Untrue, and OT ๐คก
password managers can help with that :)
like keepass...
Sorry to bump this again ๐ณ - is anything blocking the release?
My time and people telling me of weโre ready or not. GitHub installs always work too โฆ
I have some time today - where we at?
we should be good for a release. I won't have much time to help out though, we're moving tomorrow and I live in a labyrinth of boxes
haha - That's fine. I'll take a look later. LinkedIn just suckered me into doing a quiz to get a badge - lol
Congratulations! ๐
lol - thanks. Was like, I hope I can pass this.
yeah... I think you passed ๐
Oh good luck finding your way out of the labyrinth then! I was going to pester you today since I'm testing and benchmarking the mypyc branch in preparation for a PR ... but I guess Cooper can help out ^^
what is mypyc in the context you used the word
a Python-to-C transcompiler
that's the cool thing I've heard
mypyc is a python to c transpiler that uses mypy to make sure what youre writing is "safe"
It also uses the type information to optimize in ways that would be unsafe if the type is unknown at runtime.
Unfortunately mypyc is still alpha software so extensive testing is necessary before deploying it to PyPI, right now I'm doing one of those testing runs
Ah crap, looks like blackbench is buggy with mypyc compiled Black
cool, so mypy didn't catch this bug because one of my type annotations were wrong (should've been Optional[str] not str) and I doubt mypy could ever hope to catch this type annotation issue due to how the function is called.
do you use --strict?
I think we should do a release with what we have and do a dedicated no changes for mypyc so we can see if we get any "mypyc" related new bugs etc.
The problem is that the type annotation is defined in a function that's called by click's magical callback code
I doubt that mypyc will cause any issues at the pure formatting level, and I'm somewhat confident on this because the data just came in from diff-shades which shows no difference in interpreted black vs mypyc compiled to C black.
Although I expect other classes of bugs and edge cases
Sweet
โฏ python ../black-mypyc-wheels/diff_shades.py compare main-e465acf.json linux-mypyc-e9834e0.json
Loading files ... done
aioexabgp (19 files): everything is the same
attrs (46 files): everything is the same
bandersnatch (50 files): everything is the same
blackbench (13 files): everything is the same
channel (44 files): everything is the same
django (2692 files): everything is the same
flake8-bugbear (27 files): everything is the same
hypothesis (384 files): everything is the same
pandas (1390 files): everything is the same
pillow (275 files): everything is the same
poetry (310 files): everything is the same
pyanalyze (48 files): everything is the same
pyramid (178 files): everything is the same
ptr (5 files): everything is the same
pytest (248 files): everything is the same
scikit-lego (124 files): everything is the same
sqlalchemy (590 files): everything is the same
tox (94 files): everything is the same
typeshed (2306 files): everything is the same
virtualenv (145 files): everything is the same
warehouse (504 files): everything is the same
As usual, we're done here, have a wonderful day/night! Cya! <3
Yeah, I have - experience with all this but it sounds cool
I may have made a better version of black-primer ๐
But your work was important still, black-primer spurred the creation of mypy-primer whose ideas I stole for diff-shades haha ๐
Actually @neon loom as I've alluded to before, I'm going to need some help since I don't have an MacOS running machine. Are you up for it?
I can give you SSH to my laptop if that makes it easier ...
Also the M1 compiled wheels are totally untested since we don't have access to M1 CI resources
Do you have IPv6 enabled on your connection?
I'm sorry if this disappoints you but I've never used ssh ๐
๐ฎ
Probably not
Ok. No problems. It's just encrypted remote shell/terminal access basically. Would let you copy files / use my m1 mac to do what you need (I'm using it as we speak too) ... Was planning on making you a non admin account + opening SSH directly to it for your IPv6 address if you had one. I could do IPv4 but it's more effort as I would have to port forward from my main router etc. and I have IPv4 off but default ... # legacy
For all those people who are like you need v4 (unfortunately I do for lame GItHub) I use NAT64 ... https://cooperlees.com/2020/12/nat64-using-jool-on-ubuntu-20-04/
I found that jool has very good tutorials, but all the commands to get going are hidden in these large tutorials. Here are the steps I took to get it working on Ubuntu 20.04 on both a Raspberry Pi + Protectli Vault. Please pre-read and refer to to Jool's Documentation for more information. I have...ยป
I've lived my life on IPv4. Not much of a networking nerd fwiw
I'm actually ok @ networking, python is a side hobby that I am trying to be good at.
https://www.youtube.com/watch?v=WaCxsVUmHa8 - Done lots of silly stuffs
Had the ability to re-create my 30 levels of NAT with Juniper firewalls. So some nerds got together again and it was NAT time. NAT-Tastic.
Ugh that's fine. Sounds like a pain to turn on IPv4. I'll do what I can on Linux and Windows and think about what I should do next
No biggy. You just need me to build + run tests right?
GitHub actions can at least build x86_64 mypyc and test now? lets make an action to test mypyc?
I've been running the test suite for all of the environments supported, it's just the M1 wheels that can't be tested
.github/workflows/build.yaml lines 83 to 87
CIBW_BEFORE_TEST: "pip install -r .mypyc-support/test-requirements.txt"
CIBW_TEST_COMMAND: 'pytest {project} -k "not incompatible_with_mypyc"'
CIBW_TEST_EXTRAS: "python2,d,jupyter"
# Skip trying to test arm64 builds on Intel Macs.
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"```
Linux, Windows and Intel MacOS all run the test suite (excluding some tests that break because mocks and monkeypatching aren't supported by mypyc) during the wheel build
I wonder if I can spin up a couple machines on my host
Worst case scenario, I can write a simple circle CI or smthn
Have it deployed on all machines
Yeah it should be that hopefully. We could run benchmarks on Mac too but it's not strictly necessary and can be quite fickle to do properly. Basically setup test environment, install wheel from the workflow. run pytest -k "not incompatible_with_mypyc", and run diff-shades and compare the produced data file to a known good one from main (I'll provide it). Oh do all of that again for M1.
I really need to come up with better instructions
Can we shell script that so its all repeatable more reliably ๐
Good idea, especially since I want to invite members of the community to help out too
yes
TIL - 148 files would be left unchanged in the cpython repo ๐
nice
Didn't expect that many
probably some really small files, but still impressive
psf/black#2407
So wait, we're adding CPython to primer?
Ya ya
I'm a little bit worried at how long CI is doing to take with that
4 mins. And only on 3.9 (latest stable cpython so we can support as much syntax as possible) - I think the signal is very valuable. Already found more ESP bugs.
non ESP == 13 failed files - 16 with ESP
Ah ok that's good. Why do we run primer across multiple OSes and Python versions btw?
Well - the 4 mins is on my Mac M1 maxed out. I may well be to slow for Actions. if so, will do it in a dedicated job in 3.9 only
To find these bugs?
We've seen platform specific bugs, so running the same code across different OS's find these things.
Fair enough
- cpython tests is probably the best repo for black to test on as the stdlib's unittests should use all syntax
- Limit to running in recent versions of the python runtime - e.g. today >= 3.9
- This allows us to parse more syntax
- Limit to running in recent versions of the python runtime - e.g. today >= 3.9
- Exclude all failing files for now
- Definately have bugs to explore there - Refer to #2407 for more details there
- Some test files on purpose have syntax errors, so we will never be able to parse them
- Add new black command arguments logging in deb...
Such a small amount of code for the hours of work. I hate we use a regex for excludes personally.
But a cool POC I feel, showing we can format a very high % of cpython. Some files we'll always have to exclude, but ~10 or so there we need to dig into
@bright glacier - Worth a change log? I was torn
I don't feel users care what repos we CI on
3.9 passed but 3.10 timed out:
[2021-08-15 23:08:36,091] ERROR: Running black for /tmp/primer.20210815225821/cpython timed out (['/opt/hostedtoolcache/Python/3.10.0-rc.1/x64/bin/black', '--experimental-string-processing', '--extend-exclude', 'Lib/lib2to3/tests/data/different_encoding.py|Lib/lib2to3/tests/data/false_encoding.py|Lib/lib2to3/tests/data/py2_test_grammar.py|Lib/test/bad_coding.py|Lib/test/bad_coding2.py|Lib/test/badsyntax_3131.py|Lib/test/badsyntax_pep3120.py|Lib/test/test_base64.py|Lib/test/test_exceptions.py|Lib/test/test_grammar.py|Lib/test/test_named_expressions.py|Lib/test/test_patma.py|Lib/test/test_tokenize.py|Lib/test/test_xml_etree.py|Lib/traceback.py|Tools/c-analyzer/c_parser/parser/_delim.py', '--check', '--diff', '.']) (lib.py:190)
IMO no
Seems I read wrong. They both timed out. Will allow 15 mins, if it can't pass reliably in 15 mins I'll disable for now.
Whelp I'm never running black-primer locally (or diff-shades once I add CPython) on a whim
it takes around ~30 minutes for me to a run through all of the primer projects
You can always change the config ... I do when I play with stuff locally
Yup yep, for diff-shades I added simple include / exclude options for that
diff-shades is basically me writing my own black-primer by stealing a bunch of ideas from mypy-primer
it's designed to compare two revisions of black
Cool
I was going to use black-primer instead for my mypyc work but it wasn't ideal because primer can't easily tell you whether two revisions of black behave the same
it does a good job at testing black's stability and impact on projects as a whole BUT it just doesn't tell you a lot at a revision level
Nope, didn't have that goal in mind when I wrote it. But I'd never be upset if something replaced it and did it all if it's of value etc.
Basically this is the sort of tooling I needed and wanted.
Pretty useful to see if a change is too disruptive or changes something it shouldn't ^^
Anyway, diff-shades was thrown together in a few days so the quality of the tool ain't great but I've been using it successfully for my mypyc work which makes me happy
I gotta go for now, but I'll leave with this summary: https://github.com/ichard26/black-mypyc-wheels/blob/a6e773925ad01998be94fc2fcc5e6059c6682ca5/diff_shades.py#L413-L437
Yeah nice. That's how all good tools get started. primer can be replaced / re-written to do all this if needed.
Give up, going to be no sane way to run cpython. I limited it to Lib/* but still ~3m40s on my laptop. Not gonna happen. But I'd still like to merge the config for others to be able to use etc. if we ever want to debug the bugs it exposes.
Tis a shame. But ya never know unless you try.
Maybe we get rid of django and run cpython as the one large repo - it may work. But I think having the two large repos overloaded the i/o as I think it's running 2 at once (by default)
which IMO is not the best idea because black is parallelized anyway ^^
Yup! Thank you!
P.S. the reason why I wanted the jupyter deps in here is to reduce friction when contributing. You shouldn't have to reinstall black with the jupyter extra just to test your ipynb changes ^^
Alright, let's try again at adding the test dependencies to Pipfile.lock, hopefully pipenv behaves this time ^^
Aw crap, the weird pytz issue is still happening, gosh this is annoying
Hmm, looks like this is a known bug: https://github.com/pypa/pipenv/issues/4686
I wonder if my weird environment setup is the cause
I'm now on attempt 4 I think?
at some point
I had commits
where my message was just 5
6, 7, 8
etc
because freaking github workflows don't have custom runners to test them
a commit history can tell a story ^^
...of not being able to count
83564ec5c (HEAD -> fix-messages, origin/fix-messages) This is ugly but special-casing this test seems fine
91ac7200b Only sys.exit(1) if an error occurred + fix one warning
0367ebf89 [mypyc] Emit messages regardless if there's no errors
attempt 1
attempt 2
attempt 3
attempt 5
"attempt idk but i swear this *should* work"
that's how you make a good commit history ๐ /j
squash em afterwards
HECK YEA
pipenv didn't break the pytz dependency
damn is it sensitive to the environment tho
I had to move a virtual environment out of my CWD before running pipenv lock ๐
ugh, wth now the hashes aren't matching on 3.6
i'mma try again tomorrow, but at least i made progress :D
At my company, we set the Python version in default_language_version
in each repo's .pre-commit-config.yaml,
so that all hooks are running with the same Python version.
However, this currently doesn't work for black,
as the language_version specified here
in the upstream .pre-commit-hooks.yaml takes precedence.
Currently, this requires us to manually set language_version
specifically for black,
duplicating the value from default_language_version.
The failure mode otherw...
bloody hell now the hashes work but the lock file isn't complete
Using the lock file on 3.6 for example breaks the documentation
Gosh I dislike pipenv more and more
Oh I'm actually quite interested about this, black was one of the first projects I ever saw using poetry, why did you guys switch?
@bright glacier why are you using pipenv?
I have no idea ๐
The switch happened before I even contributed to black
Join the darkside - switch to poetry
I wonder hmm
Heh
Y'all probably aren't interested in using a full poetry build and release system, but that's why I have two branches
It's a bit outdated now, but this branch has a solid start for setting up poetry
The one that released the pypi package is poetry-build
i'm actually likely going to switch to twine for releases ๐
i must be entirely mis remembering cause i cant find poetry in the history anywhere
It's finally happening :tada:, the initial work was done several years ago in GH-1009 by @ msullivan is now being followed through by yours truly. If this work doesn't find its way to PyPI eventually, I'll be disappointed :slightly_smiling_face:
Performance
I wrote an entire report which can be read here: https://gist.github.com/ichard26/b996ccf410422b44fcd80fb158e05b0d, but the TL;DR is:
- Formatting with safety checks: 1.93x faster
- Formatting without safety checks: ...
Finally! I got my mypyc PR up, I still have a lot of work to do, but this is a major milestone 
If you need Windows testing, I can do that any time if you tell me what I'd have to do
Uh yeah, I need to come up with better instructions first as noted in the PR description first ๐
Oh I uh, apparently can't read
Haha, no worries, I wrote perhaps too much :p
I've never liked it
did pipenv solve the multi-platform problem already?
when going on windows you couldn't pipenv install because the lockfile sometimes had linux specific binaries
It had a 2021.5.29 release ... and a commit 8 days ago - So getting more action that it use to
Has > 500 issues tho. Makes me feel better about black now
tbh i think something like pipenv is inherently more prone to bugs due to its critical and highll complex natuer
Please add an changelog entry but other than that this seems fine to me. Thank you!
P.S. for added convience here's a diff you can use:
diff --git a/CHANGES.md b/CHANGES.md
index a678aae..a4b8e01 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,11 @@
- Add support for formatting Jupyter Notebook files (#2357)
- Move from `appdirs` dependency to `platformdirs` (#2375)
+### Integrations
+
+- The provided pre-commit hooks no longer specify `language_version` to avoi...
@bright glacier how do you push to a pr fork branch?
^^
import os,time
os.system('cls')
moneygain = 1
money = 0
speed = 0
cost = 10
added = 1
add = 1
ps = True
while True:
print(f'''
car speed:{speed}mph
cost to upgrade: ${cost} coins
money = ${money}
type (add) to gain ${moneygain}
type (upgrade) to add speed
''')
commands = input(">")
if commands == "add":
money += moneygain
os.system('cls')
if commands != "add" or "upgrade":
os.system('cls')
if commands == "upgrade" and money >= cost:
add += 1
speed += add
os.system('cls')
money -= cost
added += 1
moneygain += added
cost += 20
i made this game and here's the code I'm a beginner so please point out any mistakes
wdym
Write in full I'm not a English
Like you have entered text into the console many times at the speed of a car?
@verbal iron
yes
import os,time
os.system('cls')
moneygain = 1
money = 0
speed = 0
cost = 10
added = 1
add = 1
ps = True
def main():
print(f'''
car speed:{speed}mph
cost to upgrade: ${cost} coins
money = ${money}
type (add) to gain ${moneygain}
type (upgrade) to add speed
''')
commands = input(">")
if commands == "add":
money += moneygain
os.system('cls')
main()
if commands != "add" or "upgrade":
os.system('cls')
main()
if commands == "upgrade":
if money >= cost:
add += 1
speed += add
os.system('cls')
money -= cost
added += 1
moneygain += added
cost += 20โ
main()
else:
print("Not enough coins")
main()
main()```
Oh stop
oh it was a good idea
@verbal iron this isn't the correct channel for that, you should take a look at #โ๏ฝhow-to-get-help
ok
hi i have downloaded python @modern lance ping me when u have a suggestion ๐
waht do i do now?
i want to learn how to code
oof wrong channel......
you can read books sign up for bootcamps and courses i dont recommend videos. reading books are very effective
@graceful iris
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Thanks for all your work on this! I'm really excited to see this PR.
Ah yeah, didn't realize this was from an organization repository. No worries then, it's not worth the trouble even if it was technically feasible. I also didn't know that only users could permit that, you really do learn something everyday don't you heh.
Congrats on your first contribution to psf/black :tada:
ef7c45f Remove language_version for pre-commit (#2430) - aneeshusa
Right the transformer code looks at the transformer's __name__ attribute when deciding to return early: https://github.com/psf/black/blob/ef7c45f28132a7704a4549072ce5b272034fa196/src/black/linegen.py#L964-L967
This is kinda hacky and becomes quite a problem when integrating mypyc since nested functions don't keep that attribute due a bug (https://github.com/mypyc/mypyc/issues/884). The current workaround is to dynamtically create a wrapping class at runtime (via type() mind you :upside_d...
where do you find these "books" is it like online or something
Amazon.co.uk: python
I'll note that this entire topic is off topic here: but real python is a good source of free articles. they're more piecemeal like so if you prefer more structured guided learning, they might not be a good bet starting out
I'd suggest moving to something like #python-discussion.
ok
Actually this doesn't go far enough, it didn't occur to me before but we actually support nested gitignores these days, and uhm, this PR doesn't fully fix the ungraceful crash when a nested gitignore is invalid.
โฏ tree -a test
test
โโโ a
โย ย โโโ a.py
โย ย โโโ .gitignore
โโโ a.py
1 directory, 3 files
~/programming/oss/black on gitignore [$?] via v3.8.5 (bm-venv)
โฏ dropblackcache -y ; black test
no caching was found!
Could not parse test/a/.gitignore: Invalid git pat...
So wait, how many mini-projects am I running for psf/black again?
- documentation
- developer experience
- tooling (blackbench, diff-shades)
- mypyc
- this isn't really a project but I'm trying to get the PR number down too
what are the other 35?
fortunately most of them don't exist :D
yet
I already have ideas of more stuff I could do, but I really need to limit myself from taking on more
hey, I'm working on 7 projects, could you help me with 10 of them? Again, just 12 need your assistance, so join me with working on 17 projects ty
๐
yeah that's a good idea
This is in response to the ticket: https://github.com/psf/black/issues/2359
A particularly unhelpful error was thrown before, I feel this will be a lot more helpful to users trying to understand what went wrong.
Just making sure you've all seen it cause it's pretty rad - got to https://github.com/psf/black (or any github repo) and hit '.' on your keyboard (You must be logged in ...)
VSCode on demand!
And you can even have vim plugin!
No python / black plugins yet - Wonder if we can help make that happen somehow ๐
<3's VSCode
!remind 5H "look into this message re. bandersnatch #tools-and-devops message"
Your reminder will arrive <t:1629412535:R>!
@bright glacier
Here's your reminder: "look into this message re. bandersnatch #tools-and-devops message"
[Jump back to when you created the reminder](#black-formatter message)
!remind 16H "Further think through the idea of doing open-house style mentorship via PyDis, xref #ot1-this-regex-is-impossible message"
Your reminder will arrive <t:1629485233:R>!
Describe the style change
Sometimes you need to access attributes deep within another object or with extremely long names, and Black helpfully tries to wrap the right hand side of the expression to avoid blowing the length limit, but doesn't touch the right.
Examples in the current Black style
(
something.something_else.hideously_long_attribute_name.other_property.even_deeper.finally_getting_close.okay
) = 1
Desired style
TBH I always thought some of the purpose of blackd was to support configuration rules throughout an organisation without having to put the configuration on every repo
SAME ICON
@bright glacier
Here's your reminder: "Further think through the idea of doing open-house style mentorship via PyDis, xref #ot1-this-regex-is-impossible message"
[Jump back to when you created the reminder](#black-formatter message)
Ah yeah the mentorship thingy
@dense jungle I'm reviewing PR psf/black#2414 for what is hopefully the last time. I'm pretty likely to approve and merge, but I wanted to let you give any feedback first.
Well, actually I guess we do have two PRs to consider. I prefer this one mostly because it hides away the traceback (which can be scary!) but that's just me.
Thanks for the quick update!
Hmm, re psf/black#2412, I suppose the docker image we provide does fall under usage and configuration but it doesn't sit well with me.
Thinking about it some more, the current location could work especially since we probably want to document the OS native binaries we also provide. A "Alternative installation" (please bikeshed this -- it's horrible :p) document could easily work.
let's land it. The other PR seems less thoroough
Awesome, I'm happy to see the PR count go down ^^
Also I get to +1 my closed issue count so hooray ๐
oh no you're going to beat me
...
brb creating 41 spam issues on psf/black (/s ofc) ๐ผ
104aec5 Present a more user-friendly error if .gitignor... - nipunn1313
Awesome to see more automation come alive -- love it! Thank you!
I'm using codespell to check my documentation changes now, so hopefully Jelle won't catch as many dumb typos these days :p
Ooo I should run diff-shades on psf/black#2278. I'm stil working on a markdown output but this PR should be a good experiment into whether it serves its mission as a mypy-primer for black well enough.
Haha, you know that repository is quite active when CI is maxed out. Some jobs are in queue right now :p
Good timing as I got to go now for the time being ๐
Describe the style change
Black does not currently clean trailing whitespace. This is strange, and does not jive well with any major Python linter I can find (say Pylint).
Additional context
The only reason I can think of to not do this now is backwards compatibility.
If ticket isn't immediately closed for being annoying to the dev team, I would happily implement it.
Thanks.
TBH because I have
- id: trailing-whitespace
``` in my pre-commit config *and* have my editor set to trim trailing whtespace before save I've never noticed it
heya, I'd appreciate reviews on the following PRs:
- psf/black#2416 "document jupyter hook" (this one is the lowest priority since it looks OK to me)
- psf/black#2412 "Docker image usage description"
- psf/black#2384 "Stop changing return type annotations to tuples"
- psf/black#2278 "Parenthesize conditional expressions"
RE. psf/black#1574 I think the best course of action would be to actually stop suggesting stable as much as possible and instead specify the current latest version. We can extend the script PR 2416 introduces that checks if the pre-commit rev value is correct to cover these cases too.
Whelp, I was going to run diff-shades against the "Parenthesize conditional expressions" PR but it turns out diff-shades needs a lot more development before it's CI ready
While I like the changes for the most part, the fact we don't hug brackets is really bothering me
just feels like a lot of whitespace
hm
side note: anyone know of a toml formatter because my whitespace is wild in those
param = [
- processors[key](compiled_params[key])
- if key in processors
- else compiled_params[key]
+ (
+ processors[key](compiled_params[key])
+ if key in processors
+ else compiled_params[key]
+ )
for key in positiontup
]
eg. feels a bit wasteful here
assert db_request.route_path.calls == [
- pretend.call("manage.project.roles", project_name=project.name)
- if desired_role == "Owner"
- else pretend.call("packaging.project", name=project.name)
+ (
+ pretend.call("manage.project.roles", project_name=project.name)
+ if desired_role == "Owner"
+ else pretend.call("packaging.project", name=project.name)
+ )
]
ditto
- psf/black#2278 "Parenthesize conditional expressions"
like there's a lot more cases where IMO it improves things, but the above two don't sit well with me, OTOH there's this:
- lambda tab: tab.c.q.in_(vv)
- if tab.name == "t1"
- else tab.c.q.in_(qq),
+ lambda tab: (
+ tab.c.q.in_(vv) if tab.name == "t1" else tab.c.q.in_(qq)
+ ),
which is a massive improvement
otoh?
on the other hand
- value="singular%d" % ii if ii % 4 == 0 else None
+ value=("singular%d" % ii) if ii % 4 == 0 else None
ok this one is just cute even tho I don' think it's necessary :p
side note: does jelle work for quora?
IIRC yes.
given that https://github.com/psf/black/pull/2278#pullrequestreview-702596888 refers to https://github.com/quora/pyanalyze which is part of quora, idk. Ofc they also don't have the collab or member badge so idk
edit: but they do have push perms so
You can hide your membership in an organization ^^
true, but it typically will say collaborator regardless of that
It won't actually
huh, possible til
Take a look here: pypa/bandersnatch#980
Cooper and I are both maintainers, but his membership is private and mine isn't
Cooper probably says "contributor" for you, no?
that pull got me on a sidetrack to fix my own ci
.github/workflows/ci.yml line 12
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository```
.bm
i swear
Probably need --profile black then
already is there--
are you
TIL
in the tox.ini file
if its profile = black it actually means nothing
it has to be profile=black
And one more reason why I hate INIs ^^
brb making a commit to protected main to fix this
because
yeah
also
king-arthur#2
i am a bad tester; it is still not working
strangely
the line lengths are configured the same
and yet, they're fighting
How so?
isort:
from modmail.utils.threads import (
Target, ThreadAlreadyExistsError, ThreadException, ThreadNotFoundError, Ticket, is_modmail_thread,
)
black:```py
from modmail.utils.threads import (
Target,
ThreadAlreadyExistsError,
ThreadException,
ThreadNotFoundError,
Ticket,
is_modmail_thread,
)
Oh that looks like the magic trailing comma thingy, IIRC there is an issue on the isort tracker about this, lemme find it.
nice thing is if I remove the trailing comma isort puts it back
pycqa/isort#1683
well
lmao
solution: remove some of these imports since flake8 complains about them anyways
(since they aren't used in the code)
tl;dr currently doing a refactor of this file into multiple files since it deserves them
I just finished doing like the 6th? pipenv lock trying to add the test dependencies to the lockfile. I think the lockfile shouldn't be broken this time but I still need to test it.
I literally had to 1) do a clean clone of psf/black, 2) create a Python 3.6.12 virtualenv, and 3) rm Pipfile.lock before locking so it wouldn't misbehave. Lovely.
...why are you not trying to migrate to poetry or smth?
I might look into that soon, but this is probably still less work than moving to poetry.
Does poetry support custom build scripts like setuptools' setup.py?
If not, it will be a very unpleasant experience packaging up a Rust, C, and Python distribution.
Unless there's good plugins for that, but IDK.
its in alpha or beta or something
