#black-formatter
1 messages Β· Page 29 of 1
I don't have any and popcorn is kinda meh tbh
sounds like something a guy without popcorn would say out of spite π
.<
ok lets argue about this now
popcorn is good
have you seen the reddit pot where a person popped an ear of popping corn in the microwave and it popped all over the popping place
towncrier does have the history going for it too, meaning a more mature tool
finding many black formatters for jupyter notebooks. is there a "best" one? is black wrong for that context?
Black supports that natively
ohh i see. sorry for missing that
Describe the style change
Black is not consistent when arguments can be many types.
This is the original format, both stat_lengthh and stat_lengths have the same typing but one has parenthesis around it:
from __future__ import annotations
from typing import Any, Mapping
class test:
def pad(
self,
stat_lengthh: (int | tuple[int, int] | Mapping[Any, tuple[int, int]] | None) = None,
stat_lengths: int | tuple[int, int] | Mapping[Any,...
To Reproduce
With this as test.py,
with (
open('a') as f,
open('b') as g,
): pass
Black with fail with --safe (the default) but pass with --fast
% black -t py310 test.py
error: cannot format test.py: cannot use --safe with this file; failed to parse source file.
Oh no! π₯ π π₯
1 file failed to reformat.
% black -t py310 --fast test.py
reformatted test.py
All done! β¨ π° β¨
1 file reformatted.
% cat test.py
with (
open("a") as f,
...
Haha, current main supports sqlalchemy again: https://github.com/sqlalchemy/sqlalchemy/pull/7536 | @neon loom shall we add it back?
Sure. Itβs a solid sized code base.
i thought you said shall we add it black
I'm currently trialling adding diff-shades to the mypyc wheel build workflow so before I push 'em to my personal index I'll be even more confident in their stability.
personal index
wat
a free index?
GitHub pages
vercel is always there :D
I was trying to work on psf/black#449, I basically need to do target = (another == variable) right? at least that's what i get from the convo
Yeah that's what it's asking for. Honestly I don't find the case for it very strong though
yeah its "good to have"
was easiest to get me started with the formatting section of the code, so picked it up
@errant barn seems like vscode still uses MagicPython
I was kinda hoping you'd attach some words on that review Jelle so I would have somesort of response for my most recent post haha
It's unfortunate that the diff-shades integration ended up being so complex. I've been staring at the diff looking for ways to simplify it but other than removing features I don't see anything.
Oh, as I just wrote that I saw a code feature that doesn't need to exist 
hundred times out of ten this is what happens
ask someone else/mention it publicly, suddenly solve the problem or find something
I don't undertand this https://github.com/psf/black/issues/2766#issuecomment-1011784984, using towncrier/modmail-changelog/blurb would be much easier than the current workflow
you just run one command, and it opens a editor for you to write the changelog
you save and exit
and done
cc @neon loom
Here's your reminder: ||how was your first paper π||
[Jump back to when you created the reminder](#black-formatter message)
@mint barn what's up with the random block of code?
Please stick to the topic of the channel.
Was attempting the parenthesis issue a = (b ==c), here is what i have come up with, am i going in the right direction?
# yes
match_count += new_value == old_value
# no
if on_windows := os.name == "nt":
...
# yes
on_windows: bool = (os.name == "nt")
# no
name1 = name2 = name3
# yes
name1 = name2 == name3
# no
name1 == name2 == name3
# no
check_sockets(on_windows=os.name == "nt")
the test file
Nice, "yes" meaning parens will be inserted?
yeah
honestly I'd expect if a := (b == c):
but apart from the fact that you probably could delete the identity callable assignment from LineGenerator, I'm still not quite familiar with the transform code :D I'll trust tests
nor am I, i somehow figured this out
even I was wanting to have that (walrus statements), but it wasn't included in the issue
i already have the code for that ready, one line change :)
let's ask the others though
also, wdym by
could delete the identity callable assignment from LineGenerator
yeah
ah yes
got it
visit_expr = visit_expr doesn't really do anything
oh, in that case, carry on
π
i should probably move the expr check to linegen class
seems more relevant
And what import format do we follow, single line or we can add brackets if it is going above line length and continue it in tuple format, because currently its mixed up in the code?
yeaaah, sec I'll check how the py2 remove ended up
k
β€οΈ π€
yes yes agreed
I haven't dealt with primer much, but this is the second time in a short period where tests have failed because changes are expected, while tests on main succeed. If anything I'd expect it to be the other way around. Am I doing something wrong?
(psf/black#2297)
so you're telling me that fr" " is not French strings???
if by French you mean backwards then yeah 
Fun fact: you can write rb"x" to embed a Ruby string in Python
@dense jungle do you have time for a bit of senior help?
sure, I'll take a look
I know I also need to get back to you on the --preview flag, hopefully later today or tomorrow
Nice, but no worries, things are steadily progressing!
I suspect it's because we run poetry with ESP on in primer, and https://github.com/python-poetry/poetry/commit/ecb030e1f0b7c13cc11971f00ee5012e82a892bc just fixed a bunch of things that ESP would change
black-primer starts failing every time the third-party project changes code so that it stops or starts formatting as expected, which in my opinion is... pretty useless
can't wait for diff-shades with more sensible behavior
Right, makes sense π I was worried because the first run succeeded but the revert didn't
They just made themselves ESP-compliant in https://github.com/python-poetry/poetry/commit/ecb030e1f0b7c13cc11971f00ee5012e82a892bc
Sweet. Blackened poetry in motion.
The first Primers succeeded, push da button π
DAMN
All looks good to me. I'm looking forward to this normalization. Thanks!
799f76f Normalise string prefix order (#2297) - felix-hilden
fun fact: black can parse f'{...:=0}' and f'{x.y:=0}', but not (...:=0)
f'{0=:x}' - inverse walrus operator for x:=0 π
>black -c "a** a"
a ** a
>black -c "a**a"
AppData
```what?
that's probably shell globbing
>echo -c "a**a"
-c "a**a"
That seems correct, it's valid f-string syntax but not valid within parens
>black -c "*"
"ntax"
>black -c "*a"
AppData
>black -c "a*"
a.out
``` my shell is absolutely broken
The last two make sense if it's case sensitive
Okay, style question
Which looks better:
x: Union[int, float, str] = None
# or
x: int | float | str = None
second
it is shorter and cleaner
And I can do that by importing from __future__ import annotations for older versions, right?
yes
I mainly ask because I wonder if there's a setting I can set in black where I can force it to do these things
from version 3.7.0b1
No, Black wouldn't make these changes since they're not AST-safe. There are other tools (pyupgrade I think?) that can make these changes
What does AST-safe mean?
Black (with a few exceptions) only makes changes that leave the Python abstract syntax tree (AST) the same
This ensures that formatting a file with Black won't change its behavior
the main case where we make AST-unsafe changes is in docstrings where we normalize whitespace; that changes the AST because string literals are part of the AST
that makes sense, thanks!
Wait, do we want to skip looking for configuration if code is passed? https://github.com/psf/black/blob/main/src/black/__init__.py#L416
src/black/__init__.py line 416
root, method = find_project_root(src) if code is None else (None, None)```
Nvm we read it anyway but just elsewhere π
what is black?
The channel description will answer that ;) tl;dr Python autoformatter
why is there a channel like this?
trying to think of a way to structure this
read the first pinned message xD
but essentially i'm trying to automatically generate some code files based on other aspects and i want it to be formatted with black
i want it to use the black cache but it doesn't seem like it uses it for stdin... although even if it did that would still be a problem
Oh, ok. I was also working on another open source project I wondered if I could open a channel for my project as well
i'm formatting around 115 files π
Cool! But not likely to happen here, I think. It'd have to be quite a notable project I imagine
The cache is based on filename + mtime, right? That doesn't make sense for stdin
true
I guess i was wondering if it could cache the input and know that xx is going to be the output
maybe i should write my own cache for this script
That doesn't seem like a good idea for Black, we'd have to store the whole source code on disk for every stdin invocation
of course it could make sense for your use case
ye, these are tiny, roughly 50 line files, mostly filled with imports and a license
so I'll probably just write my own cache ooooorrrrr
its quite simple that I think I can skip using black at all by just changing a few things
π€ is it possible to make black ignore the left?
i solved this
and didn't even add a cache
You'll want to ask the admins in #community-meta but it's unlikely any OSS project would be accepted, even major single maintainers project like rich aren't in scope as the interaction between maintainers is a crucial bit.
I'm trying to mentally sort out what we want to do diff-shades wise handling the --preview flag, I think passing --preview to all runs except for those triggered manually (since they allow args to be configured) is what we should do. After all we're curious about the impact of a change as if it was enabled.
I think you suggested somewhere having a separate run for non---preview that checks there are no changes, that seems useful to me
Yeah that too, I was more talking about the --preview workflow as in which events should it use --preview for. Sorry that was unclear.
The last thing I'm worried about is that the current implementation only posts one comment on the PR, updating it on subsequent runs (I'm not a big fan of the visual or notification noise). It is possible confusion could spring up in the time where a new run was triggered but it hasn't finished. I know the mypy folks started out with the same thing but then moved to always posting a new comment so what do you think Jelle?
This is main reason why the revision SHAs are embedded in the comment but that's hardly a noticeable way realizing the comment is (temporarily) outdated
hm that could be confusing if iteration on a PR yields new changes that you'd want to look at
on typeshed the workflow collapses comments it posted previously which is nice
though honestly the main thing I want is that we land diff-shades π
we can always iterate further on things like this
It's a very simple change fwiw, so it doesn't matter from a technical standpoint
well until you want to hide all of the previous PR comments but I'm sure I could steal whatever mypy is using
I think we use some third-party action for that
.github/workflows/mypy_primer_comment.yml line 43
- name: Hide old comments```
I don't hate javascript but inline code is never fun in a YAML file IMO
typeshed uses a third-party action: https://github.com/python/typeshed/blob/master/.github/workflows/mypy_primer_comment.yml#L70
.github/workflows/mypy_primer_comment.yml line 70
- name: Hide old comments```
Security I suppose? guessing from the comment in the mypy one
not sure, on typeshed it's pinned to a commit so that should be fine
we could pin the two third party actions used in diff_shades_comment.yml actually now you mention that
good idea
I never understood why JavaScript's package lock files end up half a megabyte or more big
https://raw.githubusercontent.com/peter-evans/find-comment/d2dae40ed151c634e4189471272b57e76ec19ba8/package-lock.json seems unauditable in every manner possible
I mean, the dist/* folders already make it hard to audit but I digress :/
I know the proper secure thing is to fork the action and rebuild everything from source but I'm just surprised this is how JS works ..
upgrading dependencies on a big JS app is awful
Even build tools are being targeted like in that semi-recent Solarwinds attack IIRC so it's rather scary these days
hi
bump :D
Why is this False? I am doing print(node, is_walrus_assignment(node))
ok earlier implementtion didn't work on everything
i want a piece of code to be ran on all types of statements, so where should it go?
like wrap_equality_check_assignment_expression needs to be ran on all stmts which contain walrus/are assigments
it only works till the comparision is in the first level
I know the transformer based formatting infra works for this requirement but there's no AST information whatsoever, all you have to work with is a list of tokens per line which sounds quite annoying to get right.
perhaps black.linegen.LineGenerator.visit_default would make for a good spot?
and actually now I mention that I wonder if I could use this instead my somewhat sketchy token based implementation of the power op PR
for some reason my brain thought we couldn't use the visitor infra for that PR but it mayyy be possible to use it which make it a lot less hacky
yeah that's what i was thinking
although I have no experience with the visitor code fwiw
currently i basically just go inside the list of node.children digging for named_expr or expr_stmt, is there a better way to do this?
You tell me
if i knew, i wouldn't have been asking 
because walrus
wait a second, do whitespace changes by the visitor get ignored?
@plain atlas :white_check_mark: Your eval job has completed with return code 0.
posix
I don't remember my point actually
so hi hope y'all well I need to work on more automation
if that's walrus it should true, but the current util function only checks for walrus operator at the very top level, just node.type == syms.named_expr, so it only work on stmts like a := b ==c
yup they do get ignored
def is_walrus_assignment(node: LN, check_all: bool = False) -> bool:
"""Return True iff `node` is of the shape ( test := test )"""
if check_all:
if node.type == syms.namedexpr_test:
return True
for child in list(node.children):
check_ = True if isinstance(child, Node) else False
if is_walrus_assignment(child, check_):
return True
# None of the children, grandchildren, etc. are walrus assignments
return False
else:
return node.type == syms.namedexpr_test
``` i upgraded it to this so it works rn
It'd be great if we had a internal APIs docs (not for users, but contributors) tbh
but writing such docs is hard when even maintainers don't really fully understand the code π
Εukasz still knows the formatting code the best
there is one?
no, I was saying we should make one
no, there is one (period)
yeah, it would be very very helpful
like "welcome to black's codebase, here's what X, Y, Z does"
"let's walk through an example change of black's formatting code"
def wrap_equality_check_assignment_expression(node: LN) -> LN:
for child in list(node.children):
print(child, [key for key, value in syms.__dict__.items() if value == child.type])
if child.type == syms.comparison:
first_child = child.children[0]
if not is_lpar_token(first_child):
wrap_in_parentheses(node, child)
print("-----------\n")
return node
``` this is what i currently do, but it checks only at the top level, so i was thinking of making this a recursion sol like the above one, but that would make it a bit hacky, so not sure if that would be the best
that's hardly helpful, it's too low-level if you're new to the codebase IMO
could you add a visitor method that handles comparison nodes?
umm, let me see how i can do that
you should be able to just define black.linegen.LineGenerator.visit_comparison, no? It seems to work although I have no idea what is the contract for visitor methods so don't ask me what it should yield
i can, but i need to add some logic for making it detect it is a eqequal comparision
It's less nesting though and that's what you were looking for, right?
you don't have to check for nested comparisons as the method will be called on 'em too assuming you don't break any contracts
For the record, I don't think this design issue was ever approved as it received lukewarm reception by the maintainers of the time
in general getting approval before working on a change is recommended but alright
On first glance I like the formatting change but I'd have to think it through more and see the impact on actual code (cue diff-shades integration)
actually yes that would work
wasn't it approved on a = b==c?
well OK, this only applies for enhancements and design issues, documentation and bug issues are always fair game
any thoughts on https://github.com/psf/black/pull/2744? I might merge it
Ah OK I see what you mean, https://github.com/psf/black/issues/449#issuecomment-413978953
and typos
yes ik those fit into the rest but where would I be without my precious one liner pulls
hmm, seems like the original proposal was indifferent to what comparison it was?
So, here's an concrete proposal: when the top node of the AST for the RHS of an assignment is in the set: ==, <=, >=, <, >, !=, then surround the RHS with parentheses to make sure it's not confusable with chained comparison or chained assignment.
although it's not clear what Εukasz approved
because it shouldn't be doing the changes on others
yea I know, I deleted my message because I hit me
smh don't hit yourself
hm it seems a lot less confusing to write x = a > b than x = a == b
yea, but the post he responded to only applies a special case for equality checks
ah yes, that's why i was wondering where i read to only apply on ==
oh dear there goes my inbox again
got to do something with that commit access
hmm I just thought of another potential edge case
why is the real world always so damn complicated >< /lh
nope, it isn't a problem thankfully
ugh, there was one last thing I wanted to do for the diff-shades integration but it fell out my mind
fast because I'll merge the PR soon π
LOL, you know I'm a π’
also we should have mypyc on by default for the release, right?
Yeah the goal was to release a RC with mypyc by default which makes me scared but I'm integrating diff-shades into the test phase of the wheel build to feel a bit less scared
OK, I remember now! it only took looking at the diff
wait a second, I already did the change but I skipped over it reading the line of YAML 
hmm, how do i figure out if the comparision was part of a expr stmt?
why? does the location matter? I thought just whether the parent was a wulrus / assignment stmt did?
expr stmt is assignment stmt and that's what i want to check
That's not any clearer to me
well now we are getting all comparisions, whether it is part of a assigment or walrus, so i need to check whether it was part of it i.e. if the parent is namedexpr_stmt (walrus) or expr_stmt (assigment)
Oh, would node.parent in (syms.namedexpr_stmt, syms.expr_stmt) work?
node being the node argument in visit_comparison
I'm not sure if this is always gonna work though, the blib2to3 AST shape is quite weird with complex nested structures
that's what i thought but its not the case, if the comparision was in a expr_stmt the parent should have been expr_stmt but its not
for namedexpr_stmt, it works
as the parent is of type namedexpr
see the screenshot i posted above
will mention it once this is done
ah I see
file_input
simple_stmt
NAME 'a'
EQUAL ' ' '='
atom
LPAR ' ' ''
power
NAME 'x'
DOUBLESTAR ' ' '**'
NAME ' ' 'y'
/power
RPAR ''
/atom
NEWLINE '\n'
/simple_stmt
simple_stmt
NAME 'b'
EQUAL ' ' '='
atom
LPAR ' ' ''
hmm, check the parent of the parent? that does feel a bit fragile though
i could go into parent's parents and check siblings but that's gonna make it a bit hacky
lol yeah
By the way you know of DebugVisitor right?
nope
diff --git a/src/black/linegen.py b/src/black/linegen.py
index c1cd6fa..1cd83d8 100644
--- a/src/black/linegen.py
+++ b/src/black/linegen.py
@@ -39,9 +39,11 @@ class CannotSplit(CannotTransform):
"""A readable split that fits the allotted line length is impossible."""
+from black.debug import DebugVisitor
+
# This isn't a dataclass because @dataclass + Generic breaks mypyc.
# See also https://github.com/mypyc/mypyc/issues/827.
-class LineGenerator(Visitor[Line]):
+class LineGenerator(DebugVisitor[Line]):
"""Generates reformatted Line objects. Empty lines are not emitted.
Note: destroys the tree it's visiting by mutating prefixes of its leaves
try it :)
it's pretty useful when trying to understand the mess that is the AST structure
oo waves, nice i like it
I recommend using --fast with it to avoid the duplication
Honestly I'm no where closer to understanding psf/black#2525
The layers of indirection mixed with user and project level configuration break my brain
docs didn't help?
no
welp i will see if i can make it simpler
I posted a suggested docs rewrite for what it's worth
I don't think the docs are really the problem, it's just the concept doesn't fit my brain well
though I didn't think about user-level config
yeah i saw that jelle
one quesion before we go into that pr, what does annassign statement correspond to?
an example would help
a : int = 1
thank you @bright glacier !
awww I was gonna push a change lol
I'll do it later since it's highly likely something will need to be fixed anyway since this is the first real time using it in psf/black :)
it's my pleasure!
Do you want write access to diff-shades Jelle?
ok this works π
# yes
match_count += (new_value == old_value)
# yes
if on_windows := (os.name == "nt"):
...
# yes
on_windows: bool = (os.name == "nt")
# no
name1 = name2 = name3
# yes
name1 = (name2 == name3)
# no
name1 == name2 == name3
# no
check_sockets(on_windows=os.name == "nt")
# yes
if a := (b == c):
pass
# yes
a = [y := (f(x) == True), y ** 2, y ** 3]
# yes
a = lambda line: (m := (re.match(pattern, line) == True))
test
I thought there was a helper to wrap nodes in parentheses?
it worked with nodes to leafs/nodes
here the children are leafs
that's what i understood
i may be wrong
also isn't children a property / attribute, why are you turning it into a list?
they are a list
if condition:
wrap_in_parentheses(node)
yield from self.visit_default(node)
```?
src/blib2to3/pytree.py line 265
self.children = list(children)```
OH, wrap_in_parentheses needs more than just the node
yeah
why are you converting the list to a list then?
umm i could use node.insert 
one sec
that would be ```py
node.insert_child(0, lpar)
node.insert_child(-1, rpar)
do Leaf object have parents? btw
huh, weird the initializer doesn't have an argument for that then
even node initializer doesn't hae argument for its parents π€·ββοΈ
oh no, that made it into
match_count += (new_value ==) old_value
rich diff π
Eh, I'm indifferent, I don't consider it that important
its not, but its nice
wow, node.insert_child(len(node.children), rpar) works
sure! can't promise I'll contribute much though
Yeah no I'm still expecting I'll be the lead contributor but just in case I ever get hit by a bus it'll serve a backup solution
sounds good!
I was about to hit merge on https://github.com/psf/black/pull/2752 but saw that you want to review π
though I suppose worst case y'all could fork it and then update it that way but like that's annoying π
ok after adding a file in test/data it would automatically be tested right?
or do i need to add a test
you'll probably have to add it to the SIMPLE_CASES list in tests/test_format.py
alright
a = b in c and b == d how should this be formatted?
imo i like it as it is
agree
well you seem to misunderstand the workflow so I responded
Yeah diff-shades is indeed slow right now, parallelization is an option but wouldn't scale well if we introduce other diff-shades workflows
could it use mypyc-compiled black for the baseline?
the baseline is cached but yes this could help cold runs
I assume it's mostly Black running
I doubt much time is spent in diff-shades unless @bright glacier did something silly
how long does it take to compile black?
I suppose I could add project groups to diff-shades so the main --preview diff-shades workflow gets the whole selection while the others don't to address the too many jobs issue
*on gha
Yeah, there's a little bit of overhead cloning and setting up the projects (2-10%) but most of it is spent in black.*
I guess one option to compile the baseline/target revision on GHA before running it against the projects
1-2 minutes depending on OS
that's why i asked how long does it take to compile
then hell yeah try compiling it before running it against the projects
oh yeah, that might be a win then. I assumed compilation would be too slow to make it a good idea for the target
If it was 5 minutes it wouldn't be worth doing since mypyc hasn't achieved more than 2x speed ups. A typical interpreted run takes 8-10 minutes
ah these above runs aren't typical?
these are the runs of diff shades on the main repo
sorry I mean diff-shades run
each workflow run does two, one against the baseline (assuming there was no cached analysis to reuse) and one against the target
me
actually, I take this back as we do also need to install clang IIRC
unless the linux images come pre-installed with it which would be amazing
I should go check an actual wheel build for the exact timings
https://paste.fuelrats.com/axuvasedus.py looks okay?
do you need a specific clang?
I don't know honestly
well you got three
locally I've been using clang version 10.0.0-4ubuntu1
so safe
I did consider building black with mypyc in the integration but the mypyc wheels were still IMO unproven ... but then again apparently Jelle has been using 'em without issue at Quora
a = lambda line: (m := (re.match(pattern, line) == True)) not really sure about this though
i kinda like it without the brackets on ==
yeah and there's no sane way of describing such an edge case in the docs
Haha, it's mandatory that I compile black before running diff-shades locally, if I don't the run will take 30+ minutes π¦
compilation takes around 3 minutes on my machine so since a compiled run takes 15 minutes, I end up with a net savings of 12 minutes
and if you're talking about pre-compiled black for the baseline which I think you are, that's not really possible for PR runs (which is where performance is the most important) as the baseline is main not some version on PyPI
Right, but don't we build mypyc wheels for every commit to main?
Nope, ichard26/black-mypyc-wheels is a manually triggered workflow
I've been meaning to add a workflow to psf/black to cover this gap but we're tight on CI resources. And even if we do this, it has the problem of where we'd put the wheels for short term storage
mypy-mypyc-wheels does this and creates a GH release for every commit to mypy
they have a bot triggering it though no?
not sure how it works
One way would be upload the wheels as a single zip artifact, then do a GH API lookup of the baseline's wheel build run, download that artifact and unzip and point pip install at it with --find-links but that's rather involved π¦
We could emulate this by using ambv's blackrelease GH account using a PAT to trigger the workflow on a repo under that account from psf/black
:blink:
The common thread of all of these potential solutions is that they're so damn complicated though
I'll fix the PR comment functionality and compile the revisions in-run tomorrow, we can evaluate the performance win and then go from there as in-run compilation is relatively simple.
ichard, on changelogging: I am indeed a bit wary of adding more complexity to this domain.
also ichard: lets upload the wheels as a zip artefact then use GH to look up the baseline wheel run, then download that artifact to unzip and point pip at it to install the package
look all in the name of performance
but yes I don't like it either hence this:
I'll fix the PR comment functionality and compile the revisions in-run tomorrow, we can evaluate the performance win and then go from there as in-run compilation is relatively simple.
well in that case lets use swarm processing on github actions by making a matrix workflow
ofc this isn't fully supported so we probably need to use a gitlab actions runner with a PAT in order to orchestrate the jobs to the distributed github action workers
I now realize CI resources would make for an excellent donation opportunity to OSS
i could possible check if there is already bracket around the operator/the walrusssssssssssssssSSSSSS?
oops
key got stuck
should i just leave those parens and add no extra logic? or just ignore that case like don't do anything in such cases
Closes #449
Checklist - did you ...
- [X] Add a CHANGELOG entry if necessary?
- [X] Add / update tests if necessary?
- [ ] Add new / update outdated documentation?
felix is super fast π
always lurking
lol, it didn't fit so deleted it
you must have also seen i requested your review on 2525
same
someone requested a feature somewhere and I responded with a pr π
you are next level
also i need your inputs as a user on the test file
does it look okay
no I can't look at test files rn
I just spent two hours fixing something that I thought worked and then I wrote a test file for it
sadly I'm not that quick with reviews :D emotes are much easier to speedrun
no need to be quick π lol
well primer failed as expected
what do you about such changes, which cause changes on the primer repos?
you can mark them as expecting changes in src/primer/json
Describe the bug
I created a file with "# fmt: off" and no matching "# fmt: on" and black suffered an internal error.
To Reproduce
Run black on this file:
def foo():
# fmt: off
pass
def bar():
pass
Example run on my computer:
(base) β ~ cat demo.py
def foo():
# fmt: off
pass
def bar():
pass
(base) β ~ black demo.py
error: cannot format demo.py: INTERNAL ERROR: Black produced code that is not equivalent to...
Hi guys,
I'd like to know if Black can do this :
project_count = fields.Integer(
compute="_compute_project_count",
string="Number of lots",
store=True,
)
project_count = fields.Integer(compute="_compute_project_count", string="Number of lots", store=True)
run it with --skip-magic-trailing-comma
and maybe a long --line-length
[tool.black]
line-length = 99999
skip-magic-trailing-comma = True
Like this ?
skip-magic-trailing-comma = true is the spelling in the toml
It did not work, (only on method)
Maybe because it's a special statement from a frame?
No, that should work. Feel free to report a bug on github
On the other hand the reverse works if I do not put the line-length
project_count = fields.Integer(compute="_compute_project_count", string="Number of lots", store=True)
project_count = fields.Integer(
compute="_compute_project_count",
string="Number of lots",
store=True,
)
df
why doesnt black work with code that contains match?
im using latest version
installed with pip install black
you need to pass --target-version py310 explicitly
I'm pretty sure there's a hint for that in the error message when it fails, did that not show up for you?
there werent any errors
oh you mean when i actually run black
yeah now that i run it manually i see the message. normally my ide does it and hides output
thank you
Wait, does black need typing_extensions on Python 3.10? IIRC typeguard is the newest typing feature we use and it was added in 3.10
probably not no
Alright I committed a fix to the diff-shades-comment workflow and also added mypyc, I'mma test it out on my fork. Hopefully there's a runtime reduction π€
Description
As noted on Discord by @ichard26
My bad for bumping typing-extensions in the Jupyter PR without making it conditional on the Python version, so here's a PR to rectify
Checklist - did you ...
- [ ] Add a CHANGELOG entry if necessary?
- [ ] Add / update tests if necessary?
- [ ] Add new / update outdated documentation?
we should probably add autocancelling on workflows so at most one run exists per workflow per PR cause right now there's 4 test workflow runs queued π
hmm I was wondering why the C build was so faster in the manylinux docker images, apparently those use clang version 3.4.2-9 from 2014 lol
I suppose clang has gotten a lot more optimizations since then
ah, sorry, I'll be more careful next time
I there's autocancelling in pandas though, I'll take a look
yeah here it is https://github.com/pandas-dev/pandas/pull/41962/files
One slight issue is that this uncovers the annoying issue where PRs from upstream won't get the whole suite of checks ran because we use the push event on such PRs (to avoid mostly duplicated checks)
later amended to https://github.com/pandas-dev/pandas/pull/44682/files
just out of interest, why do PRs from upstream? doesn't everyone do PRs from their own branch?
In other words:
- X pushes to psf/black on branch ABC
- X opens a PR
- all of the workflows on the pull_request event are skipped
- X pushes another commit that only changes the docs
- the PR doesn't get the test workflow (nor other important) ran because they have a filter files configuration (and push events don't take into account previous changes)
sorry I mean PRs from branches on the same repo
.github/workflows/test.yml lines 16 to 21
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository```
This has already caused some confusion and I suspect it's only a matter of time before we accidentally merge a PR that fails the test suite but we don't notice
hm could we solve that instead by not running CI on non-main branches on the upstream repo?
Yeah that's what the diff-shades workflow does but my gut reaction was that some co-maintainers wouldn't like that
I guess we could put it up for a team vote π
(and canceling the push runs in the workflow itself is possible but is far from ideal since 1) the checks box gets spammed with 50% cancelled statuses, and 2) that generates a GH notification to whoever triggered the workflow)
It's pretty surprising GitHub doesn't provide a native way of doing this since it'd save CI resources on their end
Description
- Pins third party actions to a specific SHA to reduce supply chain risk
- Adds a concurrency group to diff-shades so quick pushes to PRs with little time in between doesn't end up running diff-shades only to overwrite the results soon after repeatedly
- Compiles the baseline/target revision w/ mypyc to hopefully see runtime reductions
- Fixes the PR comment bug (hence why this is from my fork and not a branch here)
Checklist - did you ...
- [x] Add a CHANGELOG...
So I wasn't able to actually test out of the performance characteristics on my fork because the cache only contains a single project and clearing / working around the cache was annoying.
[23:47:02] channel finished as failed
well that's concerning
OH YEAH I FORGOT THERE IS A MYPYC incompatibility in the codebase >.<
Quick question, is it really worth fuzzing PRs? I feel like it might to be better to separate out the fuzz test into their own repo which then runs them on a schedule against psf/black main
Fuzzing does help to discover issues with edge case-y inputs and that could be useful for PRs but we aren't even using it for that purpose right now as we've configured it to be deterministic apparently?
well, mypyc is still broken for some reason even after pushing my fix that's been laying around
it could be helpful for PRs that change formatting, right?
Probably
right right, baseline is going to be broken regardless because the fix doesn't exist on main, target is fine
hmmm, one thing with compiling the baseline/target revisions is that not all revisions are guaranteed to work with mypyc which could be a problem with workflow_dispatch where you can choose whatever revision you want
but from now on all of main should work with mypyc, right?
it's probably fine as we probably won't use it on old revisions but yeah
yes
adding it as part of diff-shades certainly means this is a requirement from now on π
yeah it should be
Describe the bug
Installing black from the head of the main branch and click==7.1.2 results in a stack trace whenever the tool is run.
To Reproduce
python3 -m venv black-click-compat-bug
source black-click-compat-bug/bin/activate
python -m pip install "click<8.0" git+https://github.com/psf/black
black --help
Resulting traceback:
Traceback (most recent call last):
File "/home/enpaul/black-click-compat-bug/bin/black", line 5, in
from b...
To prevent this in the future, we should test against the lowest supported version of each dependency. Is there an existing tool that can do that?
https://github.com/FFY00/python-resolver#mindeps-cli is the best solution I know of right now but I have never used it
Hmm what are your opinions on this? https://github.com/psf/black/pull/2770#issuecomment-1013170382
I don't see any other possible solution for this
just math ops probably isn't enough, call ops are also common
ah right, i could do that too, but there are gonna be other cases so I am not completely sure about this solution
toml-lang/toml#837
ITS CLOSED
Argh! Who thought Black should be automatically applied to lines in the IPython CLI?
The makes it less useful for education purposes, less useful for interactive math, and annoying when it rewrites your input across multiple lines.
236
whelp π
Yes, this can be turned off, but you have to get a whole classroom of mixed Windows, Mac, and Linux users to monkey through the steps to get back to a normal environment where you can see what you typed into the computer rather than what it wanted you to type.
yes and then you have the problem of the config not persisting
to be clear I don't think IPython doing this is a good idea
You are allowed to complain like this only if : you tried the alpha, beta, rc, opened an issue on GitHub first, and replied to my request for comments and notice it was going to be the default if no feedback from the community for the past two years. None of which you did.
bruh
a change this big? yeah maybe make some news and don't expect everyone to find it without bringing attention to it
'sides, 99% of news comes after release
mmw there will be multiple "why is python 2 dropped" issues once that release goes live
Yeah oh well I'm fine with providing a court answer as Python two is EOL
I find it very weird and scary Black is now a dependency of IPython
I mean I like it, but then again I don't teach
It should probably be disabled by default
It's tough though as there's no persistent configuration option for IPython
π₯²
and the maintainer is pretty against removing it
EDIT: This is wrong, see the below issue
@bright glacier ^ go upvote this issue/comment on it
Oh wow.
ambv already commented on it, nice
I mean, I'd rather use my authority as a co-maintainer of arguably the software that's giving that Carrau an incredibly tough time for deescalation than anything else really
ah, the irony of oss
So here is my challenge, if I don't make it the default, no-one know about it. It's astonishing that no-one found the bug @ehamiter described above in 2 years ! That alone would have definitely delayed the release, and at least I would have had tried to fix it.
nvm i take this back
more like a lesson in "nobody changes the defaults" π
It's really hard to make it much easier, there have been a long standing issue to have persistent config, but that's far beyond the time and funds we have for that in IPython. We could borrow a nice configuration interface like ptpython for the UI if Someone want to take a shot at ti.
why not do some slight uh.... stuff
y'know how you can set a variable to a file that python will run on import?
yeah uhm... what if ipython had a class that stored the config on the root module object
so you could import that class and modify it in that file to modify ipython settings
actually you can probably do this today depending on how its coded
I was actually wondering what this is about, doesn't IPython already support profile files?
what is the additional persistence that people want?
it does lmao
maybe what they want is that you run something in IPython and have it stay the next time you open IPython
instead of having to edit a separate file
also IPython calls black.format_str, so that better stay part of our API now π
Aaah can we rename it just for the sake of it
fwiw diff-shades depends on internal implementation details of black 
which arguably could be a problem since it doesn't do the AST check
though I'd argue the stability check would probably be more annoying than useful for something like IPython
why? they could just keep the original code if the stability check fails
Yeah but then they have to explain to the user that black failed because of some internal check we do
Not necessarily
I suppose. I'd consider a silent failure to format the input especially when it looks not blackened to be also confusing. Anyhow we don't have many stability bugs these days as it seems the magic trailing comma has reached a tense but stable agreement with the optional parentheses π so this would be rare
And actually what is the difference between IPython and Jupyter notebooks? I keep seeing them in the same domain but I don't quite get the distinction between the two.
(is it obvious I use / barely looked at neither? :p )
actually I don't either :D
OK so apparently IPython is the python backend for Jupyter which was originally part of IPython but was then moved under the Jupyter name as a language agnostic application
I suppose my original understanding of Jupyter of being Python only is what made this confusing
jesus fuck i feel bad for Carreau, Hettinger should have been WAY nicer. " Argh! Who thought " is just NOT how you start a feedback.
Please stop the spam
why?
but yes what is your question?
what is the base64?
Sorry, I assumed too quickly you were just another spammer who commonly hit this channel
no
not on topic here but basically it's a format encoding binary data into a long string of text
can you explain this in volume channel?
volume channel? we have one here?
Voice Chat 0
No sorry I don't use the voice channels.
π
also fwiw you need to be voice verified to speak in 'em and you won't meet the requirements just yet
but basically base64 is a way to convert binary data (ones and zeros) into a stream of text characters. You'd use in conditions where sending raw binary would be impossible or unreliable. I can't really explain it any further than that since I barely work with it.
Looks good to me.
We might need something a bit more complicated if we want to keep the separate flag for ESP in addition to the --preview flag.
@dense jungle You here? What do you mean by other flag in the review?
If we include ESP in --preview, there would be two ways of enabling it
So we might need to do something a little fancier for it in the Mode class
Ooooh, I thought we'd just get rid of the other flag
Is it possible to enable specific preview features rn? I am not familiar with that feature
It won't be
no, and won't :D
I feel like we should keep it for compatibility
Ah right, I was thinking about it in a different way, the features are gonna be default in the next release anyways π
Hmm, got to say that feels a bit weird, although compatibility is a good standard
releasing a non-beta, is like a major release, so i think its fine removing the flag
we could probably add a note in the docs about it
That'd be my intuition as well
preview should exist even if preview does nothing in that version because it will exist in the next version or two IMO
at least.. providing --preview shouldn't error if it existed in the last release
to be clear we're talking about removing the flag for ESP, not the --preview flag
I'll comment on the ESP issue so we can get other opinions as well
Jelle regarding your comment, could you post that on the issue as well, so that we can get other's opinions on it?
did
Oops sorry didn't include the context, I was talking about https://github.com/psf/black/pull/2770#issuecomment-1013909260 π
Oh my bad
wow
not sure why skip news didn't work
It hasn't been working well on pypa/bandersnatch either
race condition with the workflow being fired and the label being applied by dependabot?
now it's fine, decided not to wait for diff-shades
.github/workflows/diff_shades.yml lines 8 to 9
pull_request:
path-ignore: ["docs/**", "tests/**", "*.md"]```
Perhaps I got the syntax wrong but that seems unlikely
diffshades commented on this PR, wasn't the comment feature faulty?
It was faulty for forks as GitHub's workflow run API behaves differently for PRs from forks than the same repository.
ah
Seems fine to me. We're going to have to discuss further how to manage the complexity of supporting more languages but that can happen independently.
Thank you!
Nope, setup a test repo here: https://github.com/Shivansh-007/test-repo/pull/1
the syntax works
what the heck then >.<
ikr, i don't see any way else to trigger it
welcome to github actions β¨
unless someone manually did....
manually triggered runs don't comment though as there's no PR to associate the run with
is it different because it's dependabot making the PR?
though it seems like it correctly excluded the unit test runs
well the primer jobs didn't run for example
it does
dependabot pulls are essentially fork pulls ftr
i have no idea if that matters in this case
yeah they are fork pulls, but that doesn't change the behaviour here
but dependabot pulls are different
How does that matter with path-ignore?
Description
Checklist - did you ...
- [ ] Add a CHANGELOG entry if necessary?
- [ ] Add / update tests if necessary?
- [ ] Add new / update outdated documentation?
it is running diff-shades
The only thing left is the condensed YAML array syntax I used
but like that shouldn't matter, no? unless GitHub Actions is being drunk
try changing it - "path" syntax, though it shouldn't change the behaviour ideally
.github/workflows/diff_shades.yml lines 8 to 9
pull_request:
path-ignore: ["docs/**", "tests/**", "*.md"]```
yes just found it too π
I'll roll that into my pre-existing hotfix PR for diff-shades
oh sorry
or not :)
pro-tip learned the hard way, if your GHA YAML file isn't working as expected, open it in the web editor
yes, it highlighted the mistake
The fact there isn't an annotation in the run warning about an invalid key is kinda "wtf github" but oh well
make a github feedback discussion on it :D
it would get implemented some day
can we jsut run diff shades on src/black and src/blib2to3, since those are the paths which will cause changes to the formating
also why is src/primer still there unless it does something more
primer is still in use, I haven't moved everything to diff-shades yet
hmm, good point. I was just trying to be conservative just in case a dependency changes something etc. etc.
I guess so
Yeah. I'm just a little checked out of psf/black development right now
anddd you can undraft 2773
<!--
Please make sure that the bug is not already fixed either in newer versions or the
current development version. To confirm this, you have three options:
- Update Black's version if a newer release exists:
pip install -U black - 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
pip install -e .[d]; - run `...
open issues over time visualized in a fancy website under construction :)
nice, are you planning on including issue closing stats as well? I'll race ya :D
Yeah @dense jungle the race is gonna be public one day soon π
Felix will beat us soon π
what is "default"?
the issue author closing their own issue, better name suggestions are welcomed π
Oh damn I didn't realise I was so behind π let's have another look in 5 years
why is the chart.js zoom plugin breaking everything everytime I try to add it π¦
I mean, if I just closed all of our current issues I think I'd be #1
self? but default is fine
author?
I like author
I hate javascript development again
hmm this seems to be an issue with my bundler? as if I had any ability to fix such an issue
https://github.com/withastro/snowpack/issues/3692 wheeeeeee none of this makes sense to me
Yo
This is not the channel for advertising your projects @thorny swift
I use VIM 8.2 on Ubuntu 21.10 and install black via
Plugin 'psf/black'
In the documentation it says
and execute the following in a terminal:
cd ~/.vim/bundle/black
git checkout origin/stable -b stable
This cannot be done since:
fatal: 'origin/stable' is not a commit and a branch 'stable' cannot be created from it
Since black is working I think this can be purged from the documentation.
@tight bone ask about our weird formatting changes here
Using decorator syntax with a chained function call breaks the AST validation in safe mode.
This is a pattern for prometheus client
it got changed back to how it was originally, which is weird
still probably worth asking
black probably shouldn't be changing docstrings that much IMO
it might've just been because of weird indentation shenanigans we did in the docstring
not exactly sure what happened, but you could probably reproduce it easily
it's just intended behavior most likely heh
we do some indentation changes for docstrings yes
Does black treat pyi file specially?
It's removing empty lines between function stubs
it does, IIRC
What's the reason for
avoid vertical whitespace between consecutive module-level functions, names, or methods and fields within a single class;
I don't maintain typeshed (the original user of this feature) so I'll defer to @dense jungle
Stubs are intended to be concise and compact, so we want less spacing
I feel like this makes the pyi code more unreadable in the same manner it would make actual Python code less readable.
for example, a function definition in a stub is normally a single line
This is what I'm dealing with
oh hm, for nested classes that indeed doesn't look great
I'd be open to changing it to put more space around nested classes
FWIW newlines within classes between attributes should be preserved as a fix landed in main for that recently. Not released yet though.
wasn't that within if blocks?
Nested classes are probably not affected by that tho
That was an older contribution of mine π https://github.com/psf/black/commit/05e1fbf27d93df36b09c560791ad46c6ce3eb518
I also think the functions don't look too nice. Maybe cause they have decorators. But the classes are worse.
I'd be more hesitant to change that, we commonly have classmethod decorators in typeshed and there's been little feedback against pushing them together
but please open an issue about nested classes, we should change that behavior
Sure
Describe the style change
Nested classes in typing stubs should have blank lines between them.
Examples in the current Black style
class A:
class B:
attribute: int
class C:
attribute: int
def method(self) -> None: ...
def method2(self) -> None: ...
Desired style
class A:
class B:
attribute: int
class C:
attribute: int
def method(self) -> None: ...
def...
Wheee thanks!
No problem. Thanks for hearing me out.
Would you be interested in implementing this change too? I think it should be pretty easy, should be a similar change to the commit @bright glacier linked above
Yes, I could give it a shot.
thanks!
Should I first wait for the other maintainers to reply?
Up to you. I expect they'll agree, but you never know. Putting up a PR can't hurt, but there's of course some chance we won't accept it if there's consensus to do it the current way.
I think it pretty clearly looks better with newlines around nested classes, but style is subjective π
I'll just wait. I'm not in a rush to get this done.
Describe the style change
Blank lines should be treated the same in top-level code under an if-statement as in top-level code proper
Examples in the current Black style
class A:
def f(self): ...
class B:
def f(self): ...
if sys.version_info >= (3, 8):
class C:
def f(self): ...
class D:
def f(self): ...
Desired style
class A:
def f(self): ...
class B:
def f(self): ...
if ...
Describe the style change
In stub files (.pyi), do not add/remove blank lines depending on whether code is under if statements.
Examples in the current Black style
class A:
def foo(self) -> None: ...
class B:
def foo(self) -> None: ...
if sys.platform == "linux":
class A:
def foo(self) -> None: ...
class B:
def foo(self) -> None: ...
Desired style
class A:
def foo(self) -> None: ...
...
It's not clear to me how to know if the current line is within a nested class
Is that what this loop is for? https://github.com/psf/black/blob/main/src/black/lines.py#L448-L449
src/black/lines.py lines 448 to 449
depth = current_line.depth
while self.previous_defs and self.previous_defs[-1] >= depth:```
If it pops each previous def, then after the loop ends will self.previous_defs[-1] be the parent definition?
Well, maybe that's not the right approach anyway. It's not clear in the first place what is causing nested classes to be treated differently when in PYI files.
Probably this https://github.com/psf/black/blob/main/src/black/lines.py#L455-L456 but IDK how to check if the previous definition at the same depth was a class.
src/black/lines.py lines 455 to 456
elif depth:
before = 0```
@bright glacier do you know what needs to be done to get mypyc wheels published by default with black releases?
no worries if you're too busy
So there's more information at https://github.com/ichard26/black-mypyc-wheels
There's a GitHub Actions workflow y'all could probably integrate into psf/black although I'd suggest using https://github.com/ichard26/black-mypyc-wheels/commit/ec2748dff4976403bf18fadeaa8e9c638cebdd76 as main on that repo is uhhh not functional
π Could someone rerun the diff-shades workflow on my parenthesis PR
maybe just merge main into your branch? not sure it if will compare against latest main or against the merge origin
thanks!
I'd honestly suggest just building the wheels manually and then uploading 'em manually too
the workflow doesn't cover upload to PyPI nor push to main yet
I'm way too lazy for that π
workflows aren't ran from the branch, they are always ran from the main repo branch if that's what you mean
I mean diiff-shades compares main against your branch
so main needs to be compilable for it to work
ah yeah, that would be the case for forks
Btw, what do we do if we get no comments on psf/black#449
Description
Add more descriptive error message to help prevent confusion when parsing source code AST fails as in #2782
Checklist - did you ...
Nothing to do here.
I don't think I need a change log entry for this - but happy to add if needed.
Nice to see diff-shades work nicely π
hm...
it makes the day a little brighter
I won't action it until like February probably so go ahead
make a comment initially, maybe linking to the run IF a comment doesn't already exist
this means that it'll be one of the first comments
On an active/quick pr, the current could end up below a large review which means people have to find it
somewhat minor but w/e
yeah it'll take probably 10 more features to really flesh it out perfectly but I don't have the time for that at all right now
imma go back to making too many prs and finding pyright bugs cya
you have time for reviewing if I PR π?
PR what?
what arl said
?
oh this ic
I mean I can't reject it in good faith but 1) I can't review it anytime soon, and 2) feels like quite a bit of complexity for not a lot of gain
less complex than my rich diff pr for sure
too tired rn about to sleep | think it would just be if not comment then make comment
which is not at all compelx
since it already fetches a comment on future runs
Yeah but you're gonna have to be careful as the comment workflow only fires when the main workflow finishes
You can set it to fire when it starts too but it is a bit finicky
hmm yeah
Also argubly it could be a downgrade in one respect since once it does finish you wouldn't get a GH notification as it would just edit the preexisting comment
You've have to check sometime later to see the results
Yes. This is actually kind of nice in typeshed, when the mypy-primer comment comes you know CI is done
actually yeah I agree with that, but you also get workflow completion notifications though...
No? You don't AFAIK
If they fail, get cancelled or literally anything else yes but not successful runs
oh really? I thought we get for successful runs also, I think I did get them a few times 
a few times seems weird given most runs would be successful imo
this is why you actually want to make the last step of the comment workflow exit 1 /s
lol I could do that actually but that'd be confusing to everyone π
Is it possible to ignore a section of code from flake8 errors, or would I need to ignore the file
its black/const.py
btw continuing this convo from felix's dms
using calls was more readable
!e
def func(**kwargs):
print(kwargs)
func(**{"a": 1, "b": 2, "got updated": "no"}, **{"c":3, "got updated": "yes"})
@tired shard :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | TypeError: __main__.func() got multiple values for keyword argument 'got updated'
yep I think I like the .update more
π
where do i add the per-file-ignores=?
for the record I'd prefer the literals, especially because of the linter complaints :D but .flake8?
ah ok, didn't see that, was finding flake8 in tox.ini
i will just leave it as calls for now, we could change it later
cc @errant barn
there was a typehint issue, so was fixing that
gaveup and then just used Any for the timing, #type-hinting message
Btw for the others, we could change the colours and stuff later
good, we can discuss details in review then
This introduces a style helper for styling your logs to get a bit pretty output in the terminal.
It adds an OutputLevels enum which can be used to define the level of the message "log" you are outputing. You can still use the old manual styles by passing fg, bold, dim, etc. individually to the function black.output.out(), but if they are specified alongside with style= kwarg (which specifies the OutputLevels) the manual styles would over-write the style specified by the ...
All in all, I like the change especially for the easy access to predefined styles. Some comments below.
Describe the solution you'd like
I think, black really missing some customisation, which will be really usefull.
Just add config or/and command line function which will disable this style formatting:
print("Really long text")
To
print(
"Really long text"
)
Describe alternatives you've considered
The best will be split all checks to codes, and add --disable=CODE, but feature request doesn't requesting this.
hello guys
when I'm trying to run pre-commit run -all I'm getting the followed error related to black:
do you know what could be causing this? all google tells me is that this has occured in Debian's mailing list once
and that's it
any clues?
my version of black is 21.12b0
i've tried every trick in the book but this issue is relentless and project im trying to contribute to (pandera) requries pre-commit so I need to get this problem resolved somehow
Can you find your package install location?
That is the file we use to supply a version number, and should be included in every install. If not, that could be a packaging issue
python -m site ?
Yeah, so one level above, I think
should be black, blackd, blib2to3 and the version file, if I'm not mistaken
well is the file missing? _black_version.py
oh my bad, it doesn't scroll any further
so yeah it is missing
yes. how do I resolve this?
how is pre-commit installing black? is the configuration in a public project?
using pip install -r requirements-dev.txt
at least that's what I used
pre-commit sets its own venv though
would manually adding _black_version.py solve this, or would that be a potentially risky can of worms?
i presume it's just a one-liner .py right
well, yes :D but
only for you
so, have you installed black in your development environment as well?
we could try some debugging in that case
a fresh install or something
nice, so does import black fail similarly?
nope, computes fine
okay, so then we could have a look at the precommit configuration
Hey @mint barn!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-ast
description: Simply check whether files parse as valid python
- id: check-case-conflict
description: Check for files that would conflict in case-insensitive filesystems
- id: check-docstring-first
description: Checks for a common error of placing code before the docstring.
- id: check-merge-conflict
description: Check for files that contain merge conflict strings
- id: check-yaml
description: Attempts to load all yaml files to verify syntax
- id: debug-statements
description: Check for debugger imports and py37+ breakpoint() calls in python source
- id: end-of-file-fixer
description: Makes sure files end in a newline and only a newline
- id: trailing-whitespace
description: Trims trailing whitespace
- id: mixed-line-ending
description: Replaces or checks mixed line ending
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
args: ["--line-length=79"]
- repo: https://github.com/ikamensh/flynt
rev: '0.69'
hooks:
- id: flynt
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
args: ["--line-length=79"]
- repo: https://github.com/pycqa/pylint
rev: v2.12.2
hooks:
- id: pylint
args: ["--disable=import-error"]
exclude: (^docs/|^scripts)```
# TODO: in mypy 0.900+ one needs to pip install type stubs separately (i.e. typeshed is no longer included)
# TODO: but pre-commit downloads mypy in a different location (~/.cache)
rev: v0.930
hooks:
- id: mypy
entry: mypy pandera tests
files: (^pandera/|^tests|^scripts)
exclude: (^docs/)
pass_filenames: false
additional_dependencies:
- types-click
- types-pyyaml
- types-pkg_resources```
yeah the black one is all we're interested in I think
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
args: ["--line-length=79"]
could you retry installing the hooks?
pre-commit install probably
don't know how to purge the env though, hopefully that will override it
damn, I think that's where my experience ends
my local precommit runs black just fine
maybe you could try to rebuild your project entirely
mostly because your dev install working rules out packaging errors, and you have a pretty minimal black pre-commit config :D so I can't imagine what's wrong
although could be that the way pre-commit installs black is somehow flawed
maybe update its version also, just in case :D
alright, I can confirm that manually creating a _black_version.py solves this
well at least, good to know
if you're satisfied with that then my pleasure :D
now I can go black and don't go back
never go back
Came across https://github.com/psf/black/issues/2634 while going through the issues, I think it could be closed as the author hasn't responded and it isn't related to black
thanks, done
Can someone help me with implementing the empty lines change between nested classes in stubs?
I sent some messages here yesterday but I guess they were missed
Sorry, don't have time to look into this right now. Maybe in a few days
pre-commit clean removes all pre-commit environments although that's a very blunt command.
any import errors due to _black_version are usually caused by switching from black before "the great refactor" (i.e. when we split up black's monolithic file into a package) and after without doing a clean reinstall, or vice versa
I'm not sure how pre-commit managed to mess up its black environment though given it should be free from developer interference
Description
This PR deprecates --experimental-string-processing and moves the functionality under --preview machinery.
Checklist - did you ...
- [x] Add a CHANGELOG entry if necessary?
- [x] Add / update tests if necessary?
- [x] Add new / update outdated documentation?
I'll review myself for some points of contention. Closes #2756.
Looks great, just some minor feedback
the PR integration seems to have broken (I just merged two PRs)
Yeah hey @delicate marsh is the webhook / cloudflare worker failing?
i know why
why?
I have a pr to fix it
hmmmm, sounds like a solution to me
SebastiaanZ/github-status-embed-for-discord#3
it uses canary.discord.com instead of normal discord.com
wait
I'm a bit tired
this is unrelated
ignore me
github-filter/src/index.ts line 156
let template = `βhttps://discord.com/api/webhooks/${id}/${token}/github?wait=1`β```
it is and idk why
I don't have maintain / admin permissions so I can't check if the webhook is firing successfully on psf/black's side.
its either github or discord but i doubt its the worker itself
had the same issue with my own one that's based off of pydis's
huh - unsure
cloudfare HSA had banned pydis π, should we working now ig, even the pydis logs had died (see #dev-contrib for info)
Congrats @muted haven :D
Ok, I have got uvloop test failing and some primer tests, I am not sure what they do and how I can solve them, would need some help π
Looks good! Just one opinion below.
We could use these headings as a template for future changelogs to reduce conflicts until we decide on which tool to use in #2766.
I hate this, https://github.com/psf/black/pull/2787/commits/53fd261abba29f1f04a1d3499d7ac3dee19506de the code blocks aren't rendered π
and merge conflict π
Looking better, but let's address all the comments!
@tired shard re: dict type hints, have I missed something?
about Dict[str, Any] not being correct for function arguments
its going to be an empty dict always, so basically doesn't contain anything, with the typehint [str, Any] it says that the dict contains mappings of strings to any data
and mypy complaining about the same
mypy is too smart..
lol
