#black-formatter

1 messages Β· Page 29 of 1

plain atlas
#

briiiiiiing out the popcoooooorn

bright glacier
#

I don't have any and popcorn is kinda meh tbh

errant barn
#

sounds like something a guy without popcorn would say out of spite πŸ˜‰

bright glacier
#

.<

plain atlas
#

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

errant barn
#

towncrier does have the history going for it too, meaning a more mature tool

sudden mauve
#

finding many black formatters for jupyter notebooks. is there a "best" one? is black wrong for that context?

sudden mauve
#

ohh i see. sorry for missing that

flat krakenBOT
#

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,...
flat krakenBOT
#

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,
...
tired shard
#

nope see create.py and see the logic for creating the path if it doesn't exist

bright glacier
neon loom
#

Sure. It’s a solid sized code base.

plain atlas
bright glacier
#

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.

plain atlas
#

a free index?

bright glacier
#

GitHub pages

tired shard
#

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

toxic stormBOT
dense jungle
tired shard
#

yeah its "good to have"

#

was easiest to get me started with the formatting section of the code, so picked it up

bright glacier
#

@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

bright glacier
#

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 lemon_sweat

plain atlas
#

ask someone else/mention it publicly, suddenly solve the problem or find something

tired shard
#

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

late dewBOT
#
It has arrived!

Here's your reminder: ||how was your first paper πŸ‘€||
[Jump back to when you created the reminder](#black-formatter message)

gusty grail
#

@mint barn what's up with the random block of code?

#

Please stick to the topic of the channel.

tired shard
#

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

errant barn
#

Nice, "yes" meaning parens will be inserted?

tired shard
errant barn
#

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

tired shard
#

nor am I, i somehow figured this out

tired shard
#

i already have the code for that ready, one line change :)

errant barn
#

let's ask the others though

tired shard
#

also, wdym by

could delete the identity callable assignment from LineGenerator

#

yeah

#

ah yes

#

got it

errant barn
#

visit_expr = visit_expr doesn't really do anything

tired shard
#

but it was there for the others also

#

so i kept it

errant barn
#

oh, in that case, carry on

tired shard
#

πŸ‘

#

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?

errant barn
#

yeaaah, sec I'll check how the py2 remove ended up

tired shard
#

k

marsh geyser
#

❀️ πŸ–€

errant barn
#

no wait it was hugging powers. Looks like no decision yet :D

tired shard
#

ah

#

isort

errant barn
#

fair point

#

well anyways personally parens > multi-statement

tired shard
#

yes yes agreed

errant barn
#

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)

toxic stormBOT
gusty grail
#

so you're telling me that fr" " is not French strings???

errant barn
#

if by French you mean backwards then yeah ducky_devil

dense jungle
#

Fun fact: you can write rb"x" to embed a Ruby string in Python

errant barn
dense jungle
#

I know I also need to get back to you on the --preview flag, hopefully later today or tomorrow

errant barn
#

Nice, but no worries, things are steadily progressing!

dense jungle
# errant barn I haven't dealt with primer much, but this is the second time in a short period ...

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

GitHub
  • Update flake8 settings

  • Add poetry to isort namespace packages

  • Ignore flake8 E501 for long test names

  • Run automatic string formatting on tests

  • Run automatic string formatting o...

#

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

errant barn
#

Right, makes sense πŸ˜„ I was worried because the first run succeeded but the revert didn't

errant barn
#

DAMN

slow ibex
#

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?
dense jungle
slow ibex
#
>echo -c "a**a"
-c "a**a"
dense jungle
slow ibex
#

>black -c "*"
"ntax"

>black -c "*a"
AppData

>black -c "a*"
a.out
``` my shell is absolutely broken
fallow saffron
#

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
slow ibex
#

second
it is shorter and cleaner

fallow saffron
#

And I can do that by importing from __future__ import annotations for older versions, right?

fallow saffron
#

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

dense jungle
#

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

fallow saffron
#

Gotcha, cool

#

I appreciate it

silent apex
#

What does AST-safe mean?

dense jungle
#

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

silent apex
#

that makes sense, thanks!

errant barn
late dewBOT
#

src/black/__init__.py line 416

root, method = find_project_root(src) if code is None else (None, None)```
errant barn
#

Nvm we read it anyway but just elsewhere πŸ˜…

plain atlas
#

hmm

#

how can i ensure that black uses the cache when passing code directly to it?

normal canopy
#

what is black?

errant barn
normal canopy
#

why is there a channel like this?

plain atlas
errant barn
plain atlas
#

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

normal canopy
#

Oh, ok. I was also working on another open source project I wondered if I could open a channel for my project as well

plain atlas
#

i'm formatting around 115 files πŸ˜…

errant barn
#

Cool! But not likely to happen here, I think. It'd have to be quite a notable project I imagine

dense jungle
plain atlas
#

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

dense jungle
#

of course it could make sense for your use case

plain atlas
#

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

bright glacier
#

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.

dense jungle
bright glacier
#

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

dense jungle
#

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

bright glacier
#

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

dense jungle
late dewBOT
#

.github/workflows/mypy_primer_comment.yml line 43

- name: Hide old comments```
bright glacier
#

I don't hate javascript but inline code is never fun in a YAML file IMO

dense jungle
late dewBOT
#

.github/workflows/mypy_primer_comment.yml line 70

- name: Hide old comments```
bright glacier
#

Security I suppose? guessing from the comment in the mypy one

dense jungle
#

not sure, on typeshed it's pinned to a commit so that should be fine

bright glacier
#

we could pin the two third party actions used in diff_shades_comment.yml actually now you mention that

dense jungle
#

good idea

bright glacier
#

I never understood why JavaScript's package lock files end up half a megabyte or more big

#

I mean, the dist/* folders already make it hard to audit but I digress :/

little parrot
#

cause theres no stdlib

#

so theres a package for everything

bright glacier
#

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 ..

dense jungle
#

upgrading dependencies on a big JS app is awful

bright glacier
#

Even build tools are being targeted like in that semi-recent Solarwinds attack IIRC so it's rather scary these days

plain atlas
#

hi

tired shard
tired shard
#

Why is this False? I am doing print(node, is_walrus_assignment(node))

tired shard
#

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

bright glacier
#

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

tired shard
bright glacier
#

although I have no experience with the visitor code fwiw

tired shard
#

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?

bright glacier
#

You tell me

tired shard
#

if i knew, i wouldn't have been asking lemon_sweat

bright glacier
#

wait a second, do whitespace changes by the visitor get ignored?

tired shard
#

idts

#

actually idk

plain atlas
#

!e ```py
import os
if a := os.name:...
print(a)

late dewBOT
#

@plain atlas :white_check_mark: Your eval job has completed with return code 0.

posix
plain atlas
#

I don't remember my point actually

#

so hi hope y'all well I need to work on more automation

tired shard
# plain atlas because walrus

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

bright glacier
tired shard
#
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
bright glacier
#

It'd be great if we had a internal APIs docs (not for users, but contributors) tbh

bright glacier
#

Łukasz still knows the formatting code the best

bright glacier
#

no, I was saying we should make one

plain atlas
#

no, there is one (period)

tired shard
#

yeah, it would be very very helpful

bright glacier
#

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"

tired shard
# tired shard currently i basically just go inside the list of `node.children` digging for nam...
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
bright glacier
#

that's hardly helpful, it's too low-level if you're new to the codebase IMO

bright glacier
tired shard
#

umm, let me see how i can do that

bright glacier
#

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

tired shard
#

i can, but i need to add some logic for making it detect it is a eqequal comparision

bright glacier
#

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

tired shard
#

yeah that's why i have been discussing it here :)

#

it would be less nesting, yeah

bright glacier
#

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)

tired shard
#

wasn't it approved on a = b==c?

bright glacier
flat krakenBOT
dense jungle
bright glacier
plain atlas
#

yes ik those fit into the rest but where would I be without my precious one liner pulls

bright glacier
#

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.

tired shard
#

ah yes

#

now i need to somehow check whether the node.parent is walrus/assigment stmt

bright glacier
#

although it's not clear what Łukasz approved

tired shard
#

because it shouldn't be doing the changes on others

bright glacier
#

yea I know, I deleted my message because I hit me

plain atlas
dense jungle
#

hm it seems a lot less confusing to write x = a > b than x = a == b

bright glacier
tired shard
#

ah yes, that's why i was wondering where i read to only apply on ==

bright glacier
#

oh dear there goes my inbox again

dense jungle
#

got to do something with that commit access

bright glacier
#

why is the real world always so damn complicated >< /lh

bright glacier
bright glacier
#

ugh, there was one last thing I wanted to do for the diff-shades integration but it fell out my mind

dense jungle
#

fast because I'll merge the PR soon πŸ™‚

bright glacier
#

LOL, you know I'm a 🐒

dense jungle
#

also we should have mypyc on by default for the release, right?

bright glacier
#

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 ducky_dave

tired shard
#

hmm, how do i figure out if the comparision was part of a expr stmt?

bright glacier
#

why? does the location matter? I thought just whether the parent was a wulrus / assignment stmt did?

tired shard
#

expr stmt is assignment stmt and that's what i want to check

bright glacier
#

That's not any clearer to me

tired shard
#

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)

bright glacier
#

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

tired shard
#

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

tired shard
bright glacier
#

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

tired shard
#

i could go into parent's parents and check siblings but that's gonna make it a bit hacky

#

lol yeah

bright glacier
#

By the way you know of DebugVisitor right?

tired shard
#

nope

bright glacier
#
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

tired shard
#

oo waves, nice i like it

bright glacier
#

I recommend using --fast with it to avoid the duplication

tired shard
#

yep, i do :D

#

ok getting back to it, let me try using parent of parent

bright glacier
#

Honestly I'm no where closer to understanding psf/black#2525

toxic stormBOT
bright glacier
#

The layers of indirection mixed with user and project level configuration break my brain

tired shard
#

docs didn't help?

bright glacier
#

no

tired shard
#

welp i will see if i can make it simpler

dense jungle
#

I posted a suggested docs rewrite for what it's worth

bright glacier
#

I don't think the docs are really the problem, it's just the concept doesn't fit my brain well

dense jungle
#

though I didn't think about user-level config

tired shard
#

yeah i saw that jelle

#

one quesion before we go into that pr, what does annassign statement correspond to?

#

an example would help

dense jungle
#

a : int = 1

tired shard
#

oh

#

k thanks

dense jungle
#

thank you @bright glacier !

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 :)

bright glacier
#

Do you want write access to diff-shades Jelle?

tired shard
#

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

bright glacier
tired shard
#

it worked with nodes to leafs/nodes

#

here the children are leafs

#

that's what i understood

#

i may be wrong

bright glacier
#

also isn't children a property / attribute, why are you turning it into a list?

tired shard
#

they are a list

bright glacier
#
if condition:
    wrap_in_parentheses(node)

yield from self.visit_default(node)
```?
late dewBOT
#

src/blib2to3/pytree.py line 265

self.children = list(children)```
bright glacier
#

OH, wrap_in_parentheses needs more than just the node

tired shard
#

yeah

bright glacier
#

why are you converting the list to a list then?

tired shard
#

umm i could use node.insert pithink

#

one sec

#

that would be ```py
node.insert_child(0, lpar)
node.insert_child(-1, rpar)

bright glacier
#

do Leaf object have parents? btw

tired shard
#

yeah

#

the node in which they are contained

bright glacier
#

huh, weird the initializer doesn't have an argument for that then

tired shard
#

even node initializer doesn't hae argument for its parents πŸ€·β€β™‚οΈ

bright glacier
tired shard
#

rich diff πŸ˜”

bright glacier
#

Eh, I'm indifferent, I don't consider it that important

tired shard
#

its not, but its nice

tired shard
dense jungle
bright glacier
#

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

dense jungle
#

sounds good!

bright glacier
#

though I suppose worst case y'all could fork it and then update it that way but like that's annoying πŸ˜‰

tired shard
#

ok after adding a file in test/data it would automatically be tested right?

#

or do i need to add a test

bright glacier
#

you'll probably have to add it to the SIMPLE_CASES list in tests/test_format.py

tired shard
#

alright

#

a = b in c and b == d how should this be formatted?

#

imo i like it as it is

dense jungle
plain atlas
#

??? why did that post

#

github being github pls ignore my comments

bright glacier
#

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

dense jungle
#

could it use mypyc-compiled black for the baseline?

plain atlas
#

compile mypyc of diff-shades 🀑

#

or is most of the wait IO

bright glacier
dense jungle
#

I doubt much time is spent in diff-shades unless @bright glacier did something silly

plain atlas
#

how long does it take to compile black?

bright glacier
#

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

plain atlas
#

*on gha

bright glacier
#

I guess one option to compile the baseline/target revision on GHA before running it against the projects

bright glacier
plain atlas
#

that's why i asked how long does it take to compile

#

then hell yeah try compiling it before running it against the projects

dense jungle
#

oh yeah, that might be a win then. I assumed compilation would be too slow to make it a good idea for the target

plain atlas
#

i was thinking anything under 5 minutes would be worth attempting

bright glacier
#

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

plain atlas
#

ah these above runs aren't typical?

#

these are the runs of diff shades on the main repo

bright glacier
#

sorry I mean diff-shades run

plain atlas
#

πŸ€” what bot is removing the embed

bright glacier
#

each workflow run does two, one against the baseline (assuming there was no cached analysis to reuse) and one against the target

bright glacier
bright glacier
#

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

tired shard
bright glacier
plain atlas
#

do you need a specific clang?

bright glacier
#

I don't know honestly

plain atlas
#

well you got three

bright glacier
#

locally I've been using clang version 10.0.0-4ubuntu1

plain atlas
#

so safe

bright glacier
#

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

tired shard
#

i kinda like it without the brackets on ==

bright glacier
#

yeah and there's no sane way of describing such an edge case in the docs

bright glacier
#

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

bright glacier
dense jungle
bright glacier
#

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

dense jungle
#

mypy-mypyc-wheels does this and creates a GH release for every commit to mypy

bright glacier
#

they have a bot triggering it though no?

dense jungle
#

not sure how it works

bright glacier
#

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

plain atlas
#

:blink:

bright glacier
#

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.

plain atlas
#

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

bright glacier
#

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.

plain atlas
#

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

bright glacier
#

I now realize CI resources would make for an excellent donation opportunity to OSS

tired shard
#

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

flat krakenBOT
tired shard
#

felix is super fast πŸ‘€

errant barn
#

always lurking

tired shard
#

lol, it didn't fit so deleted it

#

you must have also seen i requested your review on 2525

plain atlas
#

someone requested a feature somewhere and I responded with a pr πŸ˜†

tired shard
#

you are next level

#

also i need your inputs as a user on the test file

#

does it look okay

plain atlas
#

I just spent two hours fixing something that I thought worked and then I wrote a test file for it

tired shard
#

this isn't really test, but formatting

#

so do it

#

cuz i tried to check msot cases

errant barn
#

sadly I'm not that quick with reviews :D emotes are much easier to speedrun

tired shard
#

no need to be quick πŸ™ƒ lol

#

well primer failed as expected

#

what do you about such changes, which cause changes on the primer repos?

errant barn
#

you can mark them as expecting changes in src/primer/json

flat krakenBOT
#

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...
fleet zephyr
#

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)
dense jungle
#

and maybe a long --line-length

fleet zephyr
dense jungle
fleet zephyr
dense jungle
fleet zephyr
sinful thicket
#

df

misty lantern
#

why doesnt black work with code that contains match?

#

im using latest version

#

installed with pip install black

dense jungle
#

I'm pretty sure there's a hint for that in the error message when it fails, did that not show up for you?

misty lantern
#

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

bright glacier
#

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

bright glacier
#

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 🀞

flat krakenBOT
bright glacier
#

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

stuck vapor
bright glacier
#

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)

stuck vapor
stuck vapor
bright glacier
#

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)
late dewBOT
#

.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```
bright glacier
#

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

dense jungle
#

hm could we solve that instead by not running CI on non-main branches on the upstream repo?

bright glacier
#

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

flat krakenBOT
#

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...
bright glacier
#

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?

bright glacier
dense jungle
bright glacier
#

Probably

bright glacier
#

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

dense jungle
#

but from now on all of main should work with mypyc, right?

bright glacier
#

it's probably fine as we probably won't use it on old revisions but yeah

dense jungle
#

yes

bright glacier
dense jungle
#

yeah it should be

flat krakenBOT
#

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...
bright glacier
flat krakenBOT
tired shard
#

I don't see any other possible solution for this

dense jungle
tired shard
plain atlas
#

toml-lang/toml#837

plain atlas
#

ITS CLOSED

red sedge
#

woop woop

#

will pip start enforcing it?

bright glacier
#

whelp πŸ™ƒ

plain atlas
#

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

bright glacier
#

to be clear I don't think IPython doing this is a good idea

plain atlas
#

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

bright glacier
#

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

plain atlas
#

agreed

#

!pypi ipython

late dewBOT
plain atlas
little parrot
#

I mean I like it, but then again I don't teach

#

It should probably be disabled by default

bright glacier
#

It's tough though as there's no persistent configuration option for IPython

plain atlas
#

πŸ₯²

#

and the maintainer is pretty against removing it

EDIT: This is wrong, see the below issue

toxic stormBOT
plain atlas
#

@bright glacier ^ go upvote this issue/comment on it

errant barn
#

Oh wow.

plain atlas
#

ambv already commented on it, nice

bright glacier
#

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

plain atlas
#

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.

dense jungle
plain atlas
#

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

dense jungle
#

I was actually wondering what this is about, doesn't IPython already support profile files?

#

what is the additional persistence that people want?

plain atlas
#

it does lmao

dense jungle
#

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 πŸ™‚

errant barn
#

Aaah can we rename it just for the sake of it

lament crow
#

evil, I love it lul

#

(but don't do it of course)

bright glacier
#

fwiw diff-shades depends on internal implementation details of black ducky_dave

bright glacier
#

though I'd argue the stability check would probably be more annoying than useful for something like IPython

dense jungle
bright glacier
#

Yeah but then they have to explain to the user that black failed because of some internal check we do

dense jungle
#

Not necessarily

bright glacier
#

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 )

errant barn
#

actually I don't either :D

bright glacier
#

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

flat krakenBOT
frozen badge
#

jesus fuck i feel bad for Carreau, Hettinger should have been WAY nicer. " Argh! Who thought " is just NOT how you start a feedback.

mint barn
#

w

#

1

#

I

#

have

#

a

#

question

bright glacier
#

Please stop the spam

mint barn
bright glacier
#

but yes what is your question?

mint barn
bright glacier
#

Sorry, I assumed too quickly you were just another spammer who commonly hit this channel

bright glacier
mint barn
bright glacier
#

volume channel? we have one here?

mint barn
#

Voice Chat 0

bright glacier
#

No sorry I don't use the voice channels.

mint barn
bright glacier
#

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.

flat krakenBOT
errant barn
#

@dense jungle You here? What do you mean by other flag in the review?

dense jungle
#

So we might need to do something a little fancier for it in the Mode class

errant barn
#

Ooooh, I thought we'd just get rid of the other flag

tired shard
#

Is it possible to enable specific preview features rn? I am not familiar with that feature

dense jungle
tired shard
#

Ah right, I was thinking about it in a different way, the features are gonna be default in the next release anyways πŸ‘

errant barn
#

Hmm, got to say that feels a bit weird, although compatibility is a good standard

tired shard
#

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

errant barn
#

That'd be my intuition as well

plain atlas
#

preview should exist even if preview does nothing in that version because it will exist in the next version or two IMO

errant barn
#

yeah it will

#

the PR is empty in functionality :D

plain atlas
#

at least.. providing --preview shouldn't error if it existed in the last release

dense jungle
errant barn
#

I'll comment on the ESP issue so we can get other opinions as well

tired shard
#

Jelle regarding your comment, could you post that on the issue as well, so that we can get other's opinions on it?

errant barn
#

did

tired shard
errant barn
#

Oh my bad

mint barn
bright glacier
#

what happened with CI @dense jungle ?

#

I just got up so I'm confused

dense jungle
#

not sure why skip news didn't work

bright glacier
#

It hasn't been working well on pypa/bandersnatch either

#

race condition with the workflow being fired and the label being applied by dependabot?

flat krakenBOT
dense jungle
#

now it's fine, decided not to wait for diff-shades

bright glacier
#

Hmm, I thought I disabled diff-shades from running on documentation only PRs

late dewBOT
#

.github/workflows/diff_shades.yml lines 8 to 9

pull_request:
  path-ignore: ["docs/**", "tests/**", "*.md"]```
bright glacier
#

Perhaps I got the syntax wrong but that seems unlikely

tired shard
# flat kraken

diffshades commented on this PR, wasn't the comment feature faulty?

bright glacier
#

It was faulty for forks as GitHub's workflow run API behaves differently for PRs from forks than the same repository.

tired shard
#

ah

flat krakenBOT
bright glacier
#

what the heck then >.<

tired shard
#

ikr, i don't see any way else to trigger it

bright glacier
#

welcome to github actions ✨

tired shard
#

unless someone manually did....

bright glacier
#

manually triggered runs don't comment though as there's no PR to associate the run with

tired shard
#

hmm

#

can you make a test pr editing something in docs

dense jungle
#

is it different because it's dependabot making the PR?

#

though it seems like it correctly excluded the unit test runs

bright glacier
#

well the primer jobs didn't run for example

tired shard
#

shouldn't matter

#

we are just checking what paths were edited with on:path-ignore

plain atlas
#

it does

#

dependabot pulls are essentially fork pulls ftr

#

i have no idea if that matters in this case

tired shard
#

yeah they are fork pulls, but that doesn't change the behaviour here

plain atlas
#

but dependabot pulls are different

bright glacier
#

How does that matter with path-ignore?

tired shard
#

just try making a test pr

#

lets end this

flat krakenBOT
dense jungle
#

it is running diff-shades

tired shard
#

its running

#

whaaat

bright glacier
#

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

tired shard
#

try changing it - "path" syntax, though it shouldn't change the behaviour ideally

late dewBOT
#

.github/workflows/diff_shades.yml lines 8 to 9

pull_request:
  path-ignore: ["docs/**", "tests/**", "*.md"]```
bright glacier
#

oh, there's a typo

#

should be paths-ignore

dense jungle
#

yes just found it too πŸ™‚

bright glacier
#

I'll roll that into my pre-existing hotfix PR for diff-shades

flat krakenBOT
dense jungle
#

oh sorry

bright glacier
#

or not :)

#

pro-tip learned the hard way, if your GHA YAML file isn't working as expected, open it in the web editor

dense jungle
#

yes, it highlighted the mistake

bright glacier
tired shard
#

oh god

#

typo of the day

bright glacier
#

The fact there isn't an annotation in the run warning about an invalid key is kinda "wtf github" but oh well

tired shard
#

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

bright glacier
#

primer is still in use, I haven't moved everything to diff-shades yet

bright glacier
tired shard
bright glacier
#

I guess so

#

Yeah. I'm just a little checked out of psf/black development right now

tired shard
#

anddd you can undraft 2773

flat krakenBOT
#

<!--
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:

  1. Update Black's version if a newer release exists: pip install -U black
  2. Use the online formatter at , which will use
    the latest main branch.
  3. 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 `...
bright glacier
#

open issues over time visualized in a fancy website under construction :)

errant barn
#

nice, are you planning on including issue closing stats as well? I'll race ya :D

bright glacier
#

Yeah @dense jungle the race is gonna be public one day soon πŸ˜„

dense jungle
#

Felix will beat us soon πŸ™‚

dense jungle
bright glacier
#

the issue author closing their own issue, better name suggestions are welcomed πŸ˜„

errant barn
#

Oh damn I didn't realise I was so behind πŸ˜… let's have another look in 5 years

bright glacier
#

why is the chart.js zoom plugin breaking everything everytime I try to add it 😦

errant barn
#

I mean, if I just closed all of our current issues I think I'd be #1

bright glacier
#

I like author

bright glacier
#

hmm this seems to be an issue with my bundler? as if I had any ability to fix such an issue

rotund helm
#

Yo

errant barn
#

This is not the channel for advertising your projects @thorny swift

flat krakenBOT
#

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.

plain atlas
#

@tight bone ask about our weird formatting changes here

tight bone
plain atlas
#

still probably worth asking

plain atlas
tight bone
#

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

dense jungle
#

we do some indentation changes for docstrings yes

frozen yacht
#

Does black treat pyi file specially?

#

It's removing empty lines between function stubs

plain atlas
#

it does, IIRC

frozen yacht
#

What's the reason for

avoid vertical whitespace between consecutive module-level functions, names, or methods and fields within a single class;

bright glacier
#

I don't maintain typeshed (the original user of this feature) so I'll defer to @dense jungle

dense jungle
frozen yacht
#

I feel like this makes the pyi code more unreadable in the same manner it would make actual Python code less readable.

dense jungle
#

for example, a function definition in a stub is normally a single line

frozen yacht
#

This is what I'm dealing with

dense jungle
#

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

bright glacier
#

FWIW newlines within classes between attributes should be preserved as a fix landed in main for that recently. Not released yet though.

dense jungle
#

wasn't that within if blocks?

bright glacier
#

Nested classes are probably not affected by that tho

frozen yacht
#

I also think the functions don't look too nice. Maybe cause they have decorators. But the classes are worse.

dense jungle
#

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

frozen yacht
#

Sure

flat krakenBOT
bright glacier
#

Wheee thanks!

frozen yacht
#

No problem. Thanks for hearing me out.

dense jungle
#

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

frozen yacht
#

Yes, I could give it a shot.

dense jungle
#

thanks!

frozen yacht
#

Should I first wait for the other maintainers to reply?

dense jungle
#

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 πŸ™‚

frozen yacht
#

I'll just wait. I'm not in a rush to get this done.

flat krakenBOT
flat krakenBOT
frozen yacht
#

It's not clear to me how to know if the current line is within a nested class

late dewBOT
#

src/black/lines.py lines 448 to 449

depth = current_line.depth
while self.previous_defs and self.previous_defs[-1] >= depth:```
frozen yacht
#

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.

late dewBOT
#

src/black/lines.py lines 455 to 456

elif depth:
    before = 0```
dense jungle
#

@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

bright glacier
flat krakenBOT
bright glacier
tired shard
#

πŸŽ‰ Could someone rerun the diff-shades workflow on my parenthesis PR

dense jungle
bright glacier
#

the workflow doesn't cover upload to PyPI nor push to main yet

dense jungle
#

I'm way too lazy for that πŸ™‚

tired shard
dense jungle
#

so main needs to be compilable for it to work

tired shard
#

ah yeah, that would be the case for forks

#

Btw, what do we do if we get no comments on psf/black#449

toxic stormBOT
tired shard
dense jungle
#

awesome

#

now I wonder what a "louter" is

#

oh left outer

flat krakenBOT
bright glacier
#

Nice to see diff-shades work nicely πŸ˜„

plain atlas
#

hm...

bright glacier
#

it makes the day a little brighter

plain atlas
#

i have a feature request

#

f sorry for being the cloud

bright glacier
#

I won't action it until like February probably so go ahead

plain atlas
#

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

bright glacier
#

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

plain atlas
#

imma go back to making too many prs and finding pyright bugs cya

tired shard
bright glacier
#

PR what?

tired shard
#

what arl said

plain atlas
#

?

bright glacier
#

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

tired shard
#

less complex than my rich diff pr for sure

plain atlas
#

too tired rn about to sleep | think it would just be if not comment then make comment

tired shard
#

which is not at all compelx

plain atlas
#

since it already fetches a comment on future runs

bright glacier
#

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

tired shard
#

hmm yeah

bright glacier
#

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

dense jungle
tired shard
#

actually yeah I agree with that, but you also get workflow completion notifications though...

bright glacier
#

No? You don't AFAIK

#

If they fail, get cancelled or literally anything else yes but not successful runs

tired shard
#

oh really? I thought we get for successful runs also, I think I did get them a few times pithink

bright glacier
#

a few times seems weird given most runs would be successful imo

plain atlas
bright glacier
#

lol I could do that actually but that'd be confusing to everyone πŸ™‚

tired shard
#

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

errant barn
#

my man just slid out of my dms

#

why not literals though?

tired shard
#

using calls was more readable

#

!e

def func(**kwargs):
  print(kwargs)

func(**{"a": 1, "b": 2, "got updated": "no"}, **{"c":3, "got updated": "yes"})
late dewBOT
#

@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'
errant barn
#

yep I think I like the .update more

tired shard
#

πŸ‘

tired shard
errant barn
#

for the record I'd prefer the literals, especially because of the linter complaints :D but .flake8?

tired shard
#

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

tired shard
#

cc @errant barn

#

there was a typehint issue, so was fixing that

#

Btw for the others, we could change the colours and stuff later

errant barn
#

good, we can discuss details in review then

flat krakenBOT
#

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 ...

flat krakenBOT
flat krakenBOT
#

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.

mint barn
#

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

errant barn
#

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

mint barn
#

python -m site ?

errant barn
#

Most likely the path that is shown in the error stack trace

#

until site-packages

mint barn
#

yep here it is

errant barn
#

Yeah, so one level above, I think

#

should be black, blackd, blib2to3 and the version file, if I'm not mistaken

mint barn
#

here it is. is anything missing?

errant barn
#

oh my bad, it doesn't scroll any further

#

so yeah it is missing

mint barn
#

yes. how do I resolve this?

dense jungle
#

how is pre-commit installing black? is the configuration in a public project?

mint barn
#

at least that's what I used

dense jungle
#

pre-commit sets its own venv though

mint barn
#

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

errant barn
#

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

mint barn
#

yeah, let's go for it

#

I have installed it in all of my enviroments

errant barn
#

nice, so does import black fail similarly?

mint barn
#

nope, computes fine

errant barn
#

okay, so then we could have a look at the precommit configuration

late dewBOT
#

Hey @mint barn!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

mint barn
#

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```
errant barn
#

yeah the black one is all we're interested in I think

mint barn
errant barn
#

could you retry installing the hooks?

mint barn
#

pip install git+https://github.com/psf/black@21.12b0

#

?

errant barn
#

pre-commit install probably

#

don't know how to purge the env though, hopefully that will override it

mint barn
#

did not seem to change much

errant barn
#

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

errant barn
#

although could be that the way pre-commit installs black is somehow flawed

#

maybe update its version also, just in case :D

mint barn
#

alright, I can confirm that manually creating a _black_version.py solves this

errant barn
#

well at least, good to know

mint barn
#

thanks a lot Felix, this was driving me insane for a couple of hours

errant barn
#

if you're satisfied with that then my pleasure :D

mint barn
#

now I can go black and don't go back

errant barn
#

never go back

tired shard
frozen yacht
#

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

dense jungle
bright glacier
#

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

flat krakenBOT
dense jungle
#

the PR integration seems to have broken (I just merged two PRs)

bright glacier
#

Yeah hey @delicate marsh is the webhook / cloudflare worker failing?

plain atlas
#

i know why

nova comet
#

why?

plain atlas
#

I have a pr to fix it

nova comet
#

hmmmm, sounds like a solution to me

plain atlas
#

SebastiaanZ/github-status-embed-for-discord#3

toxic stormBOT
plain atlas
#

wait

#

I'm a bit tired

#

this is unrelated

#

ignore me

late dewBOT
#

github-filter/src/index.ts line 156

let template = `​https://discord.com/api/webhooks/${id}/${token}/github?wait=1`​```
bright glacier
#

I don't have maintain / admin permissions so I can't check if the webhook is firing successfully on psf/black's side.

plain atlas
#

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

delicate marsh
#

huh - unsure

tired shard
#

cloudfare HSA had banned pydis πŸ˜”, should we working now ig, even the pydis logs had died (see #dev-contrib for info)

flat krakenBOT
tired shard
#

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 πŸ˜„

flat krakenBOT
tired shard
#

and merge conflict πŸ™ƒ

flat krakenBOT
tired shard
#

oh whelp typing_extensions not present

#

πŸ‘€

errant barn
#

@tired shard re: dict type hints, have I missed something?

#

about Dict[str, Any] not being correct for function arguments

tired shard
#

and mypy complaining about the same

errant barn
#

mypy is too smart..

tired shard
#

lol