#black-formatter

1 messages ยท Page 23 of 1

spare hamlet
#

I am using replit

tribal thistle
#

Ironically, this is both the wrong and right channel to ask in

#

Black may be able to fix some of your simpler problems though, its a tool that auto formats your code

bright glacier
#

@plain atlas can you ask your question again, it got deleted unintentionally

vivid pasture
#

Sorry about that

bright glacier
#

No worries, thanks for the swift action ๐Ÿ‘

plain atlas
#

how are python warnings set to be emitted during running? Ik its something with the W flag....

plain atlas
#

okay, got it

#

python -W always
or PYTHONWARNINGS=always

bright glacier
#

nah, you're totally fine

#

(ah fuck wrong channel - i'm in staff voice right now)

plain atlas
#

;-;

#

i've added it to my zsh script that i run to init my terminal for coding

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Still surprisingly slow at ~1.2s on my machine but this is good enough (and won't slow build + test cycles by any reasonable margin). Thank you for the quick turnaround!

FWIW while it's great you're working on black-primer, I'm currently writing a semi-replacement for the development tool: https://github.com/ichard26/diff-shades. Fundamentally it takes the idea of black-primer and extends it with whatever great ideas mypy-primer added (theirs was inspired by ours), notably diffing support ...

flat krakenBOT
bright glacier
#

... now I think about it, I should probably check windows

tribal thistle
#

U call?

bright glacier
#

Uhm what?

tribal thistle
#

I usually like to break things on windows, anything I can help with?

bright glacier
#

Oh alright then, if you could setup a quick test environment for dawn's PR and cd into some random directory (\tests should do) that isn't the project root and verify no tests break that'd be awesome.

#

should be roughly these steps (yeah i'm not using pipenv)

#

although you'll have to checkout dawn's PR instead just cloning psf/black

tribal thistle
#

Tested on 3.9, no unexpected failures

bright glacier
#

alright so dawn's PR is good to ship :)

silent apex
#

woohoo!

bright glacier
#

thanks @tribal thistle and @silent apex lemon_hyperpleased

silent apex
#

Ahh, I completely missed Marco's second comment, thanks for fixing it!

#

I swear I copied that code directly from his comment, I guess I removed it for some reason

flat krakenBOT
bright glacier
#

@red sedge in what way?

red sedge
#

I suggested changes but the permalink link to them doesn't work?

bright glacier
#

yea not sure what happened to that link

red sedge
#

Sometimes two and sometimes 2

#

It will be harder to grep for them when removing the code

bright glacier
#

I mean, I explicitly split the PR into two commits so we could just revert the second one

#

But sure I can do that

red sedge
#

Black helps avoid a whole bunch of pedantry, it has to spill out somewhere

flat krakenBOT
bright glacier
red sedge
#

One has a semi and the other doesn't...

bright glacier
#

huh?

red sedge
#

A semi colon

bright glacier
#

how does a semi-colon get into my code, sigh, where is it?

red sedge
bright glacier
#

oh I see, I personally I disagree it's worth fixing but alright

#

looks good now?

red sedge
#

Yeah I wouldn't have mentioned it if it didn't go with the two/2

#

Deprecate; python two support

bright glacier
#

Oh wow not only did mypyc NOT subtly change black's formatting behaviour (woo!) main has no formatting differences compared to 21.9b0 as well ๐Ÿ‘€

plain atlas
#

!remind @bright glacier 1y that bug that just cropped up? its def related to this. /hj

late dewBOT
#
I don't think so.

You can't mention other members/roles in your reminder!

plain atlas
#

damn it

bright glacier
#

I can't either unfortunately, mod+ only

plain atlas
#

aha

bright glacier
#

building python from source with all of main optimizations disabled + interpreted mypy = you're gonna be having a long "grab a cup of coffee break"

dense jungle
#

Let's merge some PRs

bright glacier
#

I'm opening one right now :)

#

somehow we didn't notice that the loop parameter was removed in the various asyncio high-level APIs in 3.10

#

I'm surprised we haven't gotten a report about this since this code should crash if hit

flat krakenBOT
bright glacier
#

Other than ลukasz, I'm pretty sure the Python 2 deprecation PR has enough reviews. Should we merge it @dense jungle ?

dense jungle
plain atlas
#

Considering how major it is, maybe not??

dense jungle
#

Looking at the --verbose one right now

plain atlas
#

-v is fun

bright glacier
#

ah yeah I ignored that one because I didn't want to think through their suggestion

bright glacier
dense jungle
#

I am fully expecting to merge it to be clear, just want to take another look at the code

plain atlas
#

Although

#

Should it be pending deprecation warning and then next month switch to deprecation warnings?

#

Because deprecation warnings can break stuff

bright glacier
#

Well black is still an application so I'm not sure how I'd feel using the warnings API

plain atlas
#

Lemme check the code then

#

Which pr

bright glacier
#

we could add it tho, I wouldn't block that suggestion

#

psf/black#2523

toxic stormBOT
bright glacier
#

I mean, black both doesn't have an official API and Python 2 has been sun-setted for a long time now

dense jungle
#

I don't think the warning API is a good fit for us

bright glacier
#

Not yet although we want to work on this eventually. Personally I plan to work on this when I finish up with the various projects I'm currently working on (it's a lot btw).

plain atlas
#

Okay yeah

#

Just checked

#

Looks fine, mostly

#

What does err() do?

#

I'm on mobile right now so couldn't find the definition

bright glacier
#

One potential problem I do want to bring up is that right now each call to format_str with Python 2 warns

#

... that may be too noisy

plain atlas
#

For right now, that seems too noisy lol

#

Maybe in December tho

flat krakenBOT
plain atlas
#

Could save a variable once it's warned once and only warn if that variable isn't x

bright glacier
#

yeah that seems like a decent idea

plain atlas
bright glacier
#

....

plain atlas
#

Smh I missed that

#

Imagine finishing a project tho

#

I add a new one like every week or so

dense jungle
#

I'm trying to understand the print/exec stuff in the Python 2 PR now. Is the point of that to make sure we notice that the code is Python 2-only so we warn about it?

#

There's a bunch of other things we could look for, though I'm not sure it's worth the effort (except Exception, e:, 2L, def f((a, b)): come to mind)

#

oh and backticks though I'm not sure anyone ever used those

flat krakenBOT
plain atlas
#

I wonder

#

Wouldn't the mode need to be set to python2 to format python 2 code?

#

Eg the list of modes to format for in pyproject.toml

dense jungle
#

nope

#
2L
#

By default we use a lib2to3 grammar that is compatible with both Python 2 and Python 3

plain atlas
#

How is 2L valid in py2??

silent apex
#

Why doesn't black have an official API? Is there a reason there's not one, besides just not making it?

plain atlas
#

Because Ichard hasn't made it

dense jungle
#

In Python 2 int was limited to a machine int (32 or 64 bit) and long was the arbitrary-precision type

dense jungle
plain atlas
silent apex
flat krakenBOT
plain atlas
bright glacier
#

those were the only Python 2 only things I knew off the top of my head

dense jungle
#

They're probably also the easiest to detect ๐Ÿ™‚ . I'm a bit worried it won't be enough since exec is rare anywhere and print is also rare in many big codebases

#

Then again, I don't really want to go out of my way to help people who still write Python 2-only code in 2021

#

Reading the what's new brought up a few more: 0360 for octal literals; raise Exception, "message" syntax; [x for x in 1, 2] (needs parens in Python 3). Honestly those are all pretty marginal though

bright glacier
#

there's also the automatic unpacking in parameters (mind blown btw)

dense jungle
#

Yes, I listed that above. That was pretty useful actually ๐Ÿ˜ฆ I had to make some code uglier when migrating to Python 3 to deal with that

dense jungle
#

I think we should merge the Python 2 PR as is but there are conflicts blocking a rebase

bright glacier
#

I'll take a look tomorrow

plain atlas
#

lmao the test stuff that was causing a problem and not allowing the tests to be ran from a different directory....

#

I just made a simple script for my project so that isn't a problem lmao

#

although

#

i can't pass anything to it anymore, so uh, forget i said anything

fallow briar
#

e

plain atlas
#

do you mind?

#

you can't ping everyone, don't bother trying

tired shard
#

thanks jelle for the review, will take a look soon

gusty grail
#

@median garnet This channel is for discussion about usage and development of Black, a python code formatter. I've deleted your messages since it's off-topic for this channel. See #โ“๏ฝœhow-to-get-help for instructions on claiming a help channel.

sturdy charm
#

How do i compile python in windows 7 without actually having to download python (exe)

#

what are python developers trying to hide ?

bright glacier
#

Wrong channel, but also why?

sturdy charm
#

PGO and security

#

why ask why ?

bright glacier
#

the windows binaries are already compiled with PGO

sturdy charm
#

well then security (want to build from source)

#

FOSS

#

???????????????????????????

bright glacier
#

that's OK, just please use a different channel then. I'm not sure which one would be ideal though.

sturdy charm
#

so no one knows and python developers are trying to hide something ?

bright glacier
#

Well I don't work with C on a daily basis on Windows, and I doubt the core developers of a pure python project (psf/black) would know either. #c-extensions or #internals-and-peps *may* know more but I honestly have no idea.

#

TIL black-21.9b1.dev51+gb0b3709-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl is a valid wheel filename

#

that's alotta platform and ABI tags ๐Ÿ‘€

#

what's blocking the 0.920 mypy release btw @dense jungle ?

#

man, I hate you windows

#

oh lol I forgot mypyc doesn't support python 3.10 officially

#

well I guess I'll skip windows on python 3.10 then for the time being

slow ibex
#

before

bright glacier
#

yea... the # fmt: skip implementation is incredibly buggy ๐Ÿ˜ฆ

slow ibex
#

this works ok

#

why black crashes on this?

bright glacier
#

because we don't support match case syntax

slow ibex
#

shouldn't it be skipped?

bright glacier
#

that's not how the fmt: off/on implementation works, the whole file is still parsed

slow ibex
#

ok, thanks

flat krakenBOT
#

Describe the style change

This code is successfully formatted and accepted by Black:

assert name.rfc4514_string(
    {NameOID.COMMON_NAME: "CommonName", NameOID.EMAIL_ADDRESS: "E"}
) == ("CommonName=Santa Claus,E=santa@northpole.fi")
#    ^                                             ^

The parenthesis on the last line are redundant and can be removed. I wouldn't expect the formatting to be changed by Black.

However, with this input:

assert na...
neon loom
#

Halloween release? Quite a few things in changes.md ....

#

lol - Nice work bot

bright glacier
#

should probably include the python 2 deprecation today then

#

I've been working on the mypyc project so far today

neon loom
#

It ready for me to click merge?

bright glacier
#

which PR?

neon loom
#

Your python2 deprecation - Looks it to me

neon loom
#

@bright glacier - Want to see how much slower this is too?

bright glacier
#

As in you want me to benchmark it?

neon loom
#

If it's easy

bright glacier
#

I'm a little too busy for that for the time being

neon loom
#

No worries

#

If I get bored later I might try your tool

#

Just interested cause if we're not to much slower i might see if we can fix the unicode issues via monkey patching re possibly - Ideally we'd just fix it in cpython but that will take years to become the version everyone uses (but if I work it out I might submit the PR - but I need to remember all the context)

plain atlas
plain atlas
blazing pike
#

does lack support match statements in 3.10 yet?

tribal thistle
#

Noot yet

blazing pike
#

sadness

dense jungle
#

@bright glacier about mypy 0.920, I don't know what's blocking it. mypy releases are done by the people at Dropbox and I don't have much insight into when they can do it

#

I heard they're no longer working on mypy full-time so it's probably just whenever they have time

#

I think the Python 2 PR needs to be rebased because we wanted to keep the two commits separate. I can do that later in the afternoon after I recover from climbing this hill ๐Ÿ™‚

flat krakenBOT
dense jungle
#

there we go

flat krakenBOT
#
  • Install build-essential to avoid build issues like #2568 when dependencies don't have prebuilt wheels available
  • Use multi-stage build instead of trying to purge packages and cache from the image
    Copying /root/.local/ installs only black's built Python dependencies (< 20 MB).
    So the image is barely larger than python:3-slim base image

Tested locally and in my fork GitHub Actions: https://github.com/vbarbaresi/black/runs/4062490765?check_suite_focus=true

flat krakenBOT
neon loom
#

Ok, think I'll merge the docker and then cut a release unless anyone says not to - PR coming.

bright glacier
flat krakenBOT
neon loom
#

Why do we have more manual things to do @ release ๐Ÿ˜ฆ Booo

dense jungle
neon loom
#

We also have a lot of deprecation errors to fix

bright glacier
#

I'mma check on a laptop

neon loom
#

I think I'll put up a PR to remove this version manual step. I don't think the step it adds for each release now is worth it

bright glacier
neon loom
#

And TIL we have two files called the_basics.md

bright glacier
# bright glacier

Do I just not understand what a rebase merge is like or does that look like a squash merge?

bright glacier
neon loom
#

Damn, another file. We haz so much manual editing now. I might at least make a set_version.py or something that goes and does all the version replacing ...

bright glacier
#

we could probably automate it using a local sphinx extension

bright glacier
#

damn this will be our sixth release in a row in terms monthly releases, way to go on the consistent quicker deploy cycle

#

once again thank you @neon loom for getting the ball rolling on this front :)

flat krakenBOT
bright glacier
#

We should probably let people know via other channels that this release is important as we now have a formatting stability policy AND Python 2 is deprecated

neon loom
#

Where do you propose?

bright glacier
#

we could also do a mailing list or two but do people even pay attention to those these days?

toxic stormBOT
silent apex
#

Maybe "banner" is the wrong word, but one of those 20px lines that are on the top of every page, or at least the first

bright glacier
#

also great ideas

silent apex
#

Yeah, the "if you like this theme" thing

neon loom
#

48MB. Nice

bright glacier
neon loom
#

Banner etc. + twitter could be good. Maybe you start a post @bright glacier and I'll report and we nudge @ambv too

neon loom
#

I'm heading for dinner now - But if you don't get to it I'll try get some issues opened so we can fix em

#

Let me know if you tweet - I don't really look at twitter much

bright glacier
#

thankfully the loop parameter was only being passed in some exception / cleanup code so it'd be rare for those (crashing) pieces of code to be hit but yea we should probably set up pytest to fail loudly on new warnings

neon loom
#

Yeah, lets get it clean and fail on warnings

tired shard
#

Hey @errant barn ,
Re: https://github.com/psf/black/pull/2526#issuecomment-947563571

What do you think would be a good way to handle this, we are checking for configuration first so it is logged earlier, but if we don't check it earlier and black fails due to a config value (eg. pyi and ipynb- both were passed), it would never reach the project root log, so we need to log the configuration earlier.

errant barn
#

hmm true, didn't consider that

lean path
#

Can somebody teach me python

#

Please

tired shard
flat krakenBOT
#

Look, implementing tabs support is pretty simple and you don't have to make it default. You literally just have to add an option like --use-tabs and implement tabs in the code. Prettier does it, pretty much every other code formatted I use at least has an option to use tabs. you can't say that you are "LisTeNinG tO tHe CoMmUNity" when there are FOUR issues or pull requests relating to using tabs, and all of them have been rejected. You CAN'T ignore that there are some people w...

bright glacier
#

I'm a little nervous that @muted haven 's PR is going to break mypyc compatibility as it touches blib2to3 quite significantly but I can't imagine it would be horrible to fix ... unless there's dataclasses involved in which case CI gonna's be red :)

#

also the merge conflicts will be ... a bit of a pain to deal with :)

plain atlas
bright glacier
#

I suspect this will undo some of my blib2to3 optimizations as well eek!

plain atlas
#

that was a good read

#

why are consumers of open source and free software the most entitled

dense jungle
dense jungle
plain atlas
#

lol i'm reading all of the issues that they linked

#

there is even a fricking solution

#

actually that does it in reverse

#

holy shit

plain atlas
dense jungle
#

oh is that the guy with the dictionary definitions?

plain atlas
#

yess

#

LOL

#

"Use tabs instead of spaces for indentation. "
"Tabs are always equal to 4 spaces."

#

which isn't true tho

#

tabs are just tabs

muted haven
plain atlas
dense jungle
# muted haven uh, sorry about that. I can type the code, but not sure if there are any stuff t...

for context the potentially conflicting changes are https://github.com/psf/black/pull/2431/files#diff-752cb00af77ac75adb6cb5b53d3c28691db40cee3e2f517d755bcea983e7ec99 vs. https://github.com/isidentical/black/commit/c22fca62bdeca503ef1fa56647b410cbd3d5af81. Looks like the addtoken method might get some gnarly conflicts and the match code needs some annotations.

GitHub

It's finally happening ๐ŸŽ‰, the initial work was done several years ago in GH-1009 by @ msullivan is now being followed through by yours truly. If this work doesn't find its way to Py...

silent apex
red sedge
#

I just don't get how this is such a thing

plain atlas
#

Because\tpeople\tneed\ttheir\ttabs

red sedge
#

Pretty sure there's a fork/wrapper that runs black and replaces spaces with tabs

tribal thistle
#

Many lol

plain atlas
#

Yeah

#

It's not hard

#

It's literally a one line change within black's source

red sedge
#

Tabs for indentation spaces for alignment

plain atlas
#

Wouldn't py3 choke on that?

red sedge
#

I think you can use any whitespace in a parenthetical

#

Don't quote me on that though

uncut quiver
#

Hi, what is the function that reformats a file's content?

tribal thistle
#

Are you asking for the cli command, or are you looking for the function in the source code

uncut quiver
#

The function in the source code as I'm trying to reformat a string of code

tribal thistle
#

Call chain is:
main -> reformat_one/reformat_many -> format_file_in_place -> format_file_contents -> format_str (also check_stability)

#

If you're reformatting just a string, you may be able to skip right down to format_str, but option parsing is still a thing

uncut quiver
#

Alright thank you

tribal thistle
#

You could use reformat_code though, which does take a string, no file

uncut quiver
#

Yeah I will try both

sour jay
plain atlas
sour jay
#

;-;

plain atlas
#

Honestly i don't even know what that user was thinking

#

intellectually inconsistent

#

Like

#

WTF does that even mean

sour jay
#

Only intellectually consistent people would get that ๐Ÿ˜ค

plain atlas
#

Smh

bright glacier
#

what did black do :O

#

They are compiled dependencies to be fair

plain atlas
#

i don't get that, tbh

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,python2];
      ...
dense jungle
bright glacier
neon loom
dense jungle
neon loom
#

blib2to3 itself, too, uses regex ...

dense jungle
#

Yes, I think that's where we need it. But maybe we can do something manual in a few places so it still supports those exotic identifiers

mint barn
#

@fallow saffron

#

@fallow saffron

flat krakenBOT
#

This is a work-in-progress PR for the following issue: https://github.com/psf/black/issues/2242.

To-Do:

  • Add tests
  • Figure out why Python 2 tests are failing (the rest of the tests seem to be OK)
  • Try primer / gallery as well as large dataset of source code to ensure it is still parsing everything it could before (only the handling of soft keywords changed, but still let's make sure of that since this touches the core part of the parser (addtoken)).
bright glacier
#

@muted haven I'll do some testing on this PR as I (finally) have free time. I'll check mypyc compat and behaviour equivalence with my own tool, diff-shades, with is basically black-primer / gallery but more integrated and full-featured (eventually, it's a WIP). If I feel like it I'll do some benchmarking but I make no promises on this one :)

#

I honestly have no idea why those two tests are failing either :(

dense jungle
#

Apparently it's not printing the Python 2 deprecation message? Not sure why that would be

muted haven
#

AFAIK it can't currently parse the python2 code, but don't know why it shouldn't affect much

#

I have not yet found time to research it

bright glacier
#

Yea... the grammar fallback code should handle it just fine ...

muted haven
#

hopefully on weekend I can get to some of these issues

bright glacier
#

Oh and just to be clear please don't feel like your work on gallery was pointless, at the bare minimum it spawned the creation of black-primer, which then inspired mypy-primer which then inspired me to create diff-shades haha :)

#

Also I'm fairly confident other people from the core team has used gallery before, I just haven't

#

Your creation is a parent lol

muted haven
#

Oh no worries on that. Gallery was an interesting experience for me, since it also inspired another project (reiz) that I ended up writing a paper about.

bright glacier
#

Of course, so gallery is the source of many great things ๐Ÿ˜„ /lh /gen

muted haven
#

Indeed

#

Also it was my first contribution to black, so there's that. Hopefully this would be the second one (and perhaps more to come)

bright glacier
#

Oh my, the merge conflict on src/blib2to3/pgen2/parser.py with the mypyc branch as the base is way smaller than I expected ๐Ÿ‘€ :)

#

recursive merge strategy for the win I suppose!

#
Traceback (most recent call last):
  File "/home/ichard26/.local/share/virtualenvs/black-Q9x7i-w-/bin/black", line 5, in <module>
    from black import patched_main
  File "src/black/__init__.py", line 39, in <module>
    from black.nodes import STARS, syms, is_simple_decorator_expression
  File "src/black/nodes.py", line 32, in <module>
    pygram.initialize(CACHE_DIR)
  File "src/blib2to3/pygram.py", line 175, in initialize
    python_symbols = _python_symbols(python_grammar)
  File "src/blib2to3/pygram.py", line 32, in __init__
    setattr(self, name, symbol)
AttributeError: '_python_symbols' object has no attribute 'asexpr_test'

first issue trying to run the mypyc compiled version of the match PR :)

bright glacier
#
1โฏ black test.py --diff -v --fast
Using configuration from /home/ichard26/programming/tools/diff-shades/pyproject.toml.
Traceback (most recent call last):
  File "/home/ichard26/programming/tools/diff-shades/venv/lib/python3.8/site-packages/black/__init__.py", line 643, in reformat_one
    if changed is not Changed.CACHED and format_file_in_place(
  File "/home/ichard26/programming/tools/diff-shades/venv/lib/python3.8/site-packages/black/__init__.py", line 796, in format_file_in_place
    dst_contents = format_file_contents(src_contents, fast=fast, mode=mode)
  File "/home/ichard26/programming/tools/diff-shades/venv/lib/python3.8/site-packages/black/__init__.py", line 920, in format_file_contents
    dst_contents = format_str(src_contents, mode=mode)
  File "/home/ichard26/programming/tools/diff-shades/venv/lib/python3.8/site-packages/black/__init__.py", line 1057, in format_str
    src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions)
  File "/home/ichard26/programming/tools/diff-shades/venv/lib/python3.8/site-packages/black/parsing.py", line 96, in lib2to3_parse
    raise exc from None
black.parsing.InvalidInput: Cannot parse: 3:6: match xt:
error: cannot format test.py: Cannot parse: 3:6: match xt:
Oh no! ๐Ÿ’ฅ ๐Ÿ’” ๐Ÿ’ฅ
1 file would fail to reformat.

~/programming/tools/diff-shades on main [$?โ‡ก] via v3.8.5 (venv) took 400ms 
123โฏ cat test.py
x = hi

match xt:
    case (a, n):
        pass

what-

#

pip install-ing a local clone with the match PR did not grant black the magical ability to parse match ๐Ÿ˜ฆ

plain atlas
#

are you running the correct black?

bright glacier
#

yes

#

sigh

dense jungle
#

and you don't have local .so files lying around?

plain atlas
#

stack overflow files?

#

what are .so files?

bright glacier
#

no compiled C

plain atlas
#

o

dense jungle
#

it stands for shared object

plain atlas
#

ah

bright glacier
bright glacier
#
12 failed, 251 passed, 3 skipped, 12 deselected, 3 xfailed, 12 warnings in 22.15s
``` OK this might take a while to fix ...
#

hmm, looks like the token.* numbers got shifted around?

#

yup they did

#

I don't understand how the numerical IDs are calculated tho

flat krakenBOT
#

Describe the style change

Examples in the current Black style

len_x1y1 = math.pow(rec_po[0].x - rec_po[1].x, 2) + math.pow(
        rec_po[0].y - rec_po[1].y, 2
    )

Desired style

len_x1y1 = math.pow(rec_po[0].x - rec_po[1].x, 2) + math.pow(rec_po[0].y - rec_po[1].y, 2)
# or
len_x1y1 = ( math.pow(rec_po[0].x - rec_po[1].x, 2) 
             +math.pow(rec_po[0].y - rec_po[1].y, 2))

Additional context

flat krakenBOT
onyx quarry
#

Does black not support python 3.10?

#

Run into errors when I use match

errant barn
#

Yes and no: no on the new syntax but yes on general runtime

onyx quarry
#

is there a way to just have the formatter skip the lines so i can still format the rest of the file

#

fmt: off doesnt seem to be doing anything

#

as far as stopping a crash

errant barn
#

We still need to parse the file, so unfortunately I think not

onyx quarry
#

what do you suggest, should I just turn formatting off for the file until its supported?

errant barn
#

you can follow psf/black#2242

toxic stormBOT
errant barn
#

In the meantime, probably yeah

onyx quarry
#

Thanks

flat krakenBOT
#

Is this related to a problem? Please describe.

Visiting https://black.readthedocs.io/ redirects one to https://black.readthedocs.io/en/stable/ . This is the documentation for version 21.9 , so users can easily misses changes made for 21.10, such as those in: https://black.readthedocs.io/en/latest/integrations/source_version_control.html .

Describe the solution you'd like

Update 'stable' to point to 21.10

Describe alternatives you've considered

n/a

**Additional co...

bright glacier
#

@silent apex do you mean all releases by "minor" or did you mean to say "major"?

silent apex
#

Err, I meant whatever 21.09 and 21.10 are

#

Idk what versioning scheme black uses

#

Apologies if that was unclear, the only versioning I speak is semver

dense jungle
#

we don't really have major vs. minor versions, it's just a matter of how many we get out in a month

#

which does make it more awkward to select which versions to show in the docs

plain atlas
#

calsemver ;-;

silent apex
#

Well then uh, whatever a new version is (21.09, 21.10, 21.11, etc.)

#

The terminology doesn't really matter

tribal thistle
#

Powerplay: 21.101

uncut ivy
#

!e

flat krakenBOT
#

Description

Nice and simple change, a space was missing which was causing some ugly text:

Original:
DEPRECATION: Python 2 support will be removed in the first stable releaseexpected in January 2022
Now:
DEPRECATION: Python 2 support will be removed in the first stable release expected in January 2022

Checklist - did you ...

  • [ ] Add a CHANGELOG entry if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
    ...
flat krakenBOT
#

Describe the style change

Break up and indent long method chaining inside a dictionary in a more readable way

Examples in the current Black style

How black breaks up method chaining in variable assignments:

value = (
    fn.chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
)

How black does it with dictionary key assignments:

d = {
    foo: fn....
dense jungle
tribal thistle
#

I think I ran into this not all that long ago

#

Did you recently upgrade any deps?

dense jungle
#

Don't think so, but we may not have pinned this dep

tribal thistle
#

Yeah, it's a known issue with the latest version of coveralls

#

Actually, this isn't the first time a change in coverage.py has broken the coveralls package

#

A lot of the issue history is fixing that

bright glacier
#

Since I'm getting closer to integrating my mypyc work into main, I was wondering on how we'd collect field reports from users. My original idea was to use Google Forms but a GitHub issue would also work well. Google Forms would be more structured but the lack of transparency can be bit of an issue for some people. Additionally an issue would be easier to ask follow-up questions within while a Google Form would require a "contact info" field.

#

... I guess my pros-cons list is leaning towards a gh issue :)

sour jay
#

Doesn't it come pretty naturally for people to just find the repository and open an issue?

dense jungle
#

Yes, I think issues are fine

silent apex
#

GitHub issues or discussions (a single thread maybe, since there are comments on replies) sounds fine to me personally

bright glacier
#

feels good to be making actual progress on diff-shades even if I'm still horribly slow :)

#
src/diff_shades/analysis.py:    # TODO: record log files if available
src/diff_shades/analysis.py:    # TODO: allow more control w/ black.Mode so we could use diff-shades to compare
src/diff_shades/analysis.py:    # TODO: refactor this and related functions cuz it's a bit of a mess :)
src/diff_shades/cli.py:        # TODO: implement a list view
src/diff_shades/cli.py:        # TODO: implement a diff + failures view
src/diff_shades/cli.py:    # TODO: allow filtering of projects and files checked
src/diff_shades/cli.py:    # TODO: more informative output (in particular on the differences)
src/diff_shades/cli.py:    # TODO: Gracefully warn but accept analyses that weren't set up the exact same way.
src/diff_shades/cli.py:            "[italic]-> Eventually this will be just a warning, but that's a TODO"
src/diff_shades/cli.py:# TODO: implement this command :p

got a ton of TODOs tho haha

open crystal
#

black lives matter

bright glacier
#

Yes they do! .. although it's a little off-topic here fwiw

open crystal
#

richard

bright glacier
#

yeah?

open crystal
slow ibex
#

this is terrible```py
# it is kw argument
partner_id_and_days=CustomCallable(
decode=lambda buf: 0
if buf.read_uint(pos=buf.pos) == 0
else (buf.read_uint(), buf.read_uint()),
encode=lambda buf, obj: buf.write_uint(0)
if obj == 0
else (buf.write_uint(obj[0]), buf.write_uint(obj[1])),
),
# ... other arguments

bright glacier
#

We are aware :)

#

There's a work-in-progress PR to fix this

slow ibex
#

thanks ๐Ÿ‘

bright glacier
#

psf/black#2278

toxic stormBOT
thin coyote
#

hello guys

bright glacier
#

OK we have less than three months to get black ready for a stable release ... there's a lot of work to be done still:

  • improve Python 2 detection
  • integrate and deploy mypyc
  • implement basic / experimental match support
  • land PyPy support
  • merge psf/black#2278 (maybe lock this under the --future flag?)
  • merge psf/black#1879 (and lock the formatting under the --future flag)
  • turn on ESP
toxic stormBOT
bright glacier
#

what's annoying about the first three is that they're connected and merging one of them will complicate the others

bright glacier
#

our codename for --experimental-string-processing

silent apex
#

Ah, got it

bright glacier
bright glacier
#

am I being dumb or is the following valid code:

value = (1, 2)

match value:
    case x, y:
        pass
#

I can't get the match support PR to accept this fwiw ๐Ÿ˜ฆ

silent apex
#

on 3.10.0, at least

bright glacier
#

the following works:

value = (1, 2)

match value:
    case (x, y):
        pass

although I have no idea why, I'd need to take a closer look at the grammar to figure out why

silent apex
#

I'd guess it's like x, y = (1, 2) and (x, y) = (1, 2)

bright glacier
#
match_stmt: "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT
subject_expr: namedexpr_test

# cases
case_block: "case" patterns [guard] ':' suite
guard: 'if' namedexpr_test
patterns: or_test ['as' or_test]

this is the main bit of the blib2to3 grammar that's powering the PR but I don't understand patterns in particular or_test very well

bright glacier
muted haven
#

If you could post it under the PR, I'll try to check if it works or not.

bright glacier
#

the TLDR is that I messed up when writing up the python 2 deprecation PR

#

in more details I was using the token.* constants to detect the python 2 features. token.* is only guaranteed to be constant below a node type value <256 and the Python 2 nodes were above that. I should've been using pygram.python_symbols instead

tired shard
bright glacier
#

I'm confused, could you elaborate?

plain atlas
#

!d lib2to3

late dewBOT
#

Source code: Lib/lib2to3/

Deprecated since version 3.11, will be removed in version 3.13: Python 3.9 switched to a PEG parser (see PEP 617) while lib2to3 is using a less flexible LL(1) parser. Python 3.10 includes new language syntax that is not parsable by lib2to3โ€™s LL(1) parser (see PEP 634). The lib2to3 module was marked pending for deprecation in Python 3.9 (raising PendingDeprecationWarning on import) and fully deprecated in Python 3.11 (raising DeprecationWarning). It will be removed from the standard library in Python 3.13. Consider third-party alternatives such as LibCST or parso.

Note

The lib2to3 API should be considered unstable and may change drastically in the future.

bright glacier
#

We use lib2to3 as our main parser, just a fork of it

plain atlas
#

fyi @tired shard black doesn't know that the code is there at all, black can format py2 without python2 installed.

tired shard
#

lib2to3 reads python2 code and applies some fixes to make it compatible with python3 right? So if we just use this tool to convert the source and then check the original code and to check if there is a diff, we can find if the original code is python2 or 3.

Example

-print "printing something"
+print("printing something")

This is the first think that popped in my mind.

bright glacier
#

That's probably a bad idea from a performance perspective

plain atlas
#

the problem in that case is insane performance ^^

bright glacier
#

anyway I'm almost done with my solution

plain atlas
#

sure, it could work, but like

#

one sec

tired shard
#

well yeah

plain atlas
#

okay uh nvm

#

why is black taking one fourth of a second to format 61 files

#

;-;

bright glacier
#

cache

plain atlas
#

ah, where do i nuke that?

bright glacier
#

I actually have to clear the cache everytime I test something out

tired shard
#

~/.cache/black

tired shard
#

isn't there a clear cache option

bright glacier
#

nope.

tired shard
#

it would good to have one imo

bright glacier
#

I've actually made my own dropblackcache utility for this exact reason lol

plain atlas
#

interesting, it took 15 seconds to format my 61 files

#

its taken longer before lmao

muted haven
#

Thanks @bright glacier for the info, I'll try to get back to PR tomorrow and fix the case you sent!

plain atlas
#

oh well, ig it didn't make any file changes since they were already formatted facepalm

#

welp, my git status is clean

bright glacier
#

I also have a local patch fixing some other issues for your branch fyi

plain atlas
#

30 modified files now

plain atlas
#

THAT WAS NOT 27 SECONDS

#

!snf 906600530388852747 906600635267424267

late dewBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

plain atlas
#

...

bright glacier
#

!snf 906600530388852747 906600635267424267

late dewBOT
#
Snowflakes

906600530388852747
Created at 2021-11-06 17:46:50.268000+00:00 (<t:1636220810:R>).

906600635267424267
Created at 2021-11-06 17:47:15.273000+00:00 (<t:1636220835:R>).

plain atlas
#

....that was 25 seconds

#

no, that was 5 seconds

#

wtf is wrong with time

#

41 files reformatted, 20 files left unchanged.
black . 23.61s user 0.75s system 613% cpu 3.974 total

bright glacier
#

are you reading the user time

#

cuz it won't be accurate due to multicore usage

#

IIRC

plain atlas
#

ohhhhhhhhhh

#

so if it was on one core, it would have taken 23.61 seconds then?

bright glacier
#

I honestly don't remember if time measures the wall clock or CPU time so I can't answer that quesiton

plain atlas
#

hmmm

#

;-;

#

idk

#

anyways uh

plain atlas
#

even with no changes

#

yapf . -rip

flat krakenBOT
#

Description

First of all this fixes a mistake I made in Python 2 deprecation PR
using token.* to check for print/exec statements. Turns out that
for nodes with a type value higher than 256 its numeric type isn't
guaranteed to be constant. Using syms.* instead fixes this.

Also add support for the following cases:

print "hello, world!"

exec "print('hello, world!')"

def set_position((x, y), value):
    pass

try:
    pass
except Exception, e...
bright glacier
#

oh yea ci is going to break most likely

muted haven
bright glacier
#

@tribal thistle so wait, how am I supposed to fix coveralls breaking the action?

#

apparently the most recent release of coveralls-python should've fixed this but no?

tribal thistle
tribal thistle
#

Or maybe give your thoughts on TheKevJames/coveralls-python#334 ๐Ÿ‘€

toxic stormBOT
red sedge
#

It does worry me about the coverage py bus factor...

bright glacier
#

what the heck pandas, why are you so slow to format :/

tribal thistle
#

Mmm, to get help, make sure to post your code as text instead of a screenshot

#

Isnโ€™t pandas huge?

#

If it takes that long usually, itโ€™s probably best to disable it

bright glacier
#

Yeah but it took over an hour when Django only took a quarter of that

#

it usually doesn't take an hour

#

Either diff-shades is broken or this PR I'm testing has seriously broken something... Or both!

tribal thistle
#

Is this diff shades or primer

#

Ah

#

Roll back, test again. Keep rolling back until things work

bright glacier
#

30m on my laptop ๐Ÿ˜ฆ

tribal thistle
#

Lol right, hadnโ€™t thought about that

bright glacier
#

I looked into using a VM but I don't have access

tribal thistle
#

If it wasnโ€™t so late rn, Iโ€™d donate some CPU time

#

Tomorrow if youโ€™re still at it

plain atlas
bright glacier
#

thankfully it's just one project acting up

plain atlas
bright glacier
#

so I can just focus my testing on that which should cut down the testing significantly

plain atlas
#

Tbf you could probably formulate a workflow, remove concurrency options, and just push your changes and then come back to it once gha has finished running them

#

Iirc there's already a workflow for this

bright glacier
#

honestly it would be faster but I don't feel like making it

#

We don't have one for diff-shades

plain atlas
#

Ah.

bright glacier
#

I'm testing the experimental match statement pr fwiw

tribal thistle
plain atlas
#

Well, I'm going to go continue to shoot my future self in the foot while I procrastinate

bright glacier
#

Yeah #dualCoreCPULife

plain atlas
#

2Core2Life

tribal thistle
#

Is the code youโ€™re testing pushed to a repo somewhere?

bright glacier
#

yea, ichard26/diff-shades although it's non functional on GitHub, I have a few hotfixes locally I haven't pushed since I don't know if they're contributing to the weird slowdown

plain atlas
#

.gh repo ichard26/diff-shades

#

...

bright glacier
#

also it's pretty involved to repeat the run I got set up right now and since I'm eating (what else am I going to do) so yeah

plain atlas
#

ichard26/diff-shades#1

#

Why the github command is locked but the issues aren't idk

tribal thistle
#

It isnโ€™t, we removed the command

plain atlas
#

It is

#

You didn't see the error message lol

#

.gh repo ichard26/diff-shades

tribal thistle
#

Idk then

bright glacier
#

.gh help

toxic stormBOT
#
Command Help

**```
.github

**Can also use:** `gh`, `git`

*Commands for finding information related to GitHub.*

**Subcommands:**
**`repository [repo...]`**
*Fetches a repositories' GitHub information.*
**`user <username>`**
*Fetches a user's GitHub information.*
plain atlas
#

Its locked

bright glacier
#

.gh ichard26/diff-shades

plain atlas
#

;-;

bright glacier
#

.gh repo ichard26/diff-shades

toxic stormBOT
#

The Black shade analyser and comparison tool.

plain atlas
#

Also it should be easier to tell if it's a repo or user

#

Hmmm

tribal thistle
#

Uhh so where does analyze clone to lol

#

Also, on current main, 30 seconds in for a little above 50% on django

bright glacier
#

a temporary directory

tribal thistle
#

Holy mother of deprecation warnings

bright glacier
#

also this isn't that useful as I'm testing a pr of black

plain atlas
bright glacier
bright glacier
plain atlas
#

Oh.

#

Oh right this is black emitted warnings

tribal thistle
#

Alright nice, total analysis time was 4:06, and a minute clone time (and it only crashed once! ๐Ÿ˜…)

bright glacier
tribal thistle
#

If you want me to run that pr rn, let me know

#

That fast

bright glacier
#

I-

#

8 cores?

plain atlas
#

Inb4 16

bright glacier
#

nah 64

plain atlas
#

No 256

#

The sun is weaker than scales laptop

tribal thistle
#

4, but is this actually utilizing more than one lol

bright glacier
#

yea it's multicored

plain atlas
#

Actually, the sun is weaker than scale's legs with that much heat

bright glacier
#

wth ๐Ÿ˜†

tribal thistle
#

Dude. Laptop connected to desk monitor. Ultimate setup

plain atlas
#

Smh I don't use my laptop on legs either smh mh smh

tribal thistle
#

Was this meant to reformat like 18 of the 23 projects lol

bright glacier
#

I don't remember but that sounds close enough to right

plain atlas
#

@tribal thistle how fast is your internet?

bright glacier
#

Lemme get back to my computer

tribal thistle
plain atlas
#

A minute clone time for 23 projects is uh

#

Impressive

bright glacier
#

25/2 for me ๐Ÿ˜ฆ

plain atlas
#

Although I'd hope it's shallow cloning

tribal thistle
#

25/2 black/clone time?

bright glacier
#

It is

plain atlas
#

Also I would hope it clones to a cache dir instead of tempfile smh

bright glacier
tribal thistle
#

Ah

#

Lol I got so lost

#

This is shaping up really nicely so far btw

#

Just gotta suppress all them pesky warnings

plain atlas
#

Oh yeah I was meaning to rethink my life choices and read more documentation

bright glacier
plain atlas
#

I have written way too much extra code when apparently it's part of the stdlib, or even worse, part of builtins...

tribal thistle
#

Haha whatโ€™s in the output file

#

Itโ€™s just a 100mb json

plain atlas
#

Bye

bright glacier
#

alright I'm back on my laptop

bright glacier
plain atlas
#

I didn't leave yet blobsad

#

I don't want to work on my code

tribal thistle
#

Work on my code instead

bright glacier
#

lol

plain atlas
plain atlas
#

!d iter

late dewBOT
#

iter(object[, sentinel])```
Return an [iterator](https://docs.python.org/3/glossary.html#term-iterator) object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, *object* must be a collection object which supports the iteration protocol (the `__iter__()` method), or it must support the sequence protocol (the `__getitem__()` method with integer arguments starting at `0`). If it does not support either of those protocols, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") is raised. If the second argument, *sentinel*, is given, then *object* must be a callable object. The iterator created in this case will call *object* with no arguments for each call to its [`__next__()`](https://docs.python.org/3/library/stdtypes.html#iterator.__next__ "iterator.__next__") method; if the value returned is equal to *sentinel*, [`StopIteration`](https://docs.python.org/3/library/exceptions.html#StopIteration "StopIteration") will be raised, otherwise the value will be returned.
plain atlas
#

THERE IS A SECOND PARAM

#

....

tribal thistle
#

Lol

plain atlas
#

I definitely do not have a few classes which exist to just make a generation methods iterators

#

I really don't have them, nope. None

bright glacier
#

the reason why you need that analysis file is so diff-shades clones the right revision of the projects

plain atlas
bright glacier
#

so when comparing analyses only differences in the formatting output will be caught

plain atlas
#

Turns out iter(generate_id, None) would do the same thing

#

#notsalty

bright glacier
plain atlas
#

shit sorry for interrupting

bright glacier
#

ugh I wish I fully implemented the compare command

plain atlas
#

As apology I'll go review some code lemon_eyes

bright glacier
#

a run against a mainline version of black should see zero failures

#

assuming that diff-shades isn't borked, this is bad news for isidentical's match PR

plain atlas
#

Hmmmm

bright glacier
#

wait what

plain atlas
#

I have a small review detail heh

#

I mean

bright glacier
#

uhhhhhh this isn't a normal failure mode for black

plain atlas
#

I haven't looked at the code at all

plain atlas
bright glacier
#

two things

#

by failures I mean black erroring

#

and --repeat-projects-from exists for this very reason

plain atlas
tribal thistle
#

that's what we love to see

#

This is cloning btw lmao

plain atlas
#

Damn

tribal thistle
#

Taking significantly longer, I wonder if my internet is just bad. Two minutes so far

plain atlas
#

My computer runs basically at 100% all the time

bright glacier
#

no, I think it's because I wrote this stupid code

import contextlib
import os

with open(os.devnull) as blackhole:
    with contextlib.redirect_stderr(blackhole):
        black.format_file_contents
#

I forgot the "w" mode argument :(

plain atlas
#

Ahhhhhh

bright glacier
#

so this entire analysis is junk anyway

plain atlas
#

Wait why stderr and not stdout?

bright glacier
#

because that's where the deprecation message is printed to

tribal thistle
#

Where does devnul go on windows

bright glacier
bright glacier
tribal thistle
#

Sure

#

I'm still cloning, is this normal

bright glacier
#

to be fair the analysis I gave you is rather old so the cloning is much more expensive as it can't just do a simple shallow clone

tribal thistle
#

Ah, I see

bright glacier
#

you should probably use the --work-dir option btw so reruns don't have to clone as much

plain atlas
#

I wonder....

#

I feel like the deprecation message could use the warning api

#

And then in the main file

bright glacier
#

you were literally here when we discussed this

plain atlas
#

Configure the warnings to be printed

#

Yes but I explored more with the warning api since then smh

#

!d warnings

late dewBOT
#

Source code: Lib/warnings.py

Warning messages are typically issued in situations where it is useful to alert the user of some condition in a program, where that condition (normally) doesnโ€™t warrant raising an exception and terminating the program. For example, one might want to issue a warning when a program uses an obsolete module.

Python programmers issue warnings by calling the warn() function defined in this module. (C programmers use PyErr_WarnEx(); see Exception Handling for details).

plain atlas
#

Tldr I learned this was a thing

bright glacier
tribal thistle
#

nice, I'll check it out once cloning is done

bright glacier
#

in the mean while I'm going to check pandas by itself

#

via the -s / --select option

#

I know, I really tried to make this a half-decent tool

plain atlas
#

Using click?

bright glacier
plain atlas
tribal thistle
#

Yeah sure

bright glacier
#

I didn't take the time to implement decent diffing capabilities across analyses yet

#

right now the compare command is literally a binary "no changes found!" or "differences found!" operation

#

fwiw diff-shades is almost 1000 lines of python code already

#

well OK it appears that diff-shades (in particular the monkeypatching of sys.stdout / sys.stderr) isn't the one to blame

#

it's progressing at a much more reasonable rate with a pypi version of black

tribal thistle
#

Hm, that's what I used my first time around, just pip install black

bright glacier
#

although to be fair I did change out the output suppression code to a non broken one

#

yeah that super slow run was with the match pr i LINKED ABOVE

#

WHOOPS

tribal thistle
#

Mmm gobbling up my Keyboard interrupts lol

bright glacier
#

kids, don't type with intense lag

#

i didn't realize I pressed caplocks until it was too late

#

sometimes using a compute heavy multi-core program can be annoying

tribal thistle
#

But yeah, significant speed loss on that PR from what little I've managed to get running

bright glacier
#

that's not good

#

inb4 a war erupts between people who want performance vs people who want match support /j

#

I wonder why it's so slow

tribal thistle
#

(btw suppression seems to still be broken on the latest push, as well as... most output)

#

It's just outputting it for everything now

bright glacier
#

uhhh

#

screenshot? because it's working for me

tribal thistle
bright glacier
#

there's two main ways it could be slower, 1) parsing takes way longer as there's now a proxy in the heart of the parser to handle soft keywords, 2) the match support tweaked the formatting -> causing second passes -> slowdown

bright glacier
tribal thistle
#

It might not actually be slower, it seems to have actually crashed the first time around

#

just froze

plain atlas
tribal thistle
#

i'm 80% through django in 1:50

bright glacier
plain atlas
#

So main and pypi shouldn't have much of a difference, should they?

bright glacier
tribal thistle
#

Maybe? It had the normal nice output previously, but a similar output when it hit the projects with deprecation warnings

#

Is the order different this time

#

Btw, it's back to normal now

#

After all the deprecation warnings have subsided

plain atlas
#

Did you resize the window?

bright glacier
#
@contextmanager
def suppress_output() -> Iterator:
    with open(os.devnull, "w", encoding="utf-8") as blackhole:
        with redirect_stdout(blackhole), redirect_stderr(blackhole):
            yield

this is how I'm suppressing the output which works on linux

#
    src = path.read_text("utf8")
    try:
        with suppress_output():
            dst = black.format_file_contents(src, fast=False, mode=mode)
    except black.NothingChanged:
        return NothingChangedResult(src=src)

and at the callsite

plain atlas
#

That's a generator, not an iterator smh

tribal thistle
#

mess

bright glacier
#

are you sure the version of diff-shades you're using has the supress_output call in analysis.py:check_file ?

#

because this suppression worked on windows for a different funtion

tribal thistle
#

Yeah, I have the files open in the background ๐Ÿ˜…

#

I can test again once this run is finished

#

Which project throws it

bright glacier
#

perhaps the multi processing borked the suppression?

#

-s attrs

tribal thistle
#

I'll check it out in a bit then

#

btw, we're up at 7m@40% now, so slower

#

But not too much

#

Wait no, it seems to have hung Just a really slow files

bright glacier
#

it probably hasn't (hopefully)

#

the chunksize I passed to multiprocessing.Pool isn't great but I haven't seen any major slowdowns from it yet

#

only chunk-y progress

tribal thistle
#

Does pandas just have files with like a million lines

bright glacier
#

yeah its files are stupidly large

tribal thistle
#

It feels like each file is taking well over a minute at this point

bright glacier
#

hmm maybe the slowdown I experienced wasn't just me

tribal thistle
#

Oh yeah, for sure

#

I'm already at 2.5x the time

bright glacier
#

I'm really frustrated the suppression isn't working on windows fwiw

tribal thistle
#

oh-oh, seems we've really frozen this time

#

It isn't redrawing the progress bar

bright glacier
#

uhhhhh

tribal thistle
#

Actually this happened my first time as well

#

CPU usage is back down

bright glacier
#

what the hell is my code doing

tribal thistle
#

So it seems to have finished, got stuck during some transition, and locked the terminal

#

A few button presses ougtha convince it

#

Yeah that did it

plain atlas
#

@tribal thistle how is your cpu process so low smh ;-;

bright glacier
#

well if it happened the first time then we can't blame my suppression code as it didn't exist on github when you first ran diff-shades

tribal thistle
#

It was 100% for 10 minutes straight...

bright glacier
#

I doubt it's a rich bug

tribal thistle
#

Back @100 now

plain atlas
#

mine is at 100% when my computer is on smh

#

i wish i was kidding

tribal thistle
#

if it's possible, do you think you could get the progress bar to display LOCs instead of files? It isn't a very accurate metric lol

#

60% after running pandas and django is uh...

bright glacier
#

yeah there's a huge difference between typeshed and django for instance

#

even tho by file count they're similar IIRC?

tribal thistle
#

hard to tell now, that output has long scrolled out of my terminal backlog

bright glacier
#

huh

#

no python 2 deprecation output here

tribal thistle
#

I wonder if the package just wasn't installed properly

#

Tbf I didn't use editable, just ran a reinstall

#

gonna try to fix it, we're almost done

plain atlas
bright glacier
#

forcing colour mode in rich on gha windows is not a good idea btw lol

plain atlas
#

i ended up setting my terminal to give me an extra 1.5k lines of scrollback buffer

#

should've just piped it

bright glacier
#

I have my terminal set up for 15000 lines of scrollback IIRC

plain atlas
#

2.5k here

#

but that's also an integrated terminal in vscode

#

idk how long windows terminal is configured for

bright glacier
#

I- was mistaken ๐Ÿ‘€

plain atlas
#

100_000...

#

smh

tribal thistle
#

So i was wrong

#

2380 (typeshed) vs 2860 for django

#

It hadn't scrolled away, it just hadn't started

bright glacier
#

yeah it's in alphabetical order

tribal thistle
#

yeah sooo.... huuuuge difference

#

18:47 to what like

#

4 minutes previously

bright glacier
plain atlas
#

wait which 5 projects are already formatted with black?

bright glacier
#

this is a run with 21.9b0 IIRC

#

so wait the match PR introduces no failures and is only like 4 times slower?

tribal thistle
#

Uhh... I just did a very stupid thing

#

Accidentally overwrote the output when testing out the deprecation warnings ๐Ÿฅฒ

bright glacier
#

oops

#

so wait is the suppression code borked for you?

#

because in that case I have no idea how I'm supposed to fix it

#

other than monkeypatching black.output.err but that won't always work IIRC right now

tribal thistle
#

It seems to be working now, just appears that running install without uninstalling didn't actually work

bright glacier
#

probably because I don't always change the version

#

actually wait no

#

isn't pip supposed to reinstall regardless of the version if you pass a local dir

plain atlas
#

i think uh force may be needed and it might not remove all files

tribal thistle
#

Running everything again now to regen the output, but we're back to clean output again

#

nope, neverind

#

broken again

bright glacier
#

...

tribal thistle
#

seems to have worked on attrs, but it's breaking on

#

seems to be django

#

Yeah that does it

bright glacier
#

i'm so annoyed

tribal thistle
#

No, attrs is broken again now

#

I'm so confused

bright glacier
#

*sigh*

#

i can't even reproduce the python two deprecation warnings having removed the suppression code

#

why is everything not going to plan

tribal thistle
#

because we are programmers

bright glacier
#

Yeah.

tribal thistle
#

Is there a problem with the warnings themselves

bright glacier
#

oh huh interesting 21.10b0 doesn't warn on attrs but the match PR does

#

I have no idea why

#

uhhh that's even more confusing

#

oh right I know why

#

because my python 2 deprecation code was sketchy as heck

bright glacier
#

is the output suppression code working?

tribal thistle
#

Which output does it supress

bright glacier
#

the deprecation warnings

tribal thistle
#

I'm seeing them right now, so probably not

bright glacier
#

great /s

tribal thistle
#

The crazy thing is

#

It worked at first, then it stopped

bright glacier
#

I guess mixing click.secho, contextlib.redirect_std*, multiprocessing, and rich together is breaking (on) windows ๐Ÿ˜…

#

I guess I'll have to boot up windows tomorrow

#

I mean I guess I could run black in a subprocess but then I'd get rid of my fancy progress bar

bright glacier
tribal thistle
#

Just finished my second run

#

time is consistent, still 17:07

bright glacier
#

I gave up on diff-shades

tribal thistle
#

Time to upload it before I destroy it

bright glacier
#

I don't need the analysis

tribal thistle
#

oh lol

bright glacier
#

because the PR is broken anyway

tribal thistle
#

What was the PR doing anyways

bright glacier
#

match support :)

tribal thistle
#

mmm

bright glacier
#

I don't understand how redirecting stderr doesn't work on windows and yet it does on Linux (probably due to multiprocessing I suppose)

#

But oh well I'm too frustrated with all of this diff-shades work to continue work on it for the time being

plain atlas
#

i probably should have timed this

#

i decided to format my project's venv for the fun of it

#

i wonder what will be broken when done lmfao

#

oh shit, aside from all of the packages, i also have to get through the stdlib

#

ooo

#

@bright glacier if you want a challenge get black to format pyrepl

#

!pypi pyrepl

late dewBOT
plain atlas
#

of my very long time to format my entire venv for no reason other than write cycles and boredom

#

1998 files reformatted, 584 files left unchanged, 4 files failed to reformat.

#

those four files are from pyrepl

#
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/historical_reader.py
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pymdownx/magiclink.py
error: cannot format /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/keymaps.py: cannot use --safe with this file; failed to parse source file.
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/module_lister.py
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/keymap.py
error: cannot format /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/pygame_console.py: cannot use --safe with this file; failed to parse source file.
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pymdownx/superfences.py
error: cannot format /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/pygame_keymap.py: cannot use --safe with this file; failed to parse source file.
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/simple_interact.py
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/trace.py
reformatted /home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/pyrepl/python_reader.py
bright glacier
#

@tribal thistle what the heck on my windows install it works totally fine

#

I hardcoded black to always print the deprecated message and yet it doesn't leak ๐Ÿ˜•

#

also man the new windows terminal is wayy sexier

#

can I now blame your system for being weird ๐Ÿ‘€ or is there another edge case where it breaks ๐Ÿ˜”

plain atlas
#

lol reformatting everything actually broke coverage

bright glacier
#

uhhhhh like the tool or the stat

plain atlas
#

the tool

bright glacier
#

should I be concened?

plain atlas
#

(i did also run isort)

#

ImportError: cannot import name '__version__' from partially initialized module 'coverage' (most likely due to a circular import) (/home/aru/.cache/pypoetry/virtualenvs/modmail-lmlBH83T-py3.8/lib/python3.8/site-packages/coverage/__init__.py)

bright glacier
#

I doubt black caused this

plain atlas
#

me either

bright glacier
#

but yeah this is why I'm strongly against black reordering imports

plain atlas
#

i'm reinstalling coverage and just running black on it

#

one minute

#

uhhhhhh
I'm going to create a new venv and just format coverage ๐Ÿ‘€

plain atlas
#

okay no, false alarm, it works

bright glacier
#

๐ŸŽ‰

#

I can never choose between these two

#

they're both so great lemon_hyperpleased

plain atlas
#

coverage seems like the only thing that broke with isort formatting

bright glacier
#

inb4 formatting black with isort breaks it /j

plain atlas
#

but doesn't seem like anything broke with black formatting

plain atlas
#

the black i used to format coverage was formatted with my isort config

bright glacier
#

is /srs an actual tone indictor, TIL

plain atlas
#

yes, its serious

bright glacier
#

oh of course lol

plain atlas
#

lmao

bright glacier
#

i'm used to using /gen as in genuine for the same purpose

plain atlas
#

what i want is a tone indicator for half serious

#

eg what if i used difflib to split these functions

#

half-joking doesn't make sense with that

#

half serious makes more sense

bright glacier
#

wait

#

apparently /gen is genuine question and not genuine??

plain atlas
#

idfk lmao

bright glacier
#

uhhh whoops /g /lh

plain atlas
#

what is /g and /lh smh

bright glacier
#

/g = genuine | /lh = lighthearted

plain atlas
#

i was searching for i h...

#

!charinfo ih

late dewBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

bright glacier
#

!charinfo ih

late dewBOT
bright glacier
#

you should become staff for dem commands \hj

plain atlas
#

perhaps someday ๐Ÿ‘€

bright glacier
#

also frick that windows style slash

#

did not mean to do that lol

plain atlas
#

ooh i don't think i'll get another chance to use this tone indicator

#

someday i will break black /th

#

/th threat

bright glacier
#

I have a list of tone indicators with me /li

plain atlas
#

๐Ÿ‘€

#

smh

#

lol

#

honestly at some point there's too many tone indicators imo

#

like

#

some of them are great but at some point the ones that aren't used as much.... idk

#

I think the concept is great tho

#

and i would like to see.....

plain atlas
#

wtf why is this broken

#

this happened after i formatted all of my files ๐Ÿ’€

tribal thistle
#

@bright glacier The first run after the update did actually work without deprecation warnings

#

But then I ran a full run, and that broke it

#

It broke for both individual and full runs

gleaming grail
#

What is this thread for?

little parrot
#

black - The uncompromising Python code formatter

bright glacier
bright glacier
tribal thistle
#

Lol

#

I can do some debugging when I get home

#

Iโ€™ll try to get a solid repro method

bright glacier
#

Various ideas I have include: moving where I patch sys.stderr, redirecting at the file descriptor level, using a in-memory blackhole, and monkey patching click and black.output utilities... one of these has to work ๐Ÿ‘€

tribal thistle
#

All 3 when

bright glacier
#

if you machine is a certified application stress tester which it seems to be already

mint barn
#

is black formatter real worth it ?

#

interms of learning how it works etc

errant barn
#

Well naturally we'll answer: Yes of course it is ๐Ÿ˜„ saves you a heap of trouble especially when working in a team

#

In terms of learning curve, it doesn't really have one. Once you've set it up, calling it is as easy as it gets

mint barn
#

oh , sounds promising

#

i'm just a bit confused on what it actually does

#

read about it before but what i got in a nutshell is that it makes ur code look better

errant barn
#

Have a look at the pinned messages!

#

yeah exactly that

#

doesn't change it in any other way, just visually

mint barn
#

sounds great , does it follow any specify guidelines like pep8 or any other ?

errant barn
#

it's a strict version of pep8

mint barn
#

fair

errant barn
#

opinionated though, so you won't be able to use your style

mint barn
#

This series of videos introduces AsyncIO to Python programmers who haven't used it yet. The first episode is a high-level view on the async ecosystem. We cover:

  • why you'd want to use asynchronous code at all;
  • how latency drives the user experience;
  • what the difference between concurrency and parallelism is;
  • some of the problems you can...
โ–ถ Play video
errant barn
#

same face

mint barn
tribal thistle
#

A more reliable way to quit diff-shades would be uhh

#

great lol

#

@bright glacier can you replicate the fix working on the parser rewrite branch? Switching the black version to main seems to have solved the problems with the deprecation warnings

bright glacier
bright glacier
bright glacier
tribal thistle
#

Ah yes, can confirm

bright glacier
#

When I originally wrote the deprecation code I may have used the wrong constants ๐Ÿ‘€

#

And now it's super sensitive and prone to breakage