#black-formatter

1 messages ยท Page 1 of 1 (latest)

slow ibex
#

what happened these days?

dense jungle
#

the big one was a weekend where I decided to do a lot of triaging

#

and others joined in

#

some of the others were similar, a few were us merging changes that fixed a lot of issues

bright glacier
drowsy sonnet
#

Ok, that's cool.

bright glacier
#

Haha, I have a bunch of silly charting scripts working with github issue and PR data :D

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

Is your feature request related to a problem? Please describe.

When Black is run automatically as a Vim plugin, eg. upon save, and an error occurs, it is not clear that the error comes from Black.

For instance, when saving a Python file using the match ...: new syntax with an old version of Black, vim logs

Cannot parse: 282:14:         match expr:

(this can be reproduced with :Black target_version=py38 with an up-to-date Black)

When Black is run automatically,...

tribal sequoia
#

So I have a co-worker who really doesn't want to use black because he feels it's not important enough or relevant because what we are working on is not a corporate-scale project. He also dislikes that his inline comments are re-formatted so they are not aligned with subsequent lines of code. What would be a good argument for using black? I think it's a great tool that would help us out a lot.

lament crow
#

He also dislikes that his inline comments are re-formatted so they are not aligned with subsequent lines of code.
This minimizes git diffs which generally makes reviewing easier

#

This question ("Why would I want to use Black?") could actually make for a good FAQ entry in the docs.

tribal sequoia
#

Yeah, that's something I looked for but wasn't there.

#

Will add your responses to my arsenal of arguments for it :p

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
bright glacier
#

Feels good to be working on Black again :)

#

I've changed my mind on how I want to approach the CI/CD revamp, so it shouldn't take too long to prepare CD in time for 22.7.0 now

flat krakenBOT
#

Description

This comes from https://github.com/psf/black/pull/3017 which in hindsight was making too many changes at once. This should be easier to review, hopefully :)

This is not required for the upcoming 22.7.0 release, this is just the easiest part of #3017 to file separately. There's no rush to merge this.

Checklist - did you ...

  • [x] Add a CHANGELOG entry if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
bright glacier
#

I'm still bad at keeping my commits focused and atomic, but this should be an improvement ^

#

Why is GitHub sending me three notifications for the failed changelog workflow? So unnecessary and annoying.

flat krakenBOT
#

Description

Building executables without any testing is quite sketchy, let's at least verify they won't crash on startup and can format Black's own codebase.

  • Also replaced "binaries" with "executables" since it's clearer and won't be confused with mypyc.
  • Finally, I added colorama so all Windows users can get colour.

Similar to #3189, this is not required for the upcoming 22.7.0 release, this is 2nd easiest part of https://github.com/psf/black/pull/3017 to file separately. Th...

flat krakenBOT
#

Description

Got bored waiting for CI to pass on my other PRs. I'm surprised black types check without changes upgrading mypy!

Checklist - did you ...

  • [x] Add a CHANGELOG entry if necessary? -> n/a
  • [x] Add / update tests if necessary? -> n/a
  • [x] Add new / update outdated documentation? -> n/a
flat krakenBOT
#

Description

This has been annoying me for too long.

As error logs are emitted often (they happen as Black's cache directory is created after blib2to3 tries to write its cache) and cause issues to be filed by users who think Black isn't working correctly.

These errors are expected for now and aren't a cause for concern so let's remove them to stop worrying users (and new issues from being opened). We can improve the blib2to3 caching mechanism to write its cache at the end of a suc...

bright glacier
#

The above doesn't really fix the root issue, but these logs have been annoying me and users for no good reason for too long.

bright glacier
#

seriously, there was confusion over this at work too?!

#

why didn't I file this PR earlier ๐Ÿ˜„

flat krakenBOT
#

Description

As mentioned in #3185, when using Black as a Vim plugin, especially automatically on save, the plugin's messages can be confusing, as nothing indicates that they come from Black.

This PR simply prefixes the messages with "Black: ".

Checklist - did you ...

  • [X] Add a CHANGELOG entry if necessary?
  • [X] Add / update tests if necessary? [no changes needed]
  • [X] Add new / update outdated documentation? [no changes needed]
flat krakenBOT
bright glacier
# flat kraken

The question is that when and to whom would the logs be useful? The regular users only see this if they're using some editor integration that has logging enabled, people who use black as a library (which is technically unsupported, but we can't stop them) also have to have logging enabled. Developers of black are unlikely to see these logs because blib2to3 is the only code that uses logging, everything else uses print / click.echo for messaging.

#

Yes, it could be useful, but I don't think the debugging value is worth the confusion and scare this has been giving to users.

#

I probably should've put this in a comment on the PR. Will do that actually.

lament crow
#

colorama isn't needed on W10, even when using cmd. It supports ansi escapes

bright glacier
#

wat

#

I thought it didn't

lament crow
#

It doesn't support everything but it definitely supports colors

bright glacier
#

Googling suggests you need to enable virtual terminal something for CMD to support ANSI but I don't know anymore

#

I do have a windows machine so I'll check soon

glacial drum
#

if you use windows terminal, then that adds the ansi support

#

raw cmd doesn't afaik

bright glacier
#

We're talking about old CMD only

glacial drum
#

if you have windows terminal installed, even starting cmd natively will open it in terminal

lament crow
#

I'm talking about w10 cmd

#

Not terminal

#

I know rich got rid of colorama completely

#

Which is a huge success because colorama is painful

#

It might require a winapi call to enable it for the app to keep support with legacy apps, unsure

#

But that's certainly doable with Python, I guess ctypes

glacial drum
lament crow
#

It does not

#

Not on w10

#

This is a W11 feature

glacial drum
#

Did cmd enable the virtual processing flag by default now?

#

I know when they added it, they didn't enable it on conhost by default

bright glacier
#

I dunno, jackenmen says yes but IME no, conhost still starts in legacy mode

lament crow
#

It's a winapi call probs

bright glacier
#

That was several years ago though so maybe a windows 10 update changed things

glacial drum
#

Setting ENABLE_VIRTUAL_TERMINAL_PROCESSING too

#

not sure if that can be done on an existing cmd process by a child though

bright glacier
#

Yea, otherwise we could replace colorama via an API call

lament crow
#

Honestly I just find colorama incredibly annoying and would love if it wasn't a hard dep

#

I think it's transitive dep from click tho so

late dewBOT
#

setup.py lines 5 to 8

install_requires=[
    "colorama; platform_system == 'Windows'",
    "importlib-metadata; python_version < '3.8'",
],```
bright glacier
#

so technically our colorama extra is unnecessary

#

also, our colorama extra doesn't actually check if the system is Windows so it's a bit expansive that way ๐Ÿ˜…

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

Black's general philosophy is to prefer double quotes, but only if doing so doesn't involve additional escaping.

In both of the following I'd argue triple single quotes are a better match:

""""How are you\""""

'''"It isn't fair", he said.'''

Blackened, this is:

""""How are you\""""

""""It isn't fair", he said."""

Triple single quotes would allow you to skip some escaping in the first, so cha...

flat krakenBOT
bright glacier
#

man, I feel bad about upstreaming the mypyc workflow so close to the release deadline ๐Ÿ˜…

#

Life's been busy and I haven't found the time for much, but I think I'll just manage.

#
.rw-rw-r-- 3.9M ichard26 ichard26 28 Jul  2:31 black-0.1.2a7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.rw-rw-r-- 4.0M ichard26 ichard26 28 Jul  2:31 black-0.1.2a7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.rw-rw-r-- 4.3M ichard26 ichard26 28 Jul  2:31 black-0.1.2a7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.rw-rw-r-- 4.4M ichard26 ichard26 28 Jul  2:31 black-0.1.2a7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.rw-rw-r-- 4.4M ichard26 ichard26 28 Jul  2:31 black-0.1.2a7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

.. whaat? why are the linux wheels so big now?

#

they've tripled in size

#

I can confirm debug symbols are still stripped, so I guess this is mostly just changes to mypyc...?

#

I wonder if it's better to hold off using mypy[c]==0.972 for this release so I have more time to sort this out (and also properly test out macOS ARM)

#

Yeah, I'm going to stick with the same mypy[c] version for compilation for now. I don't trust updating the buildchain so close to the release, would rather stick with what's known to work just fine.

#

.. wait, no, I was wrong, debug symbols are now being added. I forgot there was a somewhat recent to mypyc that appends -g1 to CFLAGS by default

#

Still going to postpone the various buildchain updates though as I don't have the time to give them the attention and care they need.

flat krakenBOT
#

Description

This is the last part of #3017. This is effectively unchanged from the original PR, except for the addition of a commit to workaround a Windows shell quoting crash that I can't be bothered to deal with properly.

I don't really have solid test workflow runs to prove this will 100% work, but I've tested similar changes in this PR successfully (don't mind the Windows failure, I messed up). The only ...

flat krakenBOT
austere lava
#

we can't

#

but you can!

#

use isort or ฮผsort

#

or just ฮผfmt that combines black and ฮผsort

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

@lament crow yeah the old CMD prompt does require the register tweak first before supporting colours

lament crow
#

winapi call then

#

kinda annoying but makes sense from backcompat perspective

bright glacier
#

well, click is going to force us to pull colorama on windows anyway so not sure what the point would be ยฏ_(ใƒ„)_/ยฏ

lament crow
#

As long as it's transitive dep/extra, it's fine :P Maybe one day click will get rid of colorama

west crane
#

interesting project

lofty ravine
#

This is my action on github

#

and it says that file got reformatted but nothing got changed in that file

#

when using the command locally it works

#

would appreciate some help

#

What should be reformatted is between functions in class i specially left multiple free lines to test it out locally it formats it correctly but on github the file is unchanged

lament crow
#

The job that you posted is only supposed to report whether files are correctly formatted or not

lofty ravine
#

ok and how to create a workflow wich also formats the files

#

cause locally when i use it it formats the files aswell

lament crow
#

It does format the files, in the CI's environment. When you use it locally, the same happens, it formats it in your environment. Nothing automatically gets committed and pushed

#

So, you should ask yourself what you want to happen if there are any changes.

#

Make some commit? Make a PR?

lofty ravine
#

ok then how should it auto-commit the reformatting it has done?

dense jungle
#

at some projects I work on we use pre-commit.ci, it can run on PRs and push to the PR branch with formatting fixes

lofty ravine
#

ok i guess then i'll just remove the workflow and tell everyone to format their code before pushing it since we are working on a rather small project with not so many contributors

lament crow
#

Huh, I thought pre-commit.ci can also run on the branch but doesn't seem like it.

lament crow
#

There are tools such as pre-commit that can ensure that your code is formatted properly before it allows you to commit it.

#

That's something that each person could install locally if they want to not forget about formatting changes and it would then use repository's configuration as described here:

lofty ravine
#

Okay thanks for the help guys.

flat krakenBOT
bright glacier
#

If anyone experienced with docker wants a probably simple issue to work on, psf/black#2975 is it!

bright glacier
#

Thoughts on psf/black#3089 ?

bright glacier
#

I'm inclined to accept it, but it would make this look less consistent

if condition:

    def g():
        pass

else:

    def f():
        pass
if condition:
    def g():
        pass

else:
    def f():
        pass
bright glacier
#

!remind 3D revisit 22.8.0 milestone and ask some past contributors whether they'd like to pick up some issues

late dewBOT
#
Absolutely!

Your reminder will arrive on <t:1659644433:F>!

bright glacier
#

I have two issues where I know who I'll ask, but they have open PRs currently and I'd feel bad about asking them to pick up another issue when they already have something in the works ๐Ÿ˜„

atomic barn
flat krakenBOT
flat krakenBOT
bright glacier
#

FINALLY. I got a clean build on a much more modern cibuildwheel setup: https://github.com/ichard26/black-mypyc-wheels/actions/runs/2779048277 I just now need to upgrade cibuildwheel itself (which is going to be painful since it's crashing on Linux last time I tried) and then test all of the wheels again because basically everything has been changed.

bright glacier
flat krakenBOT
flat krakenBOT
#

Remove optional brackets around unpacking

Since #2945, Black removes brackets in the following situation:

for (x, y) in stuff:
    ...

Perhaps this should be extended to include unpacking assignments.
Examples in the current Black style

(x, y) = point
(first, *rest, last) = things
[a, b] = foo  # Not touched with for at the moment

Desired style

x, y = point
first, *rest, last = things
a, b = foo  # Not touched with...
flat krakenBOT
#

Describe the bug
Trailing commas inside indexing square brackets are not removed when running Black with -C. This also affects generic types with multiple parameters.

To Reproduce

For example, take this code:

x = [0, 1,]
x = z[0, 1,]

and run with -C. We get

x = [0, 1]
x = z[0, 1,]

Expected behavior

The final trailing comma should disappear.

x = z[0, 1]

Environment

  • Black's version: 22.6.0. ...
weary nimbus
#

Hey, someone interested in working on a project with me?

flat krakenBOT
#

Description

uR is not a legal string prefix, so this test breaks (AssertionError: cannot use --safe with this file; failed to parse source file AST: invalid syntax) if changed to one in which the file is changed. I've changed the last test to have u alone, and added an R to the test above instead.

Checklist - did you ...

  • [X] Add a CHANGELOG entry if necessary?
  • [X] Add / update tests if necessary?
  • [X] Add new / update outdated documentation?
bright glacier
#

you're totally welcome to try contributing to our project (black) but this isn't the place to meet people to start a new project

weary nimbus
bright glacier
flat krakenBOT
flat krakenBOT
#

With the (soon to be) introduction of mypyc into our release pipeline, releasing now means rolling the dice on whether the release automation will break or not. This would be extremely annoying and add considerable stress to an already tense situation (cutting a new release).

I have access to TestPyPI's black project now. Let's run the PyPI release workflow weekly (or biweekly maybe?) and push the distributions to TestPyPI for proper e2e testing.

Credits go to @cooperlees for the sugge...

neon loom
#

How do we know when they wipe it and when we need to generate a new API token? I guess only when it fails right ...

#

Shouldn't be that often

bright glacier
#

They basically never wipe it AFAIK, but it should just involve recreating a testpypi account and token and rerunning the workflow

#

Although depending on whose token we use, we might have to bug Jelle to update the repository secret as I don't have admin permissions.

#

I mean, Jelle will be involved regardless, but the token's barer changes how much he has to help out

lament crow
#

they don't wipe it at all

bright glacier
#

I spent some time writing down my to-do list for Black and my goodness, I think I need to delegate some tasks ๐Ÿ‘€

little parrot
#

black doesnt reformat the contents of docstrings does it?

bright glacier
#

It sometimes messes with the indentation according to some pep I can't recall

dense jungle
#

PEP 257 is docstring formatting

little parrot
#

it doesnt fix line lengths though?

#

or does it?

#

cause thatd be awesome for what im trying to do

bright glacier
#

I think that's better as a third-party tool to be honest. I really don't see Black touching the contents of docstrings even more anytime soon.

#

The discussion on whether we even want black to make AST altering changes is still unresolved. See the pinned proposal from Jelle on GH.

#

FYI I added two more status labels primarily intended for PRs: S: up for grabs and S: blocked

bright glacier
#

Gosh, I think I found two more diff-shades bugs and one of them is annoying the hell out of me

#

not sure where the bug is coming from to be honest though, it's the weirdest diff-shades bug I've seen so far

#

so diff-shades saves a copy of the files it's running Black over, this is pretty helpful as you can export the source for a file that's newly crashing from an analysis via diff-shades show $project $filepath src -q > dump.py but it's somehow saving a malformed copy, and not malformed as in outdated, but straight up broken:

@@ -507,9 +507,9 @@
                 ]
         else:
             if line.inside_brackets:
-                transformers = 
+                transformers = [delimiter_split, standalone_comment_split, rhs]
             else:
-                transformers = 
+                transformers = [rhs]

here's a diff comparing diff-shades' copy and the same file from my local repository

#

wait whaat? the source copy is actually fine in the analysis file too, where is it getting corrupted?!

#

oh wait, I wonder if rich is parsing the list literals and subscripts as bbcode

late dewBOT
#

src/diff_shades/cli.py line 351

console.print(getattr(result, field_key), highlight=False, soft_wrap=True)```
flat krakenBOT
#

I agree that this improves formatting. The code looks mostly good, but noticed few issues:

  • Tuple literals are not considered, that seems unconsistent
  • Wrapping broken up string literals that live alone in a sequence literal that simply has a trailing comma seems overkill?
--- test.py	2022-08-03 17:43:27.228805 +0000
+++ test.py	2022-08-03 17:43:28.373631 +0000
@@ -1,8 +1,10 @@
 L2 = [
-    "This is a really long string that can't be expected to fit in one line and is t...
flat krakenBOT
#

To Reproduce

~/programming/oss/black on HEAD (b776bf9) [$?] via Python v3.8.5 (venv) 
โฏ echo "print('Hello, world!')" > ../outside.py

~/programming/oss/black on HEAD (b776bf9) [$?] via Python v3.8.5 (venv) 
โฏ cat ../outside.py | black --stdin-filename "../outside.py" -

No Python files are present to be formatted. Nothing to do ๐Ÿ˜ด

~/programming/oss/black on HEAD (b776bf9) [$?] via Python v3.8.5 (venv) took 711ms 
โฏ black ../outside.py 
reformatted ../outside.py
...
atomic barn
bright glacier
#

sounds good, lemme know if you need help!

bright glacier
#

It still makes me happy to see diff-shades do its job of testing Black well ๐Ÿ˜„

#

Even with how much I want to rewrite the codebase as it's pretty awful ๐Ÿ˜…

charred fox
#

is there an article about what black actually is and does?

#

or can someone explain how it works

flat krakenBOT
#

Description

Fixes behaviour that prevented formatting for files outside the current working directory (#3207).

# before the fix
โฏ cat ../script.py | python -m black --stdin-filename '../script.py' -
No Python files are present to be formatted. Nothing to do ๐Ÿ˜ด

# after the fix 
โฏ cat ../test.py | python -m black --stdin-filename '../test.py' -   
print("hello world")
All done! โœจ ๐Ÿฐ โœจ
1 file left unchanged.

Let me know what you think! Not sure about how e...

foggy dew
#

hi, python has a -x option to skip the first line of source files when using non standard shebang it would be logical to have the exact same for black.

bright glacier
#

Why? Are the shebangs not comments?

foggy dew
#

not on dos or web

foggy dew
#

the # not first ๐Ÿ˜ฆ

#

so black does not like it

lament crow
#

That's weird o.O

#

The WASM part anyhow

foggy dew
# lament crow The WASM part anyhow

i don't know what you mean by weird, wasm is a tier 3 support in python, so it would be nice to decently format the code that can run on web pages too - not only on wasi platform ( where -x would work anyway )

lament crow
#

I said weird, I didn't say black shouldn't support it.

#

Because it is weird...

#

To me anyhow

foggy dew
#

<html> as a shebang yeah it's weird

#

or <doctype whatever

lament crow
#

It seems like a weird limitation

#

If this is the only way to do whatever it is that this does

foggy dew
#

yeah it is

#

browsers only want < as first character

late dewBOT
teal goblet
#

It's so awkward when I google "black playground"

flat krakenBOT
#
def foo():
    assert (
        b"RuntimeError: zasnvkdifnb2rnf cannot be abcdefgh with a "
        b"bjbkjdf dfsdf of asdfasdfs"
    ) in proc.stderr

becomes:

def foo():
    assert (
        b"RuntimeError: zasnvkdifnb2rnf cannot be abcdefgh with a "
        b"bjbkjdf dfsdf of asdfasdfs"
        in proc.stderr
    )

This is a line longer and less readable, since the string is less separated from the contains

flat krakenBOT
flat krakenBOT
bright glacier
#

I love my internet connection, it's very stable <3

#

I would've thought the GitHub UI would realize the draft PR action really only happened once on a refresh, but nope ...

lament crow
#

lol

bright glacier
#

I was looking through the CPython issue tracker for something new to work on since I've been feeling a bit meh about working on black lately, but I realized I'm still happier contributing to projects I already know

#

I may catch up on my python discord PR reviews soon though

bright glacier
#

I'm thoroughly confused ๐Ÿ˜•

#

it's patching black.reformat_many which should be impossible / crash since I moved that function in the PR this run is failing on

lament crow
#

I'm less likely to want to contribute if I don't have some stake in it. It's fine if that stake is far-fetched but it existing at all still helps

#

I would love to contribute some C code to CPython one day but that sounds like a long-term goal lol

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 `...
lament crow
#

I first tested whether pathspec for this works properly and then at first thought it has a bug after which I looked at it again and saw a typo in what I put in there so I thought I must have made it. Little did I know it was the issue author that made the typo which I gladly re-typed ๐Ÿ˜„

bright glacier
#

haha lol

lament crow
#

I'm pretty sure it is the actual issue here because I can't repro it with Black either and would have been surprised if I were able to but time to wait for them to respond

bright glacier
bright glacier
lament crow
#

I'm a bug magnet so that helps

#

my PRs are all over the place because of this ๐Ÿ˜„

bright glacier
#

I'm pretty focused on black so far ๐Ÿ˜„

#

I was a bit surprised seeing you in #cibuildwheel haha

lament crow
#

to my knowledge, I don't have any stake in Cirrus CI support in cibuildwheel

#

but I was playing quite a bit with it recently and been pretty amazed with it

bright glacier
#

ahh i see

lament crow
#

There was a different project where I made a PR to update cibuildwheel to get macOS M1 wheels so I guess that kind of made me look at cibuildwheel a bit closer

#

but like, I don't have an actual reason for contributing other than just feeling like it this time

bright glacier
#

that happens to me a fair bit, sometimes something catches my interest

lament crow
#

Tbf, reminds me of all my python/cherry-picker PRs that are just sort of waiting there...

#

I went on issue closing spree there but most of my PRs haven't been looked at

bright glacier
#

Yeah that's another thing about contributing to python core, it can take forever for a PR to be merged

lament crow
#

this isn't core but I'm guessing it's the same story since cherry-picker is maintained by a small subset of core devs

#

mainly Mariatta but I've seen that ลukasz was the one to merge some of my PRs there

bright glacier
#

Nice to see he's still the DIR. Although the lack of weekly updates is a shame

lament crow
#

ye, I quite liked those

bright glacier
#

I say that and I could ask him directly about that since we are co-maintainers, but ยฏ_(ใƒ„)_/ยฏ

lament crow
#

are we talking about mypy?

bright glacier
#

ลukasz wrote black, y'know :p

lament crow
#

oh right

#

lmfao

bright glacier
#

hahahaha

lament crow
#

we're in the black channel...

#

yeah, I don't know how that went over my head

lament crow
#

they came back 3 months ago

#

it seems liek

bright glacier
#

:O

lament crow
#

semi-regular though?

bright glacier
#

yeah, not weekly anymore

lament crow
#

might depends on how much he's done within the week

bright glacier
#

yeah, also probably quite busy helping pablo with 3.11

lament crow
#

it is summer so maybe he's spending his vacation time

bright glacier
#

right

lament crow
#

and yeah, busy helping with 3.11, various Python conferences too

#

EuroPython was last month ๐Ÿ˜„

#

ลukasz was probably rehearsing for the piano concert

#

:)

bright glacier
#

I heard bits and pieces of that, still don't know what really happened though ๐Ÿ˜„

lament crow
#

I wasn't there, just seen a small bit on Twitter

bright glacier
#

something something $insert-tweet-about-piano

lament crow
#

lol

bright glacier
lament crow
#

lol

#

I tried to configure clang format once

#

I actually think there might have not been enough options...

bright glacier
lament crow
#

there's a lot of options yet I think something just wasn't there

bright glacier
#

of course something wasn't there :p

lament crow
#

It might be that I was trying to make it look in a way that resembles to what I'm used to from other languages rather than whatever C++ is actually formatted like, honestly can't remember

bright glacier
#

Mhmm, I format some of my C code as if it was Python code

#

Although I do use hanging function calls instead of exploding them

lament crow
#

I think I exploded them sometimes

#

time to find it...

bright glacier
late dewBOT
#

masml.c lines 235 to 239

if ((arg && arg[0] != '&')
        && (atof(arg) == 0.0 && strcmp(arg, "0") && strcmp(arg, "0.0"))) {
    printf("[FATAL] invalid numerical constant on line %zu\n", i);
    goto BAIL;
}```
late dewBOT
#

masml.c lines 267 to 270

if (arg && arg[0] == '&') {
    printf("[LINE %-3zu] %-13s %-7s %s -> ram[%zu]\n",
        i, stype, reg, arg, var_index);
} else {```
lament crow
#

seems like I was wrong and most of what I wrote was hanging rather than exploded

#

might partially be because most of what I wrote used clang-format

#
BasedOnStyle: Chromium
IndentWidth: 4
ColumnLimit: 88
AccessModifierOffset: -2
BreakBeforeBinaryOperators: All
#

I've done exploding with Java more

bright glacier
#

I'll probably use clang-format eventually, but I've been sticking with hand formatting so far

#

I have an informal but totally non-strict line length limit of 90 I try to follow

#

ah great, nox just dropped python 3.6 support with their newest release. I was planning to finally switch black over to nox this summer

lament crow
#

are you unhappy with tox?

bright glacier
#

it's fine, but I find nox easier to use / wrap around

#

also nox would probably play a lot nicer with the weird needs of my mypyc work

lament crow
#

hmm, was tox 4 supposed to be released in May or sth?

bright glacier
#

I have no idea, I guess I can look at that too

lament crow
#

I see it isn't but I vaguely recall it being planned to happen sooner

bright glacier
#

I could probably let tox install the project itself instead of setting skip_install = True and then installing black manually, but I dunno

#

!remind 18H look into tox 4 if you're bored and have nothing else to do

late dewBOT
#
Affirmative!

Your reminder will arrive on <t:1659992446:F>!

lament crow
#

current due date for tox 4 appears to be Oct 1

bright glacier
#

!remind 17.5H also actually, plz test black with setuptools's experimental standardized editables support

late dewBOT
#
Bad argument

17.5H is not a valid duration string.

lament crow
#

based of the milestone

#

17h30m :)

bright glacier
#

!remind 17H also actually, plz test black with setuptools's experimental standardized editables support

late dewBOT
#
You got it!

Your reminder will arrive on <t:1659988901:F>!

bright glacier
#

I've been meaning to do this for ages now, but I keep pushing it off

#

Pretty sure it'll land in main in a few days, so I better stop procrastinating

lament crow
#

I honestly thought that it would have already been in main by this time

bright glacier
lament crow
#

there are released betas for tox 4 and I see one of the maintainers has been using tox 4 in prod for a long while

bright glacier
#

huge rewrites are daunting so I can't blame them for not having a set date, just kinda annoying since I want to make a decision on how to improve black's devtooling soon haha

#

I'll figure out, eventually -- it's like 11:09 PM right now so definitely ain't working on this today

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
#

... maybe we should add a FAQ entry about this ๐Ÿค”

lament crow
#

I doubt anyone will read it

#

anything short of a pinned issue probably won't be effective

late dewBOT
late dewBOT
bright glacier
#

I don't agree this is a short-coming of Black. There's no way we'd be able to reliably know when a file given on the command line is from a human or an integration/IDE (and then decide whether to enforce --exclude/--include or not)

lament crow
#

You say that it needs to piped in, I guess passing force exclude to cli doesn't override the settings from configs and just extends it then?

bright glacier
#

oh that's a good point

lament crow
#

black --force-exclude '' file.py

#

Sth like that I suppose

bright glacier
#

they could just configure vscode to pass --force-exclude and leave pyproject.toml aloone

bright glacier
#

coolio, time to rewrite my entire comment

lament crow
#

I can't say that I tried it so you might want to check

bright glacier
#

Black doesn't do any per option extending between file configuration and the CLI

#

I feel like an idiot :)

bright glacier
#

I included your helpful tip about temporarily clearing --force-exclude on the command line

#

(watch me miss something else obvious ๐Ÿ˜ฆ )

lament crow
#

Looks great

#

Are we sure force exclude with an empty will work properly actually

#

Isn't it like a regex

bright glacier
#

hmm good point

#

I can check

dense jungle
#

--force-exclude $^`?

bright glacier
#

it's not crashing with an invalid regex error

lament crow
#

It wouldn't be invalid, just wondered if it wouldn't cause it to match all

bright glacier
#

I was actually checking how --stdin-filename interacts with all of this at the same time haha

bright glacier
# lament crow It wouldn't be invalid, just wondered if it wouldn't cause it to match all
$ black test.py --check -v
Identified `/home/ichard26/programming/misc/c-development/masml` as project root containing a .git directory.
Sources to be formatted: "test.py"
Using configuration from project root.
test.py ignored: matches the --force-exclude regular expression
No Python files are present to be formatted. Nothing to do ๐Ÿ˜ด

~/programming/misc/c-development/masml on main [$?] via v3.8.5 took 330ms 
$ black test.py --check -v --force-exclude=''
Identified `/home/ichard26/programming/misc/c-development/masml` as project root containing a .git directory.
Sources to be formatted: "test.py"
Using configuration from project root.
would reformat test.py

Oh no! ๐Ÿ’ฅ ๐Ÿ’” ๐Ÿ’ฅ
1 file would be reformatted.

nah, it just disables it as if it was never configured anywhere

bright glacier
#

Took a surprisingly long time but I guess I do make it hard to contact me :)

atomic barn
#

hey guys! i made a PR some days ago (https://github.com/psf/black/pull/3208): tests passed locally but the pipeline failed. How can I test local changes more thoroughly to be sure to submit a valuable PR?

GitHub

GitHub is where people build software. More than 83 million people use GitHub to discover, fork, and contribute to over 200 million projects.

bright glacier
#

run tox -e py I think? to be honest I'm not really sure myself either

#

it's an interesting failure case though

#

3.6 and 3.7 are all failing across all OSes, but only 3.8+ windows is failing

atomic barn
#

Yup, I noticed

bright glacier
#

I'm not sure if comparing stringified filepaths is a robust enough way of handling paths, but I haven't looked into this issue yet

dense jungle
atomic barn
#

Ok! thanks for the advice

atomic barn
flat krakenBOT
bright glacier
#

Gosh, the file collection logic is soooooo confusing.

#
โฏ cat ../tester.py | black - --stdin-filename ../tester.py -v --check
Identified `/` as project root containing a file system root.
Sources to be formatted: "home/ichard26/programming/oss/black/-"
Using configuration from project root.
would reformat ../tester.py

Oh no! ๐Ÿ’ฅ ๐Ÿ’” ๐Ÿ’ฅ
1 file would be reformatted.

that sources line doesn't seem right testing your PR locally @elder tusk

#

From a purity standpoint I'd prefer testing main (although I say that and it'd probably involve mocking), but it's probably just easier to refactor find_project_root. All of the file collection and discovery logic is quite messy already ยฏ_(ใƒ„)_/ยฏ

#

I'm going to head out for a few hours soon, but I wanted to share my initial comments before I forget.

flat krakenBOT
elder tusk
#

for example, on main:

~/dev/black/docs main ฮป cat conf.py | black --stdin-filename "outside.py" -vvv --check -
Identified `/Users/shantanu/dev/black` as project root containing a .git directory.
Sources to be formatted: "docs/-"
Using configuration from project root.
outside.py already well formatted, good job.

All done! โœจ ๐Ÿฐ โœจ
1 file would be left unchanged.
#

where obviously "docs/-" is nothign

#

i pushed a quick fix for it to my branch

#

but yeah, the verbose reporting of "sources to be formatted" is very coupled to the get_sources logic, so ideally we'd move that log into there.

flat krakenBOT
#

Hey thanks for filing a PR, I really appreciate it :black_heart:

The PR looks pretty good, got a few minor suggestions. I would've also suggested adding a testcase that verifies the preview style was actually enabled by using input that's only changed under the preview style, however, the test would have to be changed in 2023 when we promote many changes in preview to stable. Sooo it's probably fine to not have a test, but I just wanted to make sure we thought this through.

exotic stratus
#

Out of curiosity, are there plans to include (optional) hard checks for type hints during declarations, function args, return types, etc.? Granted, it wouldn't be that easy to extrapolate what the var should be hinted to, but could at the very least the black process return an error if it finds places that aren't hinted?

little parrot
#

i dont work on black but i think thats a job for another tool like mypy or pyright

exotic stratus
#

Perhaps. Do those tools already offer such functionality?

exotic stratus
#

Thank you

#

Alright, I've also found pytype and pyre-check. Apparently it's called "Strict mode" at some of these, so that settles it

potent sphinx
#

Hey can anyone tell me how to make a discord bot using python?

bright glacier
slim olive
#

it makes the lint job fail if it finds missing annotations, and is fairly configurable in terms of which cases are acceptable (e.g. special methods, private methods, etc)

exotic stratus
slim olive
#

yes, it finds parameters lacking type annotations

#

ah, sorry, I was only considering the last part of your message:

could [...] the black process return an error if it finds places that aren't hinted?

#

checking the correctness of annotations & type safety is a job for type checkers such as mypy or pyright; it is beyond the scope of formatters or linters

bright glacier
#

Indeed, Black will never be a linter or type checker. That is simply out of scope for the project.

#

Black's architecture isn't even well suited as a linter, Black doesn't operate under a "find style violations in code -> fix them" model, it more normalizes code (specifically the CST metadata like spacing and parenthesizes) to follow the Black code style.

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

well my laptop has been taken hostage by windows update so I can't even debug the above issue if I wanted to

flat krakenBOT
#

Description

Fixes #3124

The logic implemented is as follows:

  • If target_version is specified in the pyproject.toml, we ignore the project metadata.
  • If it is not specified, we try to read and parse the project metadata to determine a valid minimum TargetVersion. If we fail for whatever reason, we continue without a target_version.
  • The target version should be the major version of the minimum Python version allowed by the requires-python specifier.
    • `>=3....
flat krakenBOT
flat krakenBOT
bright glacier
#

nice!

late dewBOT
#

.github/workflows/pypi_upload.yml lines 73 to 76

- name: Upload wheels to PyPI via Twine
  env:
    TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
  run: pipx run twine upload --verbose -u '__token__' wheelhouse/*.whl```
dense jungle
#

@bright glacier any other PRs you'd like me to take a look at?

bright glacier
#

I wager pipx being pre-installed is not something he knew.

#

https://github.com/psf/black/pull/3219 is a major enough change (it adds a dependency on packaging) I'd appreciate more eyes on it, but I can do the preliminary review first. mypyc is failing due to a very lax return type annotation in packaging.

#

I was going to comment on psf/black#3198 with pointers for the author to include a proper mitigation (ran out of time and I forgot about it), but yes in its current state it should not be merged.

toxic stormBOT
bright glacier
#

oh yeah, we probably don't need that global anyway

dense jungle
#

I wonder if the os.cpu_count() thing is slow on different OSes

bright glacier
#

as long black.concurrency is only imported when reformat_many is about to be called, uvloop will be imported without impacting users using black as a library

dense jungle
#

wow on linux it's even faster than my mac ```In [9]: %timeit os.cpu_count()
68.6 ns ยฑ 0.106 ns per loop (mean ยฑ std. dev. of 7 runs, 10,000,000 loops each)

bright glacier
#

technically anyone who calls black.main inline will see uvloop installed but that probably is not something we need to concern ourselves with?

import black

black.main([args, ...], standalone_mode=False)
#

If you're calling black.main, you're effectively handing off control to black and we reserve the rights to change the global environment as we need to

bright glacier
#

Doesn't really hurt.

dense jungle
#

I half expect it to take like a second on Windows

bright glacier
#

Haha, I was thinking the same thing.

#

I'd be surprised if Python has to call some subprocess or external script to get the CPU count (as like with some other platform/system metadata functions in sys) but OSes have weird limitations ยฏ_(ใƒ„)_/ยฏ

neon loom
flat krakenBOT
bright glacier
#

good morning folks! ๐ŸŒค๏ธ

bright glacier
late dewBOT
#

src/black/__init__.py lines 374 to 381

@click.option(
    "-W",
    "--workers",
    type=click.IntRange(min=1),
    default=DEFAULT_WORKERS,
    show_default=True,
    help="Number of parallel workers",
)```
bright glacier
#

Is it worth changing the default to be None so we can avoid calling os.cpu_count()?

lament crow
bright glacier
#

yeah, lots of tiny commits so my inbox has been getting spammed :(

bright glacier
#

or... the type hint is just plain wrong

dense jungle
late dewBOT
#

Lib/concurrent/futures/process.py lines 599 to 603

if max_workers is None:
    self._max_workers = os.cpu_count() or 1
    if sys.platform == 'win32':
        self._max_workers = min(_MAX_WINDOWS_WORKERS,
                                self._max_workers)```
bright glacier
#

looks like we can pass None as max_workers to ProcessPoolExecutor

#

sooo it doesn't even matter if it returns None, we're doing extra work we don't need to

bright glacier
covert zenith
#

Is black supported in Pycharm/Jetbrains IDEs?

bright glacier
#

Well I'm a better developer nowadays in the sense I write useful commit messages :p

bright glacier
#

dammit, I think I lost my changes to the release documentation

#

I probably accidentally ran a git restore on it

#

it's really annoying since I had spent a few hours on it

#

oh my goodness, there's a copy of the release process document with my changes in the sphinx build directory

#

thank gosh lemon_sweat

#

wait no, it's actually outdated :(

#

Fine, I'll rewrite it again.

bright glacier
#

what?

โฏ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/local/lib/python3.11'
  sys._base_executable = '/home/ichard26/Downloads/Python-3.11.0rc1/debug/python'
  sys.base_prefix = '/usr/local'
  sys.base_exec_prefix = '/usr/local'
  sys.platlibdir = 'lib'
  sys.executable = '/home/ichard26/programming/testing/black/3.11venv/bin/python'
  sys.prefix = '/usr/local'
  sys.exec_prefix = '/usr/local'
  sys.path = [
    '/usr/local/lib/python311.zip',
    '/usr/local/lib/python3.11',
    '/usr/local/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f241654f4c0 (most recent call first):
  <no Python frame>
#

I'm trying to test 3.11rc1 and it's failing to startup. Built it from source with --with-pydebug, not sure what would be wrong :/

#

using 3.11's venv worked, perhaps virtualenv doesn't support 3.11 yet ยฏ_(ใƒ„)_/ยฏ

#

aiohttp probably won't support 3.11 for a long time, looks like many things are still broken on their end

#

well, actually we'll probably have to fallback to aiohttp's pure python installation mode since their Cython sources don't work on 3.11

#

we need to start testing 3.11 like.. now.

#

OK, so our test suite passes on 3.11rc1 except for all of the blackd tests since our test setup code is isn't 3.11 compatible...?

#

oh, aiohttp's AioHTTPTestCase seems broken on 3.11

dense jungle
bright glacier
#

looks like pathspec changed the way of installing the project from source as ichard26/black-deps-ci is blowing up

opaque depot
#

Tell me about black

bright glacier
opaque depot
#

Well let's say I have a large API project that I own that passes flake8. How might black offer different advice?

bright glacier
#

black is a code formatter, not a linter like pylint or flake8

opaque depot
#

Oh, interesting

flat krakenBOT
#

Note that we still have:

src/blib2to3/pytree.py
13:# mypy: allow-untyped-defs, allow-incomplete-defs

src/blib2to3/pgen2/tokenize.py
4:# mypy: allow-untyped-defs, allow-untyped-calls

src/blib2to3/pgen2/conv.py
4:# mypy: ignore-errors

I took a solid look at removing those from pytree, but it seems like some of the existing type annotations are lies (e.g. things annotated as _Results can have list values). Do we not compile blib2to3 with mypyc?

opaque depot
#

One last question; how can I fade to black?

#

slinks away

flat krakenBOT
#

Description

We've decided to a) convert stable back into a branch and b) to update it immediately as part of the release process. We may as well automate it.

Test run: https://github.com/ichard26/black/runs/7831041412?check_suite_focus=true (note that in that run the job runs after the sdist/pure wheel job passes, while in this PR, it runs after all the PyPI jobs finish, I changed it in the test run because I didn't want to wait several minutes for the mypyc jobs to finish)

**Thi...

opaque depot
#

Black... Did something I think it shouldn't have.

#

I had a function that returns a list and I needed a static index from that list:
I.e. foo = bar()[1]

#

Black did this:

#
foo = bar()[
    1
]
glacial drum
#

it'll only explode out like that if it hits the configured max line length iirc

opaque depot
#

Yeah that's precisely what happened

bright glacier
#

Black's output here is known to be subpar

#

Would link to the many issues that exist but am on phone atm

opaque depot
#

Thanks

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
#

uhhh, cibuildwheel 2.9.0 is just erroring out when trying to build the 3.11rc1 wheels ๐Ÿ˜•

lament crow
#

link to the workflow?

lament crow
#

hmm, your x86_64 image is quite old for some reason

bright glacier
#

things break if it's unpinned though

lament crow
#

This is the output I get:

  manylinux_images: {'x86_64': 'quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db', 'i686': 'quay.io/pypa/manylinux2014_i686:2022-07-17-51324db', 'pypy_x86_64': 'quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db', 'aarch64': 'quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db', 'ppc64le': 'quay.io/pypa/manylinux2014_ppc64le:2022-07-17-51324db', 's390x': 'quay.io/pypa/manylinux2014_s390x:2022-07-17-51324db', 'pypy_aarch64': 'quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db', 'pypy_i686': 'quay.io/pypa/manylinux2014_i686:2022-07-17-51324db'}
  musllinux_images: {'x86_64': 'quay.io/pypa/musllinux_1_1_x86_64:2022-07-17-51324db', 'i686': 'quay.io/pypa/musllinux_1_1_i686:2022-07-17-51324db', 'aarch64': 'quay.io/pypa/musllinux_1_1_aarch64:2022-07-17-51324db', 'ppc64le': 'quay.io/pypa/musllinux_1_1_ppc64le:2022-07-17-51324db', 's390x': 'quay.io/pypa/musllinux_1_1_s390x:2022-07-17-51324db'}

While yours is:

  manylinux_images: {'x86_64': 'quay.io/pypa/manylinux2014_x86_64:2021-11-20-f410d11', 'i686': 'quay.io/pypa/manylinux2014_i686:2022-08-09-51a01be', 'pypy_x86_64': 'quay.io/pypa/manylinux2014_x86_64:2022-08-09-51a01be', 'aarch64': 'quay.io/pypa/manylinux2014_aarch64:2022-08-09-51a01be', 'ppc64le': 'quay.io/pypa/manylinux2014_ppc64le:2022-08-09-51a01be', 's390x': 'quay.io/pypa/manylinux2014_s390x:2022-08-09-51a01be', 'pypy_aarch64': 'quay.io/pypa/manylinux2014_aarch64:2022-08-09-51a01be', 'pypy_i686': 'quay.io/pypa/manylinux2014_i686:2022-08-09-51a01be'}
  musllinux_images: {'x86_64': 'quay.io/pypa/musllinux_1_1_x86_64:2022-08-09-51a01be', 'i686': 'quay.io/pypa/musllinux_1_1_i686:2022-08-09-51a01be', 'aarch64': 'quay.io/pypa/musllinux_1_1_aarch64:2022-08-09-51a01be', 'ppc64le': 'quay.io/pypa/musllinux_1_1_ppc64le:2022-08-09-51a01be', 's390x': 'quay.io/pypa/musllinux_1_1_s390x:2022-08-09-51a01be'}
#

notice the first image

bright glacier
lament crow
#

yeah, I doubt you'll be able to get it to build with old version like that

bright glacier
#

yup

#

I just realized that, the old images won't have 3.11

#

I'm dumb lemon_sweat

bright glacier
#

So legally speaking we are violating a whole wack of licenses via our pyinstaller executables by not redistributing the licenses of our dependencies

#

I'm less sure about this, but the compiled wheels might also violate a license or two as they probably include sources from both CPython and mypyc's C libraries (and maybe even system libraries via auditwheel/delocate???)

bright glacier
flat krakenBOT
flat krakenBOT
bright glacier
#

I'm going to be out for most of today without an internet connection so I'll be pretty unreachable. Just an FYI.

flat krakenBOT
flat krakenBOT
#

Describe the bug

When adding a name to .gitignore and negating a specific directory of that name, black incorrectly ignores the file.

.gitignore

build
!/foo/build

To Reproduce

By running this shell script you should see that git doesn't ignore the file but black does.

#!/usr/bin/env bash
set -e

# Create project directory
TMP_DIR="$(mktemp -d)"
cd "$TMP_DIR"

# Make this a git working copy
git -c init.defaultBranch=main init

# Create .gitig...
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 `...
flat krakenBOT
#

Some dependencies are blocking us testing black to make sure we're 100% 3.11 ready. Let work with/around them for now to at least get partial testing into CI.

This issue to to track all the needed fixes to get us there. Will get more detail here are we learn.

Known Issues

  • aiohttp for blackd
    • Will look at skipping blackd tests for now for 3.11
  • mypyc compiling

Step 1: Get partial 3.11 CI running
Step 2: work with dependency projects
Step X: Add back parts to get to ful...

neon loom
#

Canada go down again?

bright glacier
#

Nah, I was just out of the house, Rogers did not suffer another breakage ducky_dave

neon loom
#

That was a crazy outage. I didn't read the fine print, but the number of businesses single homed on them was crazy

#

(tips network engineer hat)

#

My house is even dual homed

bright glacier
#

Yeah I was offline for a whole day

#

everyone who had bell was totally fine though so that was fun

neon loom
#

Only problem is, it's TMobile 5G, and if the one cable provider in my little town goes down, the 5G gets saturated.

#

Been trying to get ADSL or a WISP link ... but not many options ๐Ÿ˜ฆ The bummer of living in the woods

#

I have a friend on Oakland CA, who has TWO 1/1 gig fibers with ATT and Sonic that take diverse paths for LESS than I pay for my 1 cable connection. lol

flat krakenBOT
#

Running the latest version of black on MacOS M1 systems fails with the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/black", line 5, in 
    from black import patched_main
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/black/__init__.cpython-39-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/black/__init__.c...
bright glacier
#

No idea why the above is happening.

little parrot
#

I've been seeing this with my new m2 MacBook which I migrated from an intel machine, but it was just fixed by reinstalling in my case

bright glacier
#

how strange

bright glacier
#

I still have no idea what is blowing up even after 20 minutes ๐Ÿ˜ฆ

neon loom
#

And I'm on my x86 Linux box in office + M1 is down stairs. #lifeIshard

bright glacier
#

Still working on that python SSH thing?

neon loom
#

Ya ya, SSH part is all done, just unittesting I'm not putting bad data into the modeling system

#

What's worse than no data? Incorrect data.

bright glacier
#

Writing unittests is rarely fun

neon loom
#

asyncssh is awesome with uvloop

bright glacier
#

I still haven't used SSH lol

neon loom
#

It would be an AWESOME candidate for mypyc

#

All it's encryption is done in pure python

bright glacier
#

mypyc's async support is a bit sketchy

#

it just landed support for async with and async for is still a WIP

neon loom
#

Ahh, also, I bet some of it's deps are not strongly typed

neon loom
bright glacier
#

me too

bright glacier
flat krakenBOT
#

Description

I had issue running Black in vim after recent updates (notably using vim > 9, linked against python 3.10.4), getting error:

TypeError: bool object expected; got int

after some tinkering i found that the values defined (or not) in pyproject.toml were the culprit. But even adding

string_normalization = false                                    
fast = true
quiet = false

in the black block of pyproject.toml, didn't help, as it was trying to convert a...

neon loom
#

I get compiled and all ...

bright glacier
#

Thanks, it's really odd how these folks are somehow getting the Intel wheels on their ARM systems

neon loom
#

I bet they don't update their setuptools + pip

lament crow
#

22.3.0 works for them though

neon loom
#

I even tried a fresh venv on 3.9, install 22.3.0 and then upgraded to 22.6.0 and it worked

#

To be fair, it's a horrible issue with 0 info on how to repro

lament crow
#

yeah, it must be something about how they installed it

#

but no info

neon loom
#

I tried. Now to get some work done so I can get us partially passing 3.11 CI later today ๐Ÿ˜„

lament crow
#

they're using Python 3.9 so unless they're using version older than 3.9.5, they would have new enough pip to install arm64 wheels tbh

neon loom
#

@bright glacier Be proud - I even tagged ๐Ÿ˜„

neon loom
lament crow
#

it must be installing compiled if it fails to import shared library, right

bright glacier
#

perhaps they're using the pure wheel for 22.3.0 for some reason?

lament crow
#

oh

#

like that

neon loom
#

Ya - we don't have 22.3.0 info ๐Ÿ™‚

lament crow
#

lol

bright glacier
#

not sure how that'd happen, something about weird caching but we don't know

#

also

lament crow
#

+1 I had 22.3.0 but I solved it installing black-21.4b0
oh god

bright glacier
#

I mean I know people can install packages that have conflicts with the already installed packages and pip won't error actually, but it will loudly warn

#

You'd think someone would've noticed that by now

lament crow
#

gotta be more aggressive with closing as no repro

bright glacier
lament crow
#

because these people don't do good job with presenting their problem

bright glacier
neon loom
#

It amazes me how people call themselves professional programmers but don't learn their language of choice packaging + installing.

It's like a mechanic not knowing what tool to use for different repair jobs.

lament crow
#

The author of the issue claims they have click 8.1.2 and black 22.3.0 but I wouldn't be too surprised if that's not the case because black gets imported from different place than click or something like that

#

/usr/local/lib/python3.9/site-packages already worries me lmao

neon loom
#

I see it all @ Meta ... from Data Scientists to CPython core devs using Python ...

bright glacier
#

I mean in fairness data science is an area where expecting the developers to know their packaging tooling is a bit of a stretch IMO

lament crow
#

because it's system-wide and that's always problematic (if you don't know what you're doing anyhow)

bright glacier
#

I mean, anaconda literally exists to help abstract away packaging from them, you can't blame the IMO

#

(not sure if anaconda redistributes black but I'm pretty sure they do)

neon loom
#

I get it, but still. Not understanding how python packages layout to create your data science code (if they go that route vs. notebooks etc.) should be learnt ...

neon loom
#

I've NEVER installed a package from anaconda ... lol

lament crow
#

I honestly don't really know how to version control notebooks properly

neon loom
#

And I've used python for a few years.

lament crow
#

but I only really needed to (or well, wanted to) version control notebooks for projects that I needed to do to complete university course

bright glacier
#

I have only used one notebook, and that was one hosted on GH lol

lament crow
#

and that one time when I contributed something to Instagram's Fixit repo which used notebooks for docs

neon loom
#

User can't repro anymore ... haha

lament crow
#

that's what happens when you don't write down the repro steps!

#

๐Ÿ˜„

bright glacier
#

yeah, way too many issues are filed with terrible reproduction steps (or none at all!)

flat krakenBOT
flat krakenBOT
neon loom
#

Ok - Can confirm, black installs (not blackd) and runs over it's own codebase in 3.11

cooper@home1:~/repos/black$ /tmp/tb/bin/python -V
Python 3.11.0rc1+
cooper@home1:~/repos/black$ /tmp/tb/bin/pip install .
Processing /cesspool/home/cooper/repos/black
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting click>=8.0.0
  Using cached click-8.1.3-py3-none-any.whl (96 kB)
Collecting platformdirs>=2
  Using cached platformdirs-2.5.2-py3-none-any.whl (14 kB)
Collecting pathspec>=0.9.0
  Using cached pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
Collecting mypy-extensions>=0.4.3
  Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Building wheels for collected packages: black
  Building wheel for black (pyproject.toml) ... done
  Created wheel for black: filename=black-22.6.1.dev33+g4ebf14d-py3-none-any.whl size=158445 sha256=2c0b4b8d25479eb9d8a16d025bee540a3e8fc47062c542bea33ebaaf1fd8ecf7
  Stored in directory: /tmp/pip-ephem-wheel-cache-b1r65m6v/wheels/52/83/28/8e56a09ecf908e4805edb77af7846d99f28341e5b6fdd2ed7e
Successfully built black
Installing collected packages: mypy-extensions, platformdirs, pathspec, click, black
Successfully installed black-22.6.1.dev33+g4ebf14d click-8.1.3 mypy-extensions-0.4.3 pathspec-0.9.0 platformdirs-2.5.2
cooper@home1:~/repos/black$ /tmp/tb/bin/black .
All done! โœจ ๐Ÿฐ โœจ
44 files left unchanged.
#

tox time

#

need to make 3.11 not install [d] I guess

flat krakenBOT
#
  • Had to exempt blackd tests for now due to aiohttp
    • Skip by using sys.version_info tuple
    • aiohttp does not compile in 3.11 yet - refer to #3230
  • Add a deadsnakes ubuntu workflow to run 3.11-dev to ensure we don't regress
    • Have it also format ourselves

Test:

  • tox -e 311

Description

Checklist - did you ...

  • [ ] Add a CHANGELOG entry if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
neon loom
#

Sweet - Passes

plain atlas
#

oops i thought i was in #bot-commands lol

flat krakenBOT
lament crow
#

huh, I completely missed the time you made plans for dropping Python 3.6 support in 22

bright glacier
#

maybe I should pin the issue

lament crow
#

call me surprised

#

I don't care for Python 3.6 but didn't expect you to do it before 23

bright glacier
#

not sure what to replace, but I guess the mypyc one since it's unlikely we'll hit more problems

#

unfortunately the click one is probably never going to be truly over

#

(unless we abuse the build number for wheels to update the requirement metadata afterthefact)

lament crow
#

just remember to bump python_requires when you drop support

#

one simple trick to prevent the world from going boom

#

:)

bright glacier
#

looks like pathspec on master is straight up broken as importing it fails with a circular import error

#

going to file an issue with them

#

wait what, cloning it locally it works fine, wat

bright glacier
#

what the hell, importing pathspec works if you're in the repository root

#

ah, sounds like the packaging setup is producing invalid wheels?

bright glacier
# lament crow circular import?
 python
Python 3.8.5 (default, Sep  9 2020, 23:45:44) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathspec
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ichard26/programming/testing/python-path-specification/venv/lib/python3.8/site-packages/pathspec/__init__.py", line 50, in <module>
    from . import patterns
ImportError: cannot import name 'patterns' from partially initialized module 'pathspec' (most likely due to a circular import) (/home/ichard26/programming/testing/python-path-specification/venv/lib/python3.8/site-packages/pathspec/__init__.py)
>>> 
lament crow
#

hmm, that should be importing the package

bright glacier
#

yeah it's only a problem if you install from a wheel

#

uhh where is the pathspec.patterns subpackage...? ๐Ÿ‘€

lament crow
#

bad setuptools config after they switched to pyproject.toml?

#

or a bug in setuptools if the config is right

bright glacier
#

probably

#

I haven't used setuptools's PEP 621 implementation though

lament crow
#

it's not a namespace package so

#

you would think that would get included

#

weird

bright glacier
#

I guess include doesn't apply to its children? (i.e. doesn't have wildcards affixed?)

lament crow
#

yeah, glob should solve it then

#

include = ["pathspec", "pathspec.*"]

bright glacier
#

That worked ๐ŸŽ‰

#

time to file a PR

elder tusk
bright glacier
#

It's probably worth hooking up GitHub Actions CI for pathspec given we depend on it.

#

I'll do that eventually if no one else gets to it before me.

#

(they have a travis config, but we all know how travis turned out)

lament crow
#

I'm unsure whether Travis CI was ever actually installed on the repo

#

I can't find a single commit that would have a check on it

#

there's a configuration, yes

#

but I don't know if it ever actually ran

bright glacier
#

I'm setting up github actions CI for them now

lament crow
bright glacier
#

yeah, turns out I really wanted to do some good ol' devops haha :)

#
โฏ git add .github
The following paths are ignored by one of your .gitignore files:
.github

-what even?

lament crow
#

I started watching the pathspec repo since the valid report on black where I told the author to report the issue and they still haven't ;-(

bright glacier
#

ah of course the test suite is failing on windows cause of backward slashes

#

typical windows experience :)

lament crow
#

you might want to tell them they'll need to go to the actions tab and enable the actions from there

bright glacier
#

I think they just need to approve the workflows to run since I'm a first-time contributor, no?

#

I'm pretty sure you can push a workflow file and it'll auto enable workflows

lament crow
#

it would show up as such then

lament crow
#

and I'm actually not entirely sure that auto-enabling is a thing

#

I recall having mixed experience with that in the past

bright glacier
#

I'll let them respond ยฏ_(ใƒ„)_/ยฏ

#

github, ugh, stop it >.<

flat krakenBOT
dense jungle
lament crow
#

In pathspec's case, the intention was to import a submodule but since there wasn't one with that name, the import system tried importing a name from the base module which made it into circular import

#

It is misleading in this case but in general, I like that Python tells you that you might be running into a circular import issue

#

so hopefully you wouldn't get rid of it entirely, just make it more descriptive in non-obvious cases

dense jungle
#

Yes, perhaps the heuristic for when we emit that wording could be improved. I haven't looked at the code though

lament crow
#

in this case, I still wouldn't mind having a suggestion that it might be a circular import but I definitely would love it if it said along the lines of lines "there's either no submodule with that name or you attempted a circular import"

#

basically, anything to make it not misleading while still being helpful

#

๐Ÿ˜„

bright glacier
#

Jeez, I come back to the project after getting sucked into mypyc stuff for several days, aaaaand there's now 37 open PRs ๐Ÿ‘€

#

To be honest, I'm not really in the mood to work on Black, but I am release managing this month's release and I still got a few RM tasks to do first.

#

Will review one or two PRs first and then get back to release stuff today (hopefully ๐Ÿคž )

bright glacier
flat krakenBOT
bright glacier
#

I have no idea what this code does in the first place ๐Ÿ˜…

flat krakenBOT
bright glacier
#

@neon loom do you mind if I push changes to your 3.11 PR? I'd like to try out Jelle's suggestion (to reduce the diff size and avoid unnecessarily ruin git blame) and also try to integrate py311 into the main tox test session (via some session specific conditionals)

neon loom
#

I did try that โ€ฆ

#

Itโ€™s the inheritance

bright glacier
#

right.

#

I can't even get my tox cleanup to work either ๐Ÿ˜ฆ No clean up then.

neon loom
#

Once aiohttp supports 3.11 my hacks go away too and I just add 3.11 to our main test CI โ€ฆ

#

So is it really worth more effort?

bright glacier
#

I already knew how I'd clean it up so it didn't take too much effort, I just didn't expect tox to not support our use-case.

commands =
    !py311: pip install -e .[d]
    py311: pip install -e .
#

I thought this would've worked, but nope. Anyway I decided to try deduplicating the sessions just so changes are easier to the config (we might to forget to update the 3.11 session for example) in case aiohttp take forever to support 3.11.

neon loom
#

Sure. What ever you think is best. We just wanted to prove we work on 3.11 and I thought I achieved that.

bright glacier
#

I guess tox -e py just doesn't work with tox conditionals as it could be hard getting the python version factor from that

bright glacier
# neon loom Itโ€™s the inheritance

Wait a second, how did the inheritance break things? The test suite should run on 3.11, it's just that the blackd tests fail. Skipping them should avoid failures, no?

neon loom
#

The inheritance need aiohttp installed to import

#

It does not build

#

Why are we wasting each otherโ€™s time?

bright glacier
#

Sorry I didn't mean to.

#

Anyway that question was dumb. I forgot that aiohttp doesn't install (mostly because I hacked it to successfully install on 3.11 by disabling Cython_

flat krakenBOT
bright glacier
#

I can't actually test tox -e ci-py311 and make sure it works because my 3.11 install seems to be broken... ? but either way it's a valid session name so it should be fine.

bright glacier
neon loom
#

I gave it the 10 mins it was worth considering it would go away

neon loom
#

๐Ÿ˜ฆ

bright glacier
#

I'll push a revert. I just need to stop wasting your time.

#

Sorry about that by the way. I really should've thought it more through.

neon loom
#

It's not a big deal, but our industry has a problem with over optimizing things that are not of large benefit for the time it can take.

#

I try to share the perspective to people is it really worth it - that's all I'm trying to share here.

#

We are all limited on time

lament crow
#

I mean, if they enjoy playing with it

#

this isn't a billed time so

neon loom
#

I agree, but like people to spend their limited donated time on impact not perfection ๐Ÿ™‚

bright glacier
#

Look, it's just my fault. I don't want to fight about it.

neon loom
#

It's just a personal preference and am for people to play with OSS projects etc. if it interests them

lament crow
#

I do get your point, I just don't necessarily agree with it in the OSS context

#

๐Ÿ˜„

neon loom
#

Each to their own. All good.

#

I've just seen to many people burn out on OSS

#

From doing micro optimizations that were not always huge benefit to all

#

But if people enjoy it, please.

red sedge
#

input is

    async def __aexit__(self, exc_type, exc_value, traceback):
        await self._close(
            # if we're handling an exception, we assume that it's more
            # important to deliver that exception than shutdown gracefully.
            fast=exc_type is not None
        )

output is

    async def __aexit__(self, exc_type, exc_value, traceback):
        await self._close(
            # if we're handling an exception, we assume that it's more
            # important to deliver that exception than shutdown gracefully.
            fast=exc_type
            is not None
        )
lament crow
#

or one of the issues that are linked in it

red sedge
bright glacier
#

It seems likely it's related

bright glacier
#
run-dunders.test:339: error: Unsupported left operand type for + (<nothing>)
run-dunders.test:339: error: Argument 1 to "abs" has incompatible type "int"; expected "__SupportsAbs[<nothing>]"

working with mypyc's test suite is really painful due to the limited builtins/typing stubs, ugh I don't understand what's wrong here

dense jungle
#

but yeah 90% of weird mypy test suite issues are due to fixtures

bright glacier
#
--- a/mypyc/test-data/fixtures/ir.py
+++ b/mypyc/test-data/fixtures/ir.py
@@ -3,7 +3,7 @@
 
 from typing import (
     TypeVar, Generic, List, Iterator, Iterable, Dict, Optional, Tuple, Any, Set,
-    overload, Mapping, Union, Callable, Sequence, FrozenSet
+    overload, Mapping, Union, Callable, Sequence, FrozenSet, Protocol
 )
 
 T = TypeVar('T')
@@ -12,6 +12,10 @@ S = TypeVar('S')
 K = TypeVar('K') # for keys in mapping
 V = TypeVar('V') # for values in mapping
 
+class SupportsAbs(Protocol[T_co]):
+    def __abs__(self) -> T_co: pass
+
+
 class object:
     def __init__(self) -> None: pass
     def __eq__(self, x: object) -> bool: pass
@@ -308,7 +312,7 @@ def zip(x: Iterable[T], y: Iterable[S]) -> Iterator[Tuple[T, S]]: ...
 @overload
 def zip(x: Iterable[T], y: Iterable[S], z: Iterable[V]) -> Iterator[Tuple[T, S, V]]: ...
 def eval(e: str) -> Any: ...
-def abs(x: float) -> float: ...
+def abs(x: SupportsAbs[T]) -> T: ...
 def exit() -> None: ...
 def min(x: T, y: T) -> T: ...
 def max(x: T, y: T) -> T: ...

Kind of hacky defining a typing name in a builtins stub but there's not really anywhere else that'd be less painful (since by default this stub uses the limited typing stub from mypy). Not that this works anyway.

dense jungle
#

does int have __abs__ in this fixture?

bright glacier
#

of course not

#

will add to int/float

#

OK that finally worked. I forgot that int/float were also defined in this stub. Thanks for the pointer!

clever peak
#

i get a segfault error when i run a .so file compiled with mypyc, how can i see why it segfaulted?

dense jungle
#

or look at a core dump

clever peak
red sedge
#

how do you manage dupes on your issue tracker?

#

like it seems black is prone to a bunch of indescribable or uname-able behaviors with a many to one relationship to bug fix

#

most of the stuff I find are "black did this and I don't like it and don't know why"

dense jungle
#

I have tried to reduce them by adding precise labels and closing ones that seem to describe the same behavior

#

Could do more though

red sedge
#

it seems like naming the issue is like 80% of the work and the bug fix is the other 80%

red sedge
bright glacier
#

Yeah, you do get better with time at discerning what behaviours seem similar/related. It takes lots of time though so that's we rarely do issue tracker cleanups.

#

It's expected there are duplicates, it's not the easiest thing in the world to constantly keep track on the hundreds of issues.

#

When a new issue is filed, if we already know that it's a duplicate of something else (and we know what to search for so we can find the original issue) then we'll usually try to dedupe immediately, but otherwise, they're left until we do another issue tracker cleanup.

clever peak
bright glacier
clever peak
#

or is that not the case? if its not then i guess mypyc in general

bright glacier
#

??? I'm asking if Black is segfaulting for you.

#

It wasn't clear in your original message whether you were compiling your own code with mypyc or were using black (that is compiled with mypyc)

clever peak
#

oh, mypyc sorry

bright glacier
#

So you're compiling your own code with mypyc? black is not segfaulting?

clever peak
#

thats correct

bright glacier
#

OK good, because this channel is meant for the black formatter project so I'd be concerned if black was crashing ๐Ÿ˜„

clever peak
#

oops, sorry, which channel is appropiate?

bright glacier
#

This place ends up involving mypyc chatter though because we use mypyc to compile black and I contribute to mypyc

dense jungle
clever peak
#

yeah thats why i had come here since this seem the place with the most mypyc chatter

bright glacier
#

I haven't found a good place to talk about mypyc so I'm just abusing this channel to be honest ๐Ÿ™‚

#

mypy in general used to have a gitter instance, but it got merged into python/typing so I doubt mypyc would be welcome there

clever peak
bright glacier
#

Yeah, people familiar with mypyc are still hard to find since there's not really a designated place for them.

#

If you want to grab an OT channel, I can try to help you out with your issue since I'm fairly familiar with mypyc.

#

(a help channel works too, doesn't really matter, it's still Python after all ๐Ÿ˜„ )

lament crow
#

Is it Python? I thought it's magic.

#

:)

bright glacier
#

I mean, there's a lot of hacks involved :)

#

dataclasses support is really a hack which is why it's so painful to use them in black as mypyc doesn't have good support for them

silent apex
#

what's so hacky about it?

late dewBOT
#

mypyc/lib-rt/misc_ops.c line 336

CPyDataclass_SleightOfHand(PyObject *dataclass_dec, PyObject *tp,```
silent apex
#

SleightOfHand
oh.

bright glacier
#

since we compile classes into native classes (and change how the attributes work) we have to edit the type object on the fly to pretend it's more like a regular Python class, pass that to the dataclass decorator and then reapply the actual attributes

silent apex
#

oh i see

bright glacier
#

The more robust solution is to compile away the dataclass decorator entirely and reimplement all of the fields and methods the decorator attaches.

#

That's a pretty large task though.

silent apex
#

oh i kind of assumed mypyc maintained (at least part of) it's own copy of the stdlib

#

so it could make things work nicer

bright glacier
silent apex
#

ah

flat krakenBOT
elder tusk
bright glacier
#

thank you! will take a look today or tomorrow

half meteor
bright glacier
#

Getting this ^^ merged along with the autoupdate stable branch PR is everything that I personally need to handle before I can cut a release.

bright glacier
flat krakenBOT
#

Describe the style change

Examples in the current Black style

init >> prepare[0], prepare[
        -1
    ] >> approve >> fork >> branch_start, branch_end >> join >> done

Desired style

init >> prepare[0], prepare[-1] >> approve >> fork >> branch_start, branch_end >> join >> done

Additional context
Actually I've no idea why prepare[-1] was formatted and prepare[0] not. Is there an option to avoid this kind of for...

flat krakenBOT
#

Describe the bug

Trailing commas are incorrectly being ruthlessly collapsed into one line

To Reproduce

Reproes in the black playground

def method(
    self,
) -> typing_extensions.Literal[
    "l1",
    "l2",
]: pass

Result is

def method(
    self,
) -> typing_extensions.Literal["l1", "l2",]:
    pass

Expected behavior

I'd expect no change to the Literal writeout.

Environment

Black 22.6.0 in the black playground...

mint barn
#

poopfart

flat krakenBOT
#

Hey All! Stubled upon this, hope this is still relevant

error: cannot format [ommited]/pyqtgraph/widgets/TreeWidget.py: 
INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_c76gbp19.log

This version produced the error:

 python3 -mblack --version
__main__.py, version 20.8b1

This version handles it fine:

black, 22.3.0 (compiled: ye...
bright glacier
#

@grizzled vessel fwiw do you want to add yourself to the AUTHORS list in your PR? If not, I'll remove the changelog entry as it's unnecessary and merge.

flat krakenBOT
#

The amount of changes diff-shades reports for this PR scares me, especially since I'm not entirely sure if it's really an improvement in situations like these:

--- a/warehouse:warehouse/packaging/services.py
+++ b/warehouse:warehouse/packaging/services.py
@@ -33,13 +33,15 @@
         # This class should not be used in production, it's trivial for it to
         # be used to read arbitrary files from the disk. It is intended ONLY
         # for local development with trusted use...
grizzled vessel
#

I thought I had to do it since it was in the PR template ๐Ÿ˜…

#

Glad the change worked though firHappy

bright glacier
#

@dense jungle

@@ -17,12 +14,16 @@
     "for safely locating files on disk.",
     InsecureStorageWarning,
 )
 
 d = {
-    "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination         a",
+    "DEFAULT_PAGINATION_CLASS": (
+        "rest_framework.pagination.LimitOffsetPagination         a"
+    ),
 }
 
 {
-    "x": "some aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa"
-    "long string aaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa",
+    "x": (
+        "some aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa"
+        "long string aaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa"
+    ),
 }

looks like we already wrap multiline strings as dictionary values on main? (with --preview only mind you)

#

Obviously there's still the problem of strings that can't be broken up by having no spaces, but that's psf/black#413

dense jungle
toxic stormBOT
bright glacier
#

Apparently we fixed this before 22.1.0 ยฏ_(ใƒ„)_/ยฏ

dense jungle
#

maybe the original ESP PR changed this?

bright glacier
#

I'd try bisecting but testing anything older than 20.8b1 is pretty annoying. Anyway 20.8b1 also wraps the string so it's probably the original ESP PR

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Describe the style change

There are some situations in which lists and tuples have equivalent semantics, which presents an opportunity for standardisation. Tuples should be marginally faster.

Examples in the current Black style

for p in [2, 3, 5]:
    ...
[f(x) for x in [1, 4, 3]]
if size in ["med", "big"]:
    ...
for p in (2, 3, 5):
    ...
[f(x) for x in (1, 4, 3)]
if size in ("med", "big"):
    ...

Desired style

for p in (2,...
bright glacier
#

Yeah, I don't think this is happening ...

dense jungle
bright glacier
#

(so does mypyc, actually it converts it into a series of == / != checks bypassing the tuple/list overhead entirely)

bright glacier
late dewBOT
#

@bright glacier :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 |   0           0 RESUME                   0
002 | 
003 |   1           2 LOAD_NAME                0 (x)
004 |               4 LOAD_CONST               0 ((1, 2, 4))
005 |               6 CONTAINS_OP              0
006 |               8 RETURN_VALUE
007 |   0           0 RESUME                   0
008 | 
009 |   1           2 LOAD_NAME                0 (x)
010 |               4 LOAD_CONST               0 ((1, 2, 4))
011 |               6 CONTAINS_OP              0
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/cibugibuga.txt?noredirect

bright glacier
#

TIL, I didn't actually know it did this. I knew CPython did this for set literals (converting them to frozenset constants) but the thought it also works for other collection literals didn't occur to me :)

flat krakenBOT
flat krakenBOT
#

Hey!

It's incredible how we managed to miss this simple error for so long. Great to see it fixed finally ahaha. Would you mind adding a changelog entry (in CHANGES.md) and writing a test case for this (you'd put it under TestFileCollection, see its other cases as examples) so we won't regress on this? If not, no worries, I'm happy to do these things for you.

Also, FYI I updated y...

flat krakenBOT
#

Description

  • Formalise release cadence guidelines
  • Overhaul release steps to be easier to follow and more thorough
  • Reorder changelog template to something more sensible
  • Update release automation docs to reflect recent improvements (notably the addition of in-repo mypyc wheel builds)

Review notes

See https://ichard26-testblackdocs.readthedocs.io/en/overhaul-release-doc/contributing/release_process.html for a preview of this newly rewritten document.

@felix-hilden g...

flat krakenBOT
bright glacier
#

Ugh, turns out converting these square brackets to parentheses is not an AST-safe transformation:

for [x,] in points:
    pass
#

This makes the removal of unnecessary brackets for unpacking/extended assignments a bit tricky since maybe_make_parens_invisible_in_atom is not designed to handle square brackets

#

For for statements, it's not too bad, no one would be using square brackets like this anyway, but I've seen square brackets in regular unpacking assignment statements before so yeah, psf/black#3203 is going to involve shuffling around of pre-existing logic.

toxic stormBOT
bright glacier
#

On the bright side, I can probably submit my patch for psf/black#3080 since scope-creeping it to include square brackets and regular unpacking assignment statements turns out to be not trivial.

toxic stormBOT
flat krakenBOT
#

Description

Fixes #3080.

What remains is removing unnecessary brackets because yes, you can do this:

for [x, y] in points:
    print("this is valid code!!!")

I'm leaving this as a future task because it turns out simply converting these square brackets into parentheses is not an AST-safe transformation. And maybe_make_parens_invisible_in_atom is currently not designed to handle square brackets and initial attempts to add a boolean `treat_square_brackets_as_p...

bright glacier
#

My gosh, what I thought would be an easy patch took way too much time and energy. Way too much frustration, grr.

dense jungle
#

What is the point of the stable tag/branch anyway? Do people use it?

bright glacier
#

yeah our vim integration / github action docs currently suggest it as an option

#

not sure what else depends on it, but I'm going to assume lots given it's been there for a long now

late dewBOT
#

.github/workflows/linters.yml line 62

uses: psf/black@stable```
dense jungle
#

I suppose now we can't get rid of it without breaking a lot of users

bright glacier
#

It'd be nice to get rid of it, but it's old history now. Might as well automate it I guess.

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

I am currently using autopep8 to format the code in a repository and would like to gradually migrate only a part of the code to black formatting. In order to do this easily, I would like to be able to ignore selectively individual files by adding a comment at the top of the file I want to ignore. I can use "# fmt: off" but then this disables autopep8 formatting as well, while I would like to be able to disable only black an...

lament crow
#

Aww, more docstring processing is coming

#

Guess that's what I get for choosing an opinionated formatter, huh? :P

#

How much of that do you plan btw

#

psf/black#2885 I know of

toxic stormBOT
half meteor
#

question about https://github.com/psf/black/issues/1352
i have a ~200 lines of patch that actually implements the functionality to restrict the formatting given a list of line ranges, mostly leveraging the existing # fmt: on/off logic (that's also why i sent a few PRs fixing some bugs related to fmt off ๐Ÿ™‚ )
are you interested in supporting this in black? i haven't done research what the actual interface will be, i.e. how editors/IDEs and git will give black the list of line ranges to format.

GitHub

My problem is that sometimes I'm editing some code in a project that doesn't use Black (heresy, I know). Sometimes I'll type some code, or paste into the source something li...

flat krakenBOT
#

The existing example pyproject.toml has the extend-exclude options commented out, so the syntax isn't correct. It's possible that it's self-evident to others, but I have not been able to wrap my head around the proper way to do it. It appears that it does not work like the include option.

Here's what mine looks like right now, but returns:
Error: Invalid value for '--extend-exclude': Not a valid regular expression: nothing to repeat at position 0

[tool.black]
    include ...
cinder elm
#

!eval

#pass the cutty
from random import randint, choice
#probability pool based on real world data
pool = []
pool.append("Mega")
for x in range(7): pool.append("Purple")
for x in range(22): pool.append("Cuteson")
for x in range(90): pool.append("Cutty")
pool.append("Little")

legend = {"Cutty": 1,
         "Cuteson": 5,
         "Purple": 15,
         "Little": 25,
         "Mega": 40}
  


totalpoints = 0

def roll_cutty():
  global totalpoints
  points = 0
  while True:
    rollq = input("Roll? ")
    if rollq == "y":
      pass
    else:
      totalpoints += points
      print(f"you gained {points} points")
      print(f"you now have {totalpoints} points")
      break
    if randint(1,200) == 122:
      print("Cuteout: back to zero!")
      points = 0
    rolls = [choice(pool),choice(pool)]
    print(f"You got a {rolls[0]} and a {rolls[1]}")
    total = 0
    if rolls[0] == "Cutty" and rolls[1] == "Cutty" and randint(1,4) == 1:
      print("You rolled 2 Cuttys, but they were opposite! Lost all points!")
      points = 0
      print(f"You now have {points} potential points")
      break
    else:
      for x in rolls:
        points += legend[x]
        total += legend[x]
      print(f"+{total} points!")
      print(f"You now have {points} potential points")
    
      
      
while True: 
  roll_cutty()

late dewBOT
#

@cinder elm :x: Your 3.10 eval job has completed with return code 1.

001 | Roll? Traceback (most recent call last):
002 |   File "<string>", line 54, in <module>
003 |   File "<string>", line 25, in roll_cutty
004 | EOFError: EOF when reading a line
bright glacier
#

Misclicked the wrong channel @cinder elm ?

#

This isn't #bot-commands :)

bright glacier
#

Wow the current .gitignore tests suck, they're barely testing anything.

#

Nevermind, apparently the autocomplete for vim in fish hides .gitignore files >.<

#

It's so nice when you can use the file collection test case helper I made a while ago. So easy to write a test case:

    def test_nested_gitignore_directly_in_source_directory(self) -> None:
        # https://github.com/psf/black/issues/2598
        path = Path(DATA_DIR / "nested_gitignore_tests")
        src = Path(path / "root" / "child")
        expected = [src / "a.py", src / "c.py"]
        assert_collected_sources([src], expected)
flat krakenBOT
#

Description

Closes #2560.
This should get a label to silence the CHANGELOG entry check.


Adds documentation to the Future Style guide which advises the user to consider using contextlib.ExitStack() as opposed to large number of context managers following the with statement. For example, as in the Issue,

with contextlib.ExitStack() as exit_stack:
    cm1 = exit_stack.enter_context(make_context_manager(1))
    cm2 = exit_stack.enter_context(make_cont...
flat krakenBOT
swift fossil
#

Thanks, y'all, for being so friendly to beginners!

A while ago I promised to contribute (#black-formatter message) and I am finally getting into it with the above PR.

I made OSS contributions one of my goals at my job, so I actually have the time to do this more now! :']

bright glacier
#

I'm trying my best to make contributing to black as smooth as an experience it reasonably can be, thanks :)

swift fossil
#

I've tried to make PRs into some other open-source things (without much, if any, traction or interaction) and I was surprised at how fast and reasonable this was . :'']

bright glacier
#

There is a reason why we mark documentation issues as good first issues, they're relatively easy haha

#

You got pretty lucky with my response time since I was already reviewing another PR so I was already around to do another one. Although in general for documentation PRs, we are pretty fast since they are usually simple.

swift fossil
#

Haha, yeah, I expected like, a week response time. :''] Also, do I need to do anything else for this to get merged, or will y'all take care of that?

bright glacier
#

You're good, it's on us to press the green button that does the merge ^^

bright glacier
#

Bah, of course I missed a grammatical issue. This is why I don't merge any significant documentation changes without Jelle looking over it, I'm awful at English proofreading apparently.

bright glacier
flat krakenBOT
#

22.8.0 has been cut, let the planning for 22.9.0 begin!

Please use/see the associated milestone for what should ideally be done. Suggestions are welcome in this thread.

I'll note that this release we are planning to remove Python 3.6 runtime support and switch to Hatch. I plan to handle that myself, but this is a somewhat major change hence the mention. I will not be the RM for this release, I need a bit of a break for the time being.

bright glacier
#

The release process for 22.8.0 is now officially done.

#

Almost everything went smoothly, except for the native macOS executable build. I broke it ๐Ÿ˜… psf/black#3250

bright glacier
#

although ...

#

this shouldn't have broken if the CPython docs are to be believed

lament crow
#

well, you made it before UTC September :)

#

barely but still!

bright glacier
#

oh dear gosh you're right haha

#

that would've been pretty embarrassing if it was September in UTC time

lament crow
#

it's September in Poland for almost 2 hours now

bright glacier
#

So I'm late in ลukasz time, great ducky_australia

midnight thistle
#

hello people i am new to python

#

so can anyone teach me python in deep

#

i am at looping

flat krakenBOT
#

Description

This change updates the message returned when Jupyter dependencies are not installed, so that it contains syntax corresponding to the platform.

Previously, attempting to apply black formatting to an ipynb notebook without black[jupyter] installed always returned the hint to run pip install black[jupyter]. This command does not work on Ubuntu with python3.

With this change, in the same scenario, the hint is pip install 'black[jupyter]' if "linux" is in the platfo...

west nacelle
kindred ingot
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 `...
flat krakenBOT
#

Describe the bug

When using black and virtualenv, black try to reformat entire virtual env folder, which cause heavy process execution and hang very long.

To Reproduce
For example, take this code:

mkdir myfolder

cd myfolder

virtualenv env

source env/bin/activate

pip install black

pip list

Package           Version
----------------- -------
black             22.8.0
click             8.1.3
mypy-extensions   0.4.3
pathspec          0.10.0
pip ...
bright glacier
#

For the record, I used to name my virtual environments env , but I stopped a long while ago.

#

any reason to not ask upstream to yank pathspec 10.0.0 @dense jungle ?

#

looks pretty serious from the upstream bug report

bright glacier
#

Will do so then, I've contributed to the repository before so this should be friendly ๐Ÿคž

bright glacier
#

I guess I'm just to used to the Python world. I wouldn't think to use env in a Python codebase, but now I think about it, could see it being used.

#

Would be a reasonable subpackage name for one

lament crow
#

I use .venvs which is somewhat problematic to some tools as well ๐Ÿ˜„ Partially resolved by putting gitignore in the directory + in global gitignore but not all tools necessarily adhere to it. And then there's flake8 that doesn't even have the common venv or .venv in default excludes :/

flat krakenBOT